eeschema: Crash on opening schematic (lp:#1822678)

[Original report](https://bugs.launchpad.net/bugs/1822678) created by **Michael Geselbracht (mgeselbracht)**
```
As of commit 2466b4363 (bisected) eeschema crashes while opening a "more
complex" schematic.
The pic_programmer demo can be opened without any issues. But "bigger"
projects lead to an immediate crash. Reverting the commit resolves this
issue.

With one project there is a "kicad Error" dialog with the message
"Unhandled exception class: St9bad_alloc  what: std::bad_alloc"

Steps to reproduce:
1. Open demo project "complex_hierarchy" with kicad launcher.
2. Click on "Schematic Layout Editor" tool button -> crash


Backtrace:
#0  0x00007fffd5861eae in SCH_CONNECTION::Type() const (this=0x0) at
/data/src/kicad-source-mirror/eeschema/./sch_connection.h:172
#1  0x00007fffd59230e0 in SCH_CONNECTION::Clone(SCH_CONNECTION&)
(this=0x555558104270, aOther=...) at /data/src/kicad-source-
mirror/eeschema/sch_connection.cpp:207
#2  0x00007fffd585b8d0 in CONNECTION_GRAPH::buildConnectionGraph()
(this=0x555556d5c740) at /data/src/kicad-source-
mirror/eeschema/connection_graph.cpp:1008
#3  0x00007fffd5858950 in CONNECTION_GRAPH::Recalculate(SCH_SHEET_LIST,
bool) (this=0x555556d5c740, aSheetList=..., aUnconditional=true)
    at /data/src/kicad-source-mirror/eeschema/connection_graph.cpp:305
#4  0x00007fffd59b9b5d in SCH_EDIT_FRAME::RecalculateConnections()
(this=0x555556d1ab10) at /data/src/kicad-source-
mirror/eeschema/sch_edit_frame.cpp:1530
#5  0x00007fffd5896381 in
SCH_EDIT_FRAME::OpenProjectFiles(std::vector<wxString,
std::allocator<wxString> > const&, int) (this=0x555556d1ab10,
aFileSet=std::vector of length 1, capacity 1 = {...}, aCtl=0) at
/data/src/kicad-source-mirror/eeschema/files-io.cpp:378
#6  0x00005555556082cc in KICAD_MANAGER_FRAME::RunEeschema(wxString const&)
(this=0x555555a6d130, aProjectSchematicFileName=...) at /data/src/kicad-
source-mirror/kicad/mainframe.cpp:311
#7  0x00005555556086ba in
KICAD_MANAGER_FRAME::OnRunEeschema(wxCommandEvent&) (this=0x555555a6d130,
event=...) at /data/src/kicad-source-mirror/kicad/mainframe.cpp:335
#8  0x00007ffff67754be in
wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&,
wxEvtHandler*, wxEvent&) () at /usr/lib/x86_64-linux-
gnu/libwx_baseu-3.0.so.0
#9  0x00007ffff67755c3 in wxEventHashTable::HandleEvent(wxEvent&,
wxEvtHandler*) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#10 0x00007ffff677598b in wxEvtHandler::TryHereOnly(wxEvent&) () at
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#11 0x000055555564829e in EDA_BASE_FRAME::ProcessEvent(wxEvent&)
(this=0x555555a6d130, aEvent=...) at /data/src/kicad-source-
mirror/common/eda_base_frame.cpp:173
#12 0x00007ffff6775783 in wxEvtHandler::DoTryChain(wxEvent&) () at
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#13 0x00007ffff6775a75 in wxEvtHandler::ProcessEvent(wxEvent&) () at
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#14 0x00007ffff70a518b in wxWindowBase::TryAfter(wxEvent&) () at
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#15 0x00007ffff70a518b in wxWindowBase::TryAfter(wxEvent&) () at
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#16 0x00007ffff67757d7 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () at
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#17 0x00007ffff6f234b7 in  () at /usr/lib/x86_64-linux-
gnu/libwx_gtk2u_core-3.0.so.0
#18 0x00007ffff488910d in g_closure_invoke () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#19 0x00007ffff489bbf1 in  () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#20 0x00007ffff48a4715 in g_signal_emit_valist () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#21 0x00007ffff48a512f in g_signal_emit () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#22 0x00007ffff4e0f6f5 in  () at /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#23 0x00007ffff488910d in g_closure_invoke () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#24 0x00007ffff489c12e in  () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#25 0x00007ffff48a4715 in g_signal_emit_valist () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#26 0x00007ffff48a512f in g_signal_emit () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#27 0x00007ffff4e0e679 in  () at /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#28 0x00007ffff4eb438b in  () at /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#29 0x00007ffff488910d in g_closure_invoke () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#30 0x00007ffff489bde8 in  () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#31 0x00007ffff48a40af in g_signal_emit_valist () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#32 0x00007ffff48a512f in g_signal_emit () at /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#33 0x00007ffff4fca2bc in  () at /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#34 0x00007ffff4eb262c in gtk_propagate_event () at /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#35 0x00007ffff4eb2a2b in gtk_main_do_event () at /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#36 0x00007ffff4b2802c in  () at /usr/lib/x86_64-linux-
gnu/libgdk-x11-2.0.so.0
#37 0x00007ffff413e387 in g_main_context_dispatch () at
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#38 0x00007ffff413e5c0 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#39 0x00007ffff413e8d2 in g_main_loop_run () at /usr/lib/x86_64-linux-
gnu/libglib-2.0.so.0
#40 0x00007ffff4eb1a37 in gtk_main () at /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#41 0x00007ffff6ec2b05 in wxGUIEventLoop::DoRun() () at
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#42 0x00007ffff6631a93 in wxEventLoopBase::Run() () at
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#43 0x00007ffff65f90a6 in wxAppConsoleBase::MainLoop() () at
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#44 0x0000555555605c51 in APP_KICAD::OnRun() (this=0x5555559efb50) at
/data/src/kicad-source-mirror/kicad/kicad.cpp:267
#45 0x00007ffff6683ae9 in wxEntry(int&, wchar_t**) () at
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#46 0x0000555555604597 in main(int, char**) (argc=1, argv=0x7fffffffdbd8)
at /data/src/kicad-source-mirror/kicad/kicad.cpp:298


Version info:

Application: kicad
Version: (5.1.0-94-g2466b4363), debug build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.58.0 OpenSSL/1.1.0g zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1
(+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Platform: Linux 4.15.0-46-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
    Boost: 1.65.1
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.58.0
    Compiler: GCC 7.3.0 with C++ ABI 1011

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=OFF
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=OFF
```
Original tags: eeschema

Story points: 22.0