bitmap2component: crash (lp:#1782807)

[Original report](https://bugs.launchpad.net/bugs/1782807) created by **antoha-mi (antoha-mi)**
```
At startup, bitmap2component crash with a message:

./src/gtk/dc.cpp(276): assert "cr" failed in wxPaintDCImpl(): using
wxPaintDC without being in a native paint event

backtrace^
ASSERT INFO:
./src/gtk/dc.cpp(276): assert "cr" failed in wxPaintDCImpl(): using
wxPaintDC without being in a native paint event

BACKTRACE from the program itself:
[1] wxNativeDCFactory::CreatePaintDC(wxPaintDC*, wxWindow*)
[2] wxPaintDC::wxPaintDC(wxWindow*)
[3] BM2CMP_FRAME::OnPaint(wxPaintEvent&)
/usr/src/debug/kicad-5.0.0/bitmap2component/bitmap2cmp_gui.cpp:245
[4] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&,
wxEvtHandler*, wxEvent&)
[5] wxEvtHandler::SearchDynamicEventTable(wxEvent&)
[6] wxEvtHandler::TryHereOnly(wxEvent&)
[7] wxEvtHandler::ProcessEventLocally(wxEvent&)
[8] wxEvtHandler::ProcessEvent(wxEvent&)
[9] wxScrollHelperEvtHandler::ProcessEvent(wxEvent&)
[10] wxEvtHandler::SafelyProcessEvent(wxEvent&)
[11] wxWindow::GTKSendPaintEvents(_cairo*)
[12] g_closure_invoke
[13] g_signal_emit_valist
[14] g_signal_emit
[15] gtk_container_propagate_draw
[16] gtk_container_propagate_draw
[17] gtk_container_propagate_draw
[18] g_closure_invoke
[19] g_signal_emit_valist
[20] g_signal_emit
[21] gtk_container_propagate_draw
[22] gtk_container_propagate_draw
[23] gtk_main_do_event
[24] g_closure_invoke
[25] g_signal_emit_valist
[26] g_signal_emit
[27] g_main_context_dispatch
[28] g_main_loop_run
[29] gtk_main
[30] wxGUIEventLoop::DoRun()
[31] wxEventLoopBase::Run()
[32] wxAppConsoleBase::MainLoop()
[33] APP_SINGLE_TOP::OnRun()
/usr/src/debug/kicad-5.0.0/common/single_top.cpp:187
[34] wxEntry(int&, wchar_t**)
[35] main /usr/src/debug/kicad-5.0.0/common/single_top.cpp:239
[36] __libc_start_main
[37] _start
/usr/src/debug/glibc-2.27-alt6/csu/../sysdeps/x86_64/start.S:122


gdb backtrace:
#0  raise (sig=sig@entry=5) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff66332ea in wxTrap () at src/common/appbase.cpp:1051
#2  0x00007ffff6f0eb65 in wxGUIAppTraits::ShowAssertDialog (this=<optimized
out>, msg=...) at src/gtk/utilsgtk.cpp:334
#3  0x00007ffff6636f71 in ShowAssertDialog (file=..., line=line@entry=0,
func=..., cond=..., msgUser=..., traits=0x836680, traits@entry=0xde1b50) at
src/common/appbase.cpp:1303
#4  0x00007ffff66399d8 in wxAppConsoleBase::OnAssertFailure
(this=this@entry=0x7b8410, file=<optimized out>, line=0, func=<optimized
out>, cond=<optimized out>, msg=<optimized out>)
    at src/common/appbase.cpp:782
#5  0x00007ffff6edb9c0 in wxApp::OnAssertFailure (this=0x7b8410,
file=<optimized out>, line=<optimized out>, func=<optimized out>,
cond=<optimized out>, msg=<optimized out>)
    at src/gtk/app.cpp:540
#6  0x00007ffff6639ce5 in wxDefaultAssertHandler (file=...,
line=line@entry=276, func=..., cond=..., msg=...) at
src/common/appbase.cpp:1093
#7  0x00007ffff6634c71 in wxOnAssert (file=file@entry=0x7ffff7144e58
"./src/gtk/dc.cpp", line=line@entry=276,
    func=func@entry=0x7ffff7144ee0
<wxPaintDCImpl::wxPaintDCImpl(wxPaintDC*, wxWindow*)::__FUNCTION__>
"wxPaintDCImpl", cond=cond@entry=0x7ffff7144e9f "cr",
    msg=msg@entry=0x7ffff7144ea8 "using wxPaintDC without being in a native
paint event") at src/common/appbase.cpp:1170
#8  0x00007ffff6eefa8b in wxPaintDCImpl::wxPaintDCImpl (this=0xd26e80,
owner=<optimized out>, window=0x821cd0) at src/gtk/dc.cpp:276
#9  0x00007ffff6fc2755 in wxNativeDCFactory::CreatePaintDC (this=<optimized
out>, owner=0x7fffffffc520, window=0x821cd0) at src/common/dcbase.cpp:149
#10 0x00007ffff6fc4620 in wxPaintDC::wxPaintDC (this=0x7fffffffc520,
win=0x821cd0) at src/common/dcbase.cpp:275
#11 0x0000000000441065 in BM2CMP_FRAME::OnPaint (this=0x860660, event=...)
at /usr/src/debug/kicad-5.0.0/bitmap2component/bitmap2cmp_gui.cpp:244
#12 0x00007ffff679f29a in wxEvtHandler::ProcessEventIfMatchesId (entry=...,
handler=<optimized out>, event=...) at src/common/event.cpp:1390
#13 0x00007ffff679f598 in wxEvtHandler::SearchDynamicEventTable
(this=0xc92400, event=...) at src/common/event.cpp:1749
#14 0x00007ffff67a017f in wxEvtHandler::TryHereOnly (this=0xc92400,
event=...) at src/common/event.cpp:1583
#15 0x00007ffff67a0233 in TryBeforeAndHere (event=..., this=0xc92400) at
include/wx/event.h:3671
#16 wxEvtHandler::ProcessEventLocally (this=0xc92400, event=...) at
src/common/event.cpp:1520
#17 0x00007ffff67a0295 in wxEvtHandler::ProcessEvent (this=0xc92400,
event=...) at src/common/event.cpp:1493
#18 0x00007ffff711ecdd in wxScrollHelperEvtHandler::ProcessEvent
(this=0xca22c0, event=...) at src/generic/scrlwing.cpp:252
#19 0x00007ffff679f4b7 in wxEvtHandler::SafelyProcessEvent (this=<optimized
out>, event=...) at src/common/event.cpp:1611
#20 0x00007ffff70c172c in wxWindowBase::HandleWindowEvent
(this=this@entry=0xc92400, event=...) at src/common/wincmn.cpp:1525
#21 0x00007ffff6f1e17c in wxWindow::GTKSendPaintEvents
(this=this@entry=0xc92400, cr=cr@entry=0xb595c0) at src/gtk/window.cpp:4241
#22 0x00007ffff6f1e6fe in draw (cr=0xb595c0, win=0xc92400) at
src/gtk/window.cpp:256
#23 0x00007ffff48ac0cb in _gtk_marshal_BOOLEAN__BOXED
(closure=closure@entry=0xcc01c0,
return_value=return_value@entry=0x7fffffffc9a0,
n_param_values=n_param_values@entry=2,
    param_values=param_values@entry=0x7fffffffca50,
invocation_hint=invocation_hint@entry=0x7fffffffc9f0,
marshal_data=marshal_data@entry=0x0) at gtkmarshalers.c:83
#24 0x00007ffff49e7b8f in gtk_widget_draw_marshaller (closure=0xcc01c0,
return_value=0x7fffffffc9a0, n_param_values=2, param_values=0x7fffffffca50,
invocation_hint=0x7fffffffc9f0,
    marshal_data=0x0) at gtkwidget.c:945
#25 0x00007ffff415184d in g_closure_invoke (closure=0xcc01c0,
return_value=0x7fffffffc9a0, n_param_values=2, param_values=0x7fffffffca50,
invocation_hint=0x7fffffffc9f0) at gclosure.c:804
#26 0x00007ffff4163eae in signal_emit_unlocked_R (node=<optimized out>,
detail=detail@entry=0, instance=instance@entry=0xb93400,
emission_return=emission_return@entry=0x7fffffffcb40,
    instance_and_params=instance_and_params@entry=0x7fffffffca50) at
gsignal.c:3635
#27 0x00007ffff416be4c in g_signal_emit_valist (instance=<optimized out>,
signal_id=<optimized out>, detail=<optimized out>,
var_args=var_args@entry=0x7fffffffcc08) at gsignal.c:3401
#28 0x00007ffff416ce62 in g_signal_emit (instance=instance@entry=0xb93400,
signal_id=<optimized out>, detail=detail@entry=0) at gsignal.c:3447
#29 0x00007ffff49f4142 in gtk_widget_draw_internal
(widget=widget@entry=0xb93400, cr=cr@entry=0xb595c0,
clip_to_size=clip_to_size@entry=1) at gtkwidget.c:7025
#30 0x00007ffff47ea4f2 in gtk_container_propagate_draw
(container=container@entry=0xcac300, child=0xb93400, cr=cr@entry=0xb595c0)
at gtkcontainer.c:3841
#31 0x00007ffff47ea5b2 in gtk_container_draw (widget=0xcac300, cr=0xb595c0)
at gtkcontainer.c:3661
#32 0x00007ffff492fadb in gtk_scrolled_window_render (gadget=<optimized
out>, cr=0xb595c0, x=<optimized out>, y=<optimized out>, width=<optimized
out>, height=<optimized out>, data=0x0)
    at gtkscrolledwindow.c:2080
#33 0x00007ffff47ef43d in gtk_css_custom_gadget_draw (gadget=<optimized
out>, cr=<optimized out>, x=<optimized out>, y=<optimized out>,
width=<optimized out>, height=<optimized out>)
    at gtkcsscustomgadget.c:159
#34 0x00007ffff47f3f73 in gtk_css_gadget_draw (gadget=0xc9ec80,
cr=0xb595c0) at gtkcssgadget.c:877
#35 0x00007ffff492de61 in gtk_scrolled_window_draw (widget=<optimized out>,
cr=<optimized out>) at gtkscrolledwindow.c:3007
#36 0x00007ffff49f3eff in gtk_widget_draw_internal
(widget=widget@entry=0xcac300, cr=cr@entry=0xb595c0,
clip_to_size=clip_to_size@entry=1) at gtkwidget.c:7032
#37 0x00007ffff47ea4f2 in gtk_container_propagate_draw
(container=container@entry=0xca4220, child=0xcac300, cr=cr@entry=0xb595c0)
at gtkcontainer.c:3841
#38 0x00007ffff48d5432 in gtk_notebook_draw_stack (gadget=<optimized out>,
cr=0xb595c0, x=<optimized out>, y=<optimized out>, width=<optimized out>,
height=<optimized out>, unused=0x0)
---Type <return> to continue, or q <return> to quit---
    at gtknotebook.c:2515
#39 0x00007ffff47ef43d in gtk_css_custom_gadget_draw (gadget=<optimized
out>, cr=<optimized out>, x=<optimized out>, y=<optimized out>,
width=<optimized out>, height=<optimized out>)
    at gtkcsscustomgadget.c:159
#40 0x00007ffff47f3f73 in gtk_css_gadget_draw
(gadget=gadget@entry=0xb30680, cr=cr@entry=0xb595c0) at gtkcssgadget.c:877
#41 0x00007ffff47a41ac in gtk_box_gadget_draw (gadget=<optimized out>,
cr=0xb595c0, x=<optimized out>, y=<optimized out>, width=<optimized out>,
height=<optimized out>)
    at gtkboxgadget.c:512
#42 0x00007ffff47f3f73 in gtk_css_gadget_draw (gadget=0xc92160,
cr=cr@entry=0xb595c0) at gtkcssgadget.c:877
#43 0x00007ffff48d7aac in gtk_notebook_draw (widget=<optimized out>,
cr=0xb595c0) at gtknotebook.c:2530
#44 0x00007ffff49f3eff in gtk_widget_draw_internal
(widget=widget@entry=0xca4220, cr=cr@entry=0xb595c0,
clip_to_size=clip_to_size@entry=1) at gtkwidget.c:7032
#45 0x00007ffff47ea4f2 in gtk_container_propagate_draw
(container=container@entry=0xb93120, child=0xca4220, cr=cr@entry=0xb595c0)
at gtkcontainer.c:3841
#46 0x00007ffff4854141 in gtk_fixed_draw (widget=widget@entry=0xb93120,
cr=0xb595c0) at gtkfixed.c:597
#47 0x00007ffff48ac0cb in _gtk_marshal_BOOLEAN__BOXED
(closure=closure@entry=0x804bf0,
return_value=return_value@entry=0x7fffffffd460,
n_param_values=n_param_values@entry=2,
    param_values=param_values@entry=0x7fffffffd510,
invocation_hint=invocation_hint@entry=0x7fffffffd4b0,
marshal_data=marshal_data@entry=0x7ffff4854110 <gtk_fixed_draw>)
    at gtkmarshalers.c:83
#48 0x00007ffff49e7b8f in gtk_widget_draw_marshaller (closure=0x804bf0,
return_value=0x7fffffffd460, n_param_values=2, param_values=0x7fffffffd510,
invocation_hint=0x7fffffffd4b0,
    marshal_data=0x7ffff4854110 <gtk_fixed_draw>) at gtkwidget.c:945
#49 0x00007ffff415184d in g_closure_invoke (closure=0x804bf0,
return_value=0x7fffffffd460, n_param_values=2, param_values=0x7fffffffd510,
invocation_hint=0x7fffffffd4b0) at gclosure.c:804
#50 0x00007ffff4163c38 in signal_emit_unlocked_R (node=<optimized out>,
detail=detail@entry=0, instance=instance@entry=0xb93120,
emission_return=emission_return@entry=0x7fffffffd600,
    instance_and_params=instance_and_params@entry=0x7fffffffd510) at
gsignal.c:3673
#51 0x00007ffff416be4c in g_signal_emit_valist (instance=<optimized out>,
signal_id=<optimized out>, detail=<optimized out>,
var_args=var_args@entry=0x7fffffffd6c8) at gsignal.c:3401
#52 0x00007ffff416ce62 in g_signal_emit (instance=instance@entry=0xb93120,
signal_id=<optimized out>, detail=detail@entry=0) at gsignal.c:3447
#53 0x00007ffff49f4142 in gtk_widget_draw_internal
(widget=widget@entry=0xb93120, cr=cr@entry=0xb595c0,
clip_to_size=clip_to_size@entry=1) at gtkwidget.c:7025
#54 0x00007ffff47ea4f2 in gtk_container_propagate_draw
(container=container@entry=0xb16150, child=0xb93120, cr=cr@entry=0xb595c0)
at gtkcontainer.c:3841
#55 0x00007ffff47ea5b2 in gtk_container_draw (widget=0xb16150,
cr=cr@entry=0xb595c0) at gtkcontainer.c:3661
#56 0x00007ffff47a0154 in gtk_box_draw_contents (gadget=<optimized out>,
cr=0xb595c0, x=<optimized out>, y=<optimized out>, width=<optimized out>,
height=<optimized out>, unused=0x0)
    at gtkbox.c:448
#57 0x00007ffff47ef43d in gtk_css_custom_gadget_draw (gadget=<optimized
out>, cr=<optimized out>, x=<optimized out>, y=<optimized out>,
width=<optimized out>, height=<optimized out>)
    at gtkcsscustomgadget.c:159
#58 0x00007ffff47f3f73 in gtk_css_gadget_draw (gadget=0xb0fea0,
cr=0xb595c0) at gtkcssgadget.c:877
#59 0x00007ffff47a29e1 in gtk_box_draw (widget=<optimized out>,
cr=<optimized out>) at gtkbox.c:457
#60 0x00007ffff49f3eff in gtk_widget_draw_internal
(widget=widget@entry=0xb16150, cr=cr@entry=0xb595c0,
clip_to_size=clip_to_size@entry=1) at gtkwidget.c:7032
#61 0x00007ffff47ea4f2 in gtk_container_propagate_draw
(container=container@entry=0x8622a0, child=0xb16150, cr=cr@entry=0xb595c0)
at gtkcontainer.c:3841
#62 0x00007ffff47ea5b2 in gtk_container_draw (widget=0x8622a0, cr=0xb595c0)
at gtkcontainer.c:3661
#63 0x00007ffff4a013ef in gtk_window_draw (widget=0x8622a0, cr=0xb595c0) at
gtkwindow.c:10396
#64 0x00007ffff49f3eff in gtk_widget_draw_internal (widget=0x8622a0,
cr=0xb595c0, clip_to_size=<optimized out>) at gtkwidget.c:7032
#65 0x00007ffff49fcdf3 in gtk_widget_render (widget=widget@entry=0x8622a0,
window=0x7e1c80, region=<optimized out>) at gtkwidget.c:17542
#66 0x00007ffff48ab0c9 in gtk_main_do_event (event=<optimized out>) at
gtkmain.c:1838
#67 0x00007ffff43ccb45 in _gdk_event_emit
(event=event@entry=0x7fffffffdc60) at gdkevents.c:73
#68 0x00007ffff43dc795 in _gdk_window_process_updates_recurse_helper
(window=0x7e1c80, expose_region=<optimized out>) at gdkwindow.c:3852
#69 0x00007ffff43dd986 in gdk_window_process_updates_internal
(window=0x7e1c80) at gdkwindow.c:3998
#70 0x00007ffff43ddb80 in gdk_window_process_updates_with_mode
(window=<optimized out>, recurse_mode=<optimized out>) at gdkwindow.c:4192
#71 0x00007ffff415184d in g_closure_invoke (closure=0x869b60,
return_value=0x0, n_param_values=1, param_values=0x7fffffffdf40,
invocation_hint=0x7fffffffdee0) at gclosure.c:804
#72 0x00007ffff4163eae in signal_emit_unlocked_R (node=node@entry=0x7f1280,
detail=detail@entry=0, instance=instance@entry=0x7fd470,
emission_return=emission_return@entry=0x0,
    instance_and_params=instance_and_params@entry=0x7fffffffdf40) at
gsignal.c:3635
#73 0x00007ffff416c495 in g_signal_emit_valist (instance=<optimized out>,
signal_id=<optimized out>, detail=<optimized out>,
var_args=var_args@entry=0x7fffffffe0e8) at gsignal.c:3391
#74 0x00007ffff416ce62 in g_signal_emit (instance=instance@entry=0x7fd470,
signal_id=<optimized out>, detail=detail@entry=0) at gsignal.c:3447
#75 0x00007ffff43d54bf in _gdk_frame_clock_emit_paint
(frame_clock=frame_clock@entry=0x7fd470) at gdkframeclock.c:640
#76 0x00007ffff43d5c11 in gdk_frame_clock_paint_idle (data=0x7fd470) at
gdkframeclockidle.c:459


kicad-5.0.0
wxGTK-3.0.4 with gtk3
wxpython-3.0.2

build log: http://git.altlinux.org/tasks/210485/build/1100/x86_64/log
```

Story points: 6.0