eeschema crash on exiting "symbol library browser" using ESC key (lp:#1829981)

[Original report](https://bugs.launchpad.net/bugs/1829981) created by **Dino Ghilardi (dino-ghilardi)**
```
To reproduce the behaviour:
-Open eeschema
-Select View->symbol library browser
-press 'ESC' to cancel


then we have a segmentation fault.

Exiting the the symbol library browser closing the window does not have the
issue.

-----------------------------------------------------------------
running in gdb the faults is:

Thread 1 "kicad" received signal SIGSEGV, Segmentation fault.
0x00007fffda451fed in std::operator-<EDA_ITEM*, EDA_ITEM*&, EDA_ITEM**> (
    __x=<error reading variable: Cannot access memory at address 0x108>,
    __y=<error reading variable: Cannot access memory at address 0xe8>)
    at /usr/include/c++/6/bits/stl_deque.h:354
354             * (__x._M_node - __y._M_node - 1) + (__x._M_cur -
__x._M_first)

backtrace gives:

#0  0x00007fffda451fed in std::operator-<EDA_ITEM*, EDA_ITEM*&, EDA_ITEM**>
(
    __x=<error reading variable: Cannot access memory at address 0x108>,
    __y=<error reading variable: Cannot access memory at address 0xe8>)
    at /usr/include/c++/6/bits/stl_deque.h:354
#1  0x00007fffda451bc1 in std::deque<EDA_ITEM*, std::allocator<EDA_ITEM*>
>::size (this=0xd8)
    at /usr/include/c++/6/bits/stl_deque.h:1265
#2  0x00007fffda45191c in SELECTION::Front (this=0x98)
    at /home/dinoghi/SANDBOXKICAD5/src/kicad/include/tool/selection.h:157
#3  0x00007fffda45d7be in EE_CONDITIONS::<lambda(const
SELECTION&)>::operator()(const SELECTION &) const (__closure=0x7fffdaff16c0
<EE_CONDITIONS::Idle>, aSelection=...)
    at
/home/dinoghi/SANDBOXKICAD5/src/kicad/eeschema/tools/ee_selection_tool.cpp:93
#4  0x00007fffda463a64 in std::_Function_handler<bool(const SELECTION&),
EE_CONDITIONS::<lambda(const SELECTION&)> >::_M_invoke(const std::_Any_data
&, const SELECTION &) (__functor=...,
    __args#0=...) at /usr/include/c++/6/functional:1717
#5  0x00007fffda262367 in std::function<bool (SELECTION
const&)>::operator()(SELECTION const&) const (this=0x7fffdaff16c0
<EE_CONDITIONS::Idle>, __args#0=...)
    at /usr/include/c++/6/functional:2127
#6  0x00007fffda34c918 in SCH_DRAW_PANEL::OnKeyEvent (this=0x555559d1e000,
event=...)
    at
/home/dinoghi/SANDBOXKICAD5/src/kicad/eeschema/sch_draw_panel.cpp:290
#7  0x00007ffff634440e in wxAppConsoleBase::CallEventHandler(wxEvtHandler*,
wxEventFunctor&, wxEvent&) const () from /usr/lib/x86_64-linux-
gnu/libwx_baseu-3.0.so.0
#8  0x00007ffff64c9ea5 in
wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&,
wxEvtHandler*, wxEvent&) () from /usr/lib/x86_64-linux-
gnu/libwx_baseu-3.0.so.0
#9  0x00007ffff64ca29d in wxEvtHandler::SearchDynamicEventTable(wxEvent&)
()
   from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#10 0x00007ffff64ca31f in wxEvtHandler::TryHereOnly(wxEvent&) ()
   from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#11 0x00007ffff64ca3d3 in wxEvtHandler::ProcessEventLocally(wxEvent&) ()
   from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#12 0x00007ffff64ca435 in wxEvtHandler::ProcessEvent(wxEvent&) ()
   from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#13 0x00007ffff6ec405b in wxScrollHelperEvtHandler::ProcessEvent(wxEvent&)
()
   from /usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#14 0x00007ffff64ca1a7 in wxEvtHandler::SafelyProcessEvent(wxEvent&) ()
   from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#15 0x00007ffff6c7544d in ?? () from /usr/lib/x86_64-linux-
gnu/libwx_gtk2u_core-3.0.so.0

-------------------------------------------------------------------
Version info:
Application: Eeschema
Version: (5.1.0-648-g06b22594c), debug build
Libraries:
    wxWidgets 3.0.2
    libcurl/7.52.1 OpenSSL/1.0.2r zlib/1.2.8 libidn2/0.16 libpsl/0.17.0
(+libidn2/0.16) libssh2/1.7.0 nghttp2/1.18.1 librtmp/2.3
Platform: Linux 4.9.0-8-amd64 x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.2 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
    Boost: 1.69.0
    OpenCASCADE Community Edition: 6.8.0
    Curl: 7.52.1
    Compiler: GCC 6.3.0 with C++ ABI 1010

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=OFF
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON
------------------------------------------------------

Tested on commit 06b22594ca7fb460692db2187b86bd8075bd315b

cheers,
Dino.
```
Original tags: eeschema

Story points: 6.0