pcbnew segvault when opening 3D Model (lp:#1829503)

[Original report](https://bugs.launchpad.net/bugs/1829503) created by **Martin Thomas (mtlaunchpad)**
```
I can not open the 3D Model with Alt F3 and when Open it via the menue I
get a segfault.

Also I get the assert "Assert failure" failed in SetBitmap() thing.


Application: KiCad
Version: (5.1.0-595-gb5c483844), debug build
Libraries:
    wxWidgets 3.0.2
    libcurl/7.52.1 GnuTLS/3.5.8 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.19.36-mt 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.62.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=OFF
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=OFF



Reading symbols from kicad...done.
(gdb) r
Starting program: /usr/local/bin/kicad
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

(kicad:12698): Gtk-WARNING **: Im Modulpfad »adwaita« konnte keine Themen-
Engine gefunden werden,

(kicad:12698): Gtk-WARNING **: Im Modulpfad »adwaita« konnte keine Themen-
Engine gefunden werden,
[New Thread 0x7fffe2e02700 (LWP 12702)]
[New Thread 0x7fffe2601700 (LWP 12703)]

** (kicad:12698): WARNING **: Invalid borders specified for theme pixmap:
        /usr/share/themes/Breeze/gtk-2.0/../assets/line-h.png,
borders don't fit within the image
12:54:17: Debug: Adding duplicate image handler for 'PNG file'
12:54:17: Debug: Adding duplicate image handler for 'JPEG file'
12:54:17: Debug: Adding duplicate image handler for 'TIFF file'
12:54:17: Debug: Adding duplicate image handler for 'GIF file'
12:54:17: Debug: Adding duplicate image handler for 'PNM file'
12:54:17: Debug: Adding duplicate image handler for 'PCX file'
12:54:17: Debug: Adding duplicate image handler for 'IFF file'
12:54:17: Debug: Adding duplicate image handler for 'Windows icon file'
12:54:17: Debug: Adding duplicate image handler for 'Windows cursor file'
12:54:17: Debug: Adding duplicate image handler for 'Windows animated
cursor file'
12:54:17: Debug: Adding duplicate image handler for 'TGA file'
12:54:17: Debug: Adding duplicate image handler for 'XPM file'
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
[Thread 0x7fffe2601700 (LWP 12703) exited]
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
[New Thread 0x7fffe2601700 (LWP 12720)]
[Thread 0x7fffe2601700 (LWP 12720) exited]
[New Thread 0x7fffe2601700 (LWP 12721)]
[New Thread 0x7fffe2601700 (LWP 12722)]
[Thread 0x7fffe2601700 (LWP 12722) exited]
[New Thread 0x7fffe2601700 (LWP 12723)]
[Thread 0x7fffe2601700 (LWP 12721) exited]
[Thread 0x7fffe2601700 (LWP 12723) exited]
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
[New Thread 0x7fffe2601700 (LWP 12724)]
[New Thread 0x7fffd0750700 (LWP 12725)]
[Thread 0x7fffe2601700 (LWP 12724) exited]
[New Thread 0x7fffd0750700 (LWP 12726)]
[Thread 0x7fffd0750700 (LWP 12725) exited]
[New Thread 0x7fffe2601700 (LWP 12727)]
[Thread 0x7fffd0750700 (LWP 12726) exited]
[Thread 0x7fffe2601700 (LWP 12727) exited]
12:54:27: Debug: Loading project '/home/mthomas/daten/git/pcb-
design/custom_PCB/cbb-NTE/cbb-nte.pro' settings.
[New Thread 0x7fffe2601700 (LWP 12728)]
[New Thread 0x7fffd0750700 (LWP 12729)]
[New Thread 0x7fffcff4f700 (LWP 12730)]
[New Thread 0x7fffcf74e700 (LWP 12731)]
[Thread 0x7fffd0750700 (LWP 12729) exited]
[Thread 0x7fffcf74e700 (LWP 12731) exited]
[Thread 0x7fffcff4f700 (LWP 12730) exited]
[Thread 0x7fffe2601700 (LWP 12728) exited]
[New Thread 0x7fffe2601700 (LWP 12732)]
[New Thread 0x7fffcff4f700 (LWP 12733)]
[New Thread 0x7fffcf74e700 (LWP 12734)]
[New Thread 0x7fffd0750700 (LWP 12735)]
[Thread 0x7fffd0750700 (LWP 12735) exited]
[Thread 0x7fffcff4f700 (LWP 12733) exited]
[Thread 0x7fffe2601700 (LWP 12732) exited]
[Thread 0x7fffcf74e700 (LWP 12734) exited]
[New Thread 0x7fffd0750700 (LWP 12736)]
[New Thread 0x7fffcff4f700 (LWP 12737)]
[New Thread 0x7fffcf74e700 (LWP 12738)]
[New Thread 0x7fffe2601700 (LWP 12739)]
[Thread 0x7fffcf74e700 (LWP 12738) exited]
[Thread 0x7fffcff4f700 (LWP 12737) exited]
[Thread 0x7fffd0750700 (LWP 12736) exited]
[Thread 0x7fffe2601700 (LWP 12739) exited]
[New Thread 0x7fffe2601700 (LWP 12740)]
12:54:27: Debug: Disabling glCopyBuffer() on intel GPU

[Thread 0x7fffe2601700 (LWP 12740) exited]
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps
../src/gtk/menu.cpp(724): assert "Assert failure" failed in SetBitmap():
only normal menu items can have bitmaps

Thread 1 "kicad" received signal SIGSEGV, Segmentation fault.
0x00007ffff79837f0 in wxAuiToolBarItemArray::DoEmpty() () from
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_aui-3.0.so.0
(gdb) backtrace
#0  0x00007ffff79837f0 in wxAuiToolBarItemArray::DoEmpty() () from
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_aui-3.0.so.0
#1  0x00007ffff7986968 in wxAuiToolBar::Clear() () from
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_aui-3.0.so.0
#2  0x00007fffdaf73f48 in EDA_3D_VIEWER::ReCreateMainToolbar
(this=0x555559471d30)
    at /home/mthomas/daten/git/kicad/kicad-source-
mirror/3d-viewer/3d_viewer/3d_toolbar.cpp:47
#3  0x00007fffdaf36c6c in EDA_3D_VIEWER::EDA_3D_VIEWER
(this=0x555559471d30, aKiway=0x55555595d280 <Kiway>,
aParent=0x555557310380,
    aTitle=..., style=541335104) at /home/mthomas/daten/git/kicad/kicad-
source-mirror/3d-viewer/3d_viewer/eda_3d_viewer.cpp:196
#4  0x00007fffdafbebf5 in PCB_BASE_FRAME::CreateAndShow3D_Frame
(this=0x555557310380, aForceRecreateIfNotOwner=true)
    at /home/mthomas/daten/git/kicad/kicad-source-
mirror/pcbnew/pcb_base_frame.cpp:460
#5  0x00007fffdab33a89 in PCB_EDIT_FRAME::Show3D_Frame
(this=0x555557310380, event=...)
    at /home/mthomas/daten/git/kicad/kicad-source-
mirror/pcbnew/pcb_edit_frame.cpp:660
#6  0x00007ffff634440e in wxAppConsoleBase::CallEventHandler(wxEvtHandler*,
wxEventFunctor&, wxEvent&) const ()
   from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#7  0x00007ffff64c9ea5 in
wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&,
wxEvtHandler*, wxEvent&) ()
   from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#8  0x00007ffff64c9f9b in wxEventHashTable::HandleEvent(wxEvent&,
wxEvtHandler*) ()
   from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#9  0x00007ffff64ca34b in wxEvtHandler::TryHereOnly(wxEvent&) () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#10 0x00007fffdb20899b in EDA_BASE_FRAME::ProcessEvent
(this=0x555557310380, aEvent=...)
    at /home/mthomas/daten/git/kicad/kicad-source-
mirror/common/eda_base_frame.cpp:172
#11 0x00007ffff64ca153 in wxEvtHandler::DoTryChain(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 0x00007ffff6e562f8 in wxWindowBase::TryAfter(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 0x00007ffff6dfb2df in wxMenuBase::SendEvent(int, int) () from
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#16 0x00007ffff6cdec1b in ?? () from /usr/lib/x86_64-linux-
gnu/libwx_gtk2u_core-3.0.so.0
#17 0x00007ffff291df75 in g_closure_invoke () from /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#18 0x00007ffff292ff82 in ?? () from /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#19 0x00007ffff2938bdc in g_signal_emit_valist () from
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#20 0x00007ffff2938fbf in g_signal_emit () from /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#21 0x00007ffff305e62e in gtk_widget_activate () from
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
#22 0x00007ffff2f594dd in gtk_menu_shell_activate_item () from
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
#23 0x00007ffff2f59846 in ?? () from /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#24 0x00007ffff2f477bc in ?? () from /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#25 0x00007ffff291df75 in g_closure_invoke () from /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#26 0x00007ffff293037d in ?? () from /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#27 0x00007ffff293867f in g_signal_emit_valist () from
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#28 0x00007ffff2938fbf in g_signal_emit () from /usr/lib/x86_64-linux-
gnu/libgobject-2.0.so.0
#29 0x00007ffff305f8ac in ?? () from /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#30 0x00007ffff2f45f84 in gtk_propagate_event () from
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
#31 0x00007ffff2f4633b in gtk_main_do_event () from /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#32 0x00007ffff2bbbcbc in ?? () from /usr/lib/x86_64-linux-
gnu/libgdk-x11-2.0.so.0
#33 0x00007ffff1e947f7 in g_main_context_dispatch () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#34 0x00007ffff1e94a60 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#35 0x00007ffff1e94d82 in g_main_loop_run () from /lib/x86_64-linux-
gnu/libglib-2.0.so.0
#36 0x00007ffff2f453b7 in gtk_main () from /usr/lib/x86_64-linux-
gnu/libgtk-x11-2.0.so.0
#37 0x00007ffff6c41e65 in wxGUIEventLoop::DoRun() () from
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#38 0x00007ffff638627b in wxEventLoopBase::Run() () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#39 0x00007ffff634b776 in wxAppConsoleBase::MainLoop() () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#40 0x0000555555604672 in APP_KICAD::OnRun (this=0x5555559eb040)
---Type <return> to continue, or q <return> to quit---
    at /home/mthomas/daten/git/kicad/kicad-source-
mirror/kicad/kicad.cpp:267
#41 0x00007ffff63d7cd0 in wxEntry(int&, wchar_t**) () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#42 0x00005555556031bb in main (argc=1, argv=0x7fffffffdfa8) at
/home/mthomas/daten/git/kicad/kicad-source-mirror/kicad/kicad.cpp:298
(gdb)
```
Original tags: 3d-viewer pcbnew

Story points: 14.0