Segfault in footprint editor after multiple tool activations (lp:#1836419)

[Original report](https://bugs.launchpad.net/bugs/1836419) created by **Seth Hillbrand (sethh)**
```
To recreate:

1) Open footprint editor and open footprint
2) Add a polygon
3) Add an arc
4) Add a line

Other combinations do not seem to trigger the bug.  The following is an
assert backtrace.  Clicking continue on the assert segfaults with no useful
backtrace information.

Backtrace:
#0  0x00007ffff65a35cb in raise (sig=5) at
../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7862cbd in wxGUIAppTraits::ShowAssertDialog(wxString const&)
() at /usr/lib/x86_64-linux-gnu/libwx_gtk3u_core-3.0.so.0
#2  0x00007ffff7344ab2 in  () at /usr/lib/x86_64-linux-
gnu/libwx_baseu-3.0.so.0
#3  0x00007ffff73469b0 in wxAppConsoleBase::OnAssertFailure(wchar_t const*,
int, wchar_t const*, wchar_t const*, wchar_t const*) () at
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#4  0x00007ffff7831b30 in wxApp::OnAssertFailure(wchar_t const*, int,
wchar_t const*, wchar_t const*, wchar_t const*) () at
/usr/lib/x86_64-linux-gnu/libwx_gtk3u_core-3.0.so.0
#5  0x00007ffff7346c68 in  () at /usr/lib/x86_64-linux-
gnu/libwx_baseu-3.0.so.0
#6  0x00007ffff7342b16 in wxOnAssert(char const*, int, char const*, char
const*, char const*) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#7  0x00007fffdf4eb0ba in TOOL_MANAGER::ScheduleWait(TOOL_BASE*,
TOOL_EVENT_LIST const&) (this=0x5555562c29b0, aTool=0x5555591ca700,
aConditions=...) at ../../common/tool/tool_manager.cpp:513
#8  0x00007fffdf4e9585 in TOOL_INTERACTIVE::Wait(TOOL_EVENT_LIST const&)
(this=0x5555591ca700, aEventList=...) at
../../common/tool/tool_interactive.cpp:59
#9  0x00007fffdedfecb8 in DRAWING_TOOL::drawSegment(int, DRAWSEGMENT*&,
boost::optional<VECTOR2<double> >) (this=0x5555591ca700, aShape=0,
aGraphic=@0x55555f135cd8: 0x55555bdc3e50, aStartingPoint=...)
    at ../../pcbnew/tools/drawing_tool.cpp:902
#10 0x00007fffdedfa014 in DRAWING_TOOL::DrawLine(TOOL_EVENT const&)
(this=0x5555591ca700, aEvent=...) at
../../pcbnew/tools/drawing_tool.cpp:151
#11 0x00007fffdee0bbc4 in std::__invoke_impl<int, int
(DRAWING_TOOL::*&)(TOOL_EVENT const&), DRAWING_TOOL*&, TOOL_EVENT
const&>(std::__invoke_memfun_deref, int (DRAWING_TOOL::*&)(TOOL_EVENT
const&), DRAWING_TOOL*&, TOOL_EVENT const&) (__f=
   @ 0x555557e69b30: (int (DRAWING_TOOL::*)(class DRAWING_TOOL * const,
const class TOOL_EVENT &)) 0x7fffdedf9d24
<DRAWING_TOOL::DrawLine(TOOL_EVENT const&)>, __t=@0x555557e69b40:
0x5555591ca700, __args#0=...)
    at /usr/include/c++/8/bits/invoke.h:73
#12 0x00007fffdee0b8f1 in std::__invoke<int (DRAWING_TOOL::*&)(TOOL_EVENT
const&), DRAWING_TOOL*&, TOOL_EVENT const&>(int
(DRAWING_TOOL::*&)(TOOL_EVENT const&), DRAWING_TOOL*&, TOOL_EVENT const&)
(__fn=
   @ 0x555557e69b30: (int (DRAWING_TOOL::*)(class DRAWING_TOOL * const,
const class TOOL_EVENT &)) 0x7fffdedf9d24
<DRAWING_TOOL::DrawLine(TOOL_EVENT const&)>, __args#0=@0x555557e69b40:
0x5555591ca700, __args#1=...) at /usr/include/c++/8/bits/invoke.h:95
#13 0x00007fffdee0b4ad in std::_Bind<int (DRAWING_TOOL::*(DRAWING_TOOL*,
std::_Placeholder<1>))(TOOL_EVENT const&)>::__call<int, TOOL_EVENT const&,
0ul, 1ul>(std::tuple<TOOL_EVENT const&>&&, std::_Index_tuple<0ul, 1ul>)
(this=0x555557e69b30, __args=...) at /usr/include/c++/8/functional:400
#14 0x00007fffdee0ab55 in std::_Bind<int (DRAWING_TOOL::*(DRAWING_TOOL*,
std::_Placeholder<1>))(TOOL_EVENT const&)>::operator()<TOOL_EVENT const&,
int>(TOOL_EVENT const&) (this=0x555557e69b30, __args#0=...)
    at /usr/include/c++/8/functional:484
#15 0x00007fffdee09db5 in std::_Function_handler<int (TOOL_EVENT const&),
std::_Bind<int (DRAWING_TOOL::*(DRAWING_TOOL*,
std::_Placeholder<1>))(TOOL_EVENT const&)> >::_M_invoke(std::_Any_data
const&, TOOL_EVENT const&) (__functor=..., __args#0=...) at
/usr/include/c++/8/bits/std_function.h:282
#16 0x00007fffdf4f8e19 in std::function<int (TOOL_EVENT
const&)>::operator()(TOOL_EVENT const&) const (this=0x55555859f2a8,
__args#0=...) at /usr/include/c++/8/bits/std_function.h:687
#17 0x00007fffdf4f6132 in COROUTINE<int, TOOL_EVENT
const&>::callerStub(long) (aData=140737488342496) at
../../include/tool/coroutine.h:331
#18 0x00005555556f9b21 in make_fcontext ()



Application: ModEdit
Version: (5.1.0-1256-g39954b20f-dirty), debug build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.64.0 OpenSSL/1.1.1c zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2
(+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3
Platform: Linux 4.19.0-5-amd64 x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
    Boost: 1.67.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.64.0
    Compiler: GCC 8.3.0 with C++ ABI 1013

Build settings:
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON
```
Original tags: pcbnew

Story points: 6.0