crash after activating/escaping move and grab tool (lp:#1836218)

[Original report](https://bugs.launchpad.net/bugs/1836218) created by **Thomas Pointhuber (pointhi)**
```
To cause this I selected an element, and changed between grab and move tool
without deselect. Then escaped. (in some cases a escape changes back to
move/grab instead of exiting both tools):

Not reproducible for me right now, but here is the stacktrace:

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `eeschema/eeschema'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007f87aaf38755 in raise () from /usr/lib/libc.so.6
[Current thread is 1 (Thread 0x7f87a7fbd9c0 (LWP 8906))]
(gdb) bt
#0  0x00007f87aaf38755 in raise () at /usr/lib/libc.so.6
#1  0x00007f87aaf23851 in abort () at /usr/lib/libc.so.6
#2  0x00007f87aaf7aa38 in __libc_message () at /usr/lib/libc.so.6
#3  0x00007f87aaf8125a in  () at /usr/lib/libc.so.6
#4  0x00007f87aaf82a6e in _int_free () at /usr/lib/libc.so.6
#5  0x00007f87a58d4a20 in
__gnu_cxx::new_allocator<TOOL_EVENT*>::deallocate(TOOL_EVENT**, unsigned
long) (this=0x7ffe20ee2840, __p=0x55fe6b3b3890)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/ext/new_allocator.h:128
#6  0x00007f87a58d49f0 in std::allocator_traits<std::allocator<TOOL_EVENT*>
>::deallocate(std::allocator<TOOL_EVENT*>&, TOOL_EVENT**, unsigned long)
(__a=..., __p=0x55fe6b3b3890, __n=8)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/alloc_traits.h:470
#7  0x00007f87a58d4576 in std::_Deque_base<TOOL_EVENT,
std::allocator<TOOL_EVENT> >::_M_deallocate_map(TOOL_EVENT**, unsigned
long) (this=0x55fe670be2e0, __p=0x55fe6b3b3890, __n=8)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/stl_deque.h:638
#8  0x00007f87a58d557c in std::_Deque_base<TOOL_EVENT,
std::allocator<TOOL_EVENT> >::~_Deque_base() (this=0x55fe670be2e0) at
/usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/stl_deque.h:682
#9  0x00007f87a58d4042 in std::deque<TOOL_EVENT, std::allocator<TOOL_EVENT>
>::~deque() (this=0x55fe670be2e0) at /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/stl_deque.h:1069
#10 0x00007f87a58d3d95 in TOOL_EVENT_LIST::~TOOL_EVENT_LIST()
(this=0x55fe670be2e0) at ./kicad-source-
mirror/include/tool/tool_event.h:556
#11 0x00007f87a5b5b82c in std::pair<TOOL_EVENT_LIST, std::function<int
(TOOL_EVENT const&)> >::~pair() (this=0x55fe670be2e0) at
/usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/stl_pair.h:208
#12 0x00007f87a5b5f0d5 in std::_Destroy<std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> > >(std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*) (__pointer=0x55fe670be2e0)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/stl_construct.h:98
#13 0x00007f87a5b5f09f in
std::_Destroy_aux<false>::__destroy<std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*>(std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*, std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*) (__first=0x55fe670be2e0,
__last=0x55fe670bf000) at /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/stl_construct.h:108
#14 0x00007f87a5b5f05d in std::_Destroy<std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*>(std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*, std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*) (__first=0x55fe670bd9b0,
__last=0x55fe670bf000) at /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/stl_construct.h:136
#15 0x00007f87a5b5efa1 in std::_Destroy<std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*, std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> > >(std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*, std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*,
std::allocator<std::pair<TOOL_EVENT_LIST, std::function<int (TOOL_EVENT
const&)> > >&) (__first=0x55fe670bd9b0, __last=0x55fe670bf000)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/stl_construct.h:206
#16 0x00007f87a5b63e9b in std::vector<std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >,
std::allocator<std::pair<TOOL_EVENT_LIST, std::function<int (TOOL_EVENT
const&)> > > >::_M_erase_at_end(std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >*) (this=0x55fe66f57108,
__pos=0x55fe670bd9b0) at /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/stl_vector.h:1793
#17 0x00007f87a5b5b858 in std::vector<std::pair<TOOL_EVENT_LIST,
std::function<int (TOOL_EVENT const&)> >,
std::allocator<std::pair<TOOL_EVENT_LIST, std::function<int (TOOL_EVENT
const&)> > > >::clear() (this=0x55fe66f57108)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/9.1.0/../../../../include/c++/9.1.0/bits/stl_vector.h:1496
#18 0x00007f87a5b5893c in TOOL_MANAGER::dispatchInternal(TOOL_EVENT const&)
(this=0x55fe65c21300, aEvent=...) at ./kicad-source-
mirror/common/tool/tool_manager.cpp:605
#19 0x00007f87a5b57286 in TOOL_MANAGER::processEvent(TOOL_EVENT const&)
(this=0x55fe65c21300, aEvent=...) at ./kicad-source-
mirror/common/tool/tool_manager.cpp:939
#20 0x00007f87a5b57361 in TOOL_MANAGER::processEvent(TOOL_EVENT const&)
(this=0x55fe65c21300, aEvent=...) at ./kicad-source-
mirror/common/tool/tool_manager.cpp:949
#21 0x00007f87a5b57361 in TOOL_MANAGER::processEvent(TOOL_EVENT const&)
(this=0x55fe65c21300, aEvent=...) at ./kicad-source-
mirror/common/tool/tool_manager.cpp:949
#22 0x00007f87a5b57174 in TOOL_MANAGER::RunAction(TOOL_ACTION const&, bool,
void*) (this=0x55fe65c21300, aAction=..., aNow=true, aParam=0x0) at
./kicad-source-mirror/common/tool/tool_manager.cpp:291
#23 0x00007f87a55a39a0 in TOOL_MANAGER::RunAction(TOOL_ACTION const&, bool)
(this=0x55fe65c21300, aAction=..., aNow=true) at ./kicad-source-
mirror/include/tool/tool_manager.h:141
#24 0x00007f87a5b261ab in ACTION_MANAGER::RunHotKey(int) const
(this=0x55fe66be3570, aHotKey=77) at ./kicad-source-
mirror/common/tool/action_manager.cpp:149
#25 0x00007f87a5b58cf6 in TOOL_MANAGER::dispatchHotKey(TOOL_EVENT const&)
(this=0x55fe65c21300, aEvent=...) at ./kicad-source-
mirror/common/tool/tool_manager.cpp:636
#26 0x00007f87a5b57253 in TOOL_MANAGER::processEvent(TOOL_EVENT const&)
(this=0x55fe65c21300, aEvent=...) at ./kicad-source-
mirror/common/tool/tool_manager.cpp:934
#27 0x00007f87a5b599bf in TOOL_MANAGER::ProcessEvent(TOOL_EVENT const&)
(this=0x55fe65c21300, aEvent=...) at ./kicad-source-
mirror/common/tool/tool_manager.cpp:782
#28 0x00007f87a5b51c57 in TOOL_DISPATCHER::DispatchWxEvent(wxEvent&)
(this=0x55fe66be21a0, aEvent=...) at ./kicad-source-
mirror/common/tool/tool_dispatcher.cpp:466
#29 0x00007f87a5be9126 in EDA_DRAW_PANEL_GAL::OnEvent(wxEvent&)
(this=0x55fe65c23940, aEvent=...) at ./kicad-source-
mirror/common/draw_panel_gal.cpp:447
#30 0x00007f87ac3f389e in
wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&,
wxEvtHandler*, wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#31 0x00007f87ac3f3c1b in wxEvtHandler::SearchDynamicEventTable(wxEvent&)
() at /usr/lib/libwx_baseu-3.0.so.0
#32 0x00007f87ac3f3cb1 in wxEvtHandler::TryHereOnly(wxEvent&) () at
/usr/lib/libwx_baseu-3.0.so.0
#33 0x00007f87ac3f3d64 in wxEvtHandler::ProcessEventLocally(wxEvent&) () at
/usr/lib/libwx_baseu-3.0.so.0
#34 0x00007f87ac3f3e02 in wxEvtHandler::ProcessEvent(wxEvent&) () at
/usr/lib/libwx_baseu-3.0.so.0
#35 0x00007f87ac99467d in wxScrollHelperEvtHandler::ProcessEvent(wxEvent&)
() at /usr/lib/libwx_gtk3u_core-3.0.so.0
#36 0x00007f87ac3f3ba7 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () at
/usr/lib/libwx_baseu-3.0.so.0
#37 0x00007f87ac799e50 in  () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#38 0x00007f87aabf2a9f in  () at /usr/lib/libgtk-3.so.0
#39 0x00007f87aa6f7e55 in g_closure_invoke () at
/usr/lib/libgobject-2.0.so.0
#40 0x00007f87aa6e4ec7 in  () at /usr/lib/libgobject-2.0.so.0
#41 0x00007f87aa6e867d in g_signal_emit_valist () at
/usr/lib/libgobject-2.0.so.0
--Type <RET> for more, q to quit, c to continue without paging--
#42 0x00007f87aa6e9fb0 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#43 0x00007f87aa95c526 in  () at /usr/lib/libgtk-3.so.0
#44 0x00007f87aa9415bc in gtk_window_propagate_key_event () at
/usr/lib/libgtk-3.so.0
#45 0x00007f87ac785efb in  () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#46 0x00007f87aabf2a9f in  () at /usr/lib/libgtk-3.so.0
#47 0x00007f87aa6f7e55 in g_closure_invoke () at
/usr/lib/libgobject-2.0.so.0
#48 0x00007f87aa6e4ec7 in  () at /usr/lib/libgobject-2.0.so.0
#49 0x00007f87aa6e867d in g_signal_emit_valist () at
/usr/lib/libgobject-2.0.so.0
#50 0x00007f87aa6e9fb0 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#51 0x00007f87aa95c526 in  () at /usr/lib/libgtk-3.so.0
#52 0x00007f87aaaa30fa in  () at /usr/lib/libgtk-3.so.0
#53 0x00007f87aaaa660c in gtk_main_do_event () at /usr/lib/libgtk-3.so.0
#54 0x00007f87aa7b8514 in  () at /usr/lib/libgdk-3.so.0
#55 0x00007f87aa765704 in  () at /usr/lib/libgdk-3.so.0
#56 0x00007f87aa45990f in g_main_context_dispatch () at
/usr/lib/libglib-2.0.so.0
#57 0x00007f87aa45b869 in  () at /usr/lib/libglib-2.0.so.0
#58 0x00007f87aa45c7f2 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#59 0x00007f87aaa9fbbf in gtk_main () at /usr/lib/libgtk-3.so.0
#60 0x00007f87ac773c46 in wxGUIEventLoop::DoRun() () at
/usr/lib/libwx_gtk3u_core-3.0.so.0
#61 0x00007f87ac2c0bae in wxEventLoopBase::Run() () at
/usr/lib/libwx_baseu-3.0.so.0
#62 0x00007f87ac285517 in wxAppConsoleBase::MainLoop() () at
/usr/lib/libwx_baseu-3.0.so.0
#63 0x000055fe63cf99e5 in APP_SINGLE_TOP::OnRun() (this=0x55fe64363160) at
./kicad-source-mirror/common/single_top.cpp:197
#64 0x00007f87ac30d4c8 in wxEntry(int&, wchar_t**) () at
/usr/lib/libwx_baseu-3.0.so.0
#65 0x000055fe63cf4720 in main(int, char**) (argc=1, argv=0x7ffe20ee4f08)
at ./kicad-source-mirror/common/single_top.cpp:271

Application: Eeschema
Version: (5.1.2-183-g01a343f28), debug build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.65.1 OpenSSL/1.1.1c zlib/1.2.11 libidn2/2.2.0 libpsl/0.21.0
(+libidn2/2.2.0) libssh2/1.8.2 nghttp2/1.36.0
Platform: Linux 4.19.56-1-lts 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.69.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.65.1
    Compiler: Clang 8.0.0 with C++ ABI 1002

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=ON
    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: eeschema

Story points: 6.0