eeschema crash when pressing V to edit value (lp:#1842652)

[Original report](https://bugs.launchpad.net/bugs/1842652) created by **Jonatan Liljedahl (kymatica)**
```
To reproduce:

- launch the app
- open the schematic
- hover over a resistor and press V
- eeschema crashes!

See attached crash log.

Sometimes, if I click on the empty canvas, then press ESC before V, it
works. But I'm not sure if that's just a coincidence.

Sometimes I get this debug prints while trying this:

ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME

Application: KiCad
Version: (5.1.4-60-ga2950354a), debug build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.54.0 LibreSSL/2.6.5 zlib/1.2.11 nghttp2/1.24.1
Platform: Mac OS X (Darwin 18.5.0 x86_64), 64 bit, Little endian, wxMac
Build Info:
    wxWidgets: 3.0.4 (wchar_t,STL containers,compatible with 2.8)
    Boost: 1.69.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.54.0
    Compiler: Clang 9.0.0 with C++ ABI 1002

Build settings:
    USE_WX_GRAPHICS_CONTEXT=ON
    USE_WX_OVERLAY=ON
    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

stack trace:

(lldb) run
Process 40940 launched:
'/Applications/KiCad/kicad.app/Contents/MacOS/kicad' (x86_64)
LoadAllLibraries: lib_names:
 Tests2-cache
13:20:02: Debug: Disabling glCopyBuffer() on intel GPU

ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
./src/osx/window_osx.cpp(1640): assert "cgContext" failed in
MacPaintBorders().
Collecting stack trace information, please wait...Process 40940 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason =
EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x00007fff47749767 AppKit`-[NSApplication _crashOnException:]
+ 109
AppKit`-[NSApplication _crashOnException:]:
->  0x7fff47749767 <+109>: ud2
    0x7fff47749769 <+111>: movq   %rax, %rdi
    0x7fff4774976c <+114>: callq  0x7fff47ea547a            ; symbol stub
for: objc_begin_catch
    0x7fff47749771 <+119>: xorl   %edi, %edi
Target 0: (kicad) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason =
EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x00007fff47749767 AppKit`-[NSApplication _crashOnException:]
+ 109
    frame #1: 0x00007fff474462d8
AppKit`__65+[CATransaction(NSCATransaction)
NS_setFlushesWithDisplayRefresh]_block_invoke + 841
    frame #2: 0x00007fff49d29c94
CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
+ 23
    frame #3: 0x00007fff49d29bc9 CoreFoundation`__CFRunLoopDoObservers +
451
    frame #4: 0x00007fff49ccc74e CoreFoundation`__CFRunLoopRun + 1143
    frame #5: 0x00007fff49ccc085 CoreFoundation`CFRunLoopRunSpecific + 459
    frame #6: 0x00007fff48faa9db HIToolbox`RunCurrentEventLoopInMode + 292
    frame #7: 0x00007fff48faa61d HIToolbox`ReceiveNextEventCommon + 355
    frame #8: 0x00007fff48faa4a6
HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 64
    frame #9: 0x00007fff47344ffb AppKit`_DPSNextEvent + 965
    frame #10: 0x00007fff47343d93 AppKit`-[NSApplication(NSEvent)
_nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
    frame #11: 0x00000001005da65c
libwx_osx_cocoau-3.0.0.dylib`wxGUIEventLoop::OSXDoRun() + 220
    frame #12: 0x00000001004d5111
libwx_osx_cocoau-3.0.0.dylib`wxCFEventLoop::DoRun() + 49
    frame #13: 0x0000000100422b72
libwx_osx_cocoau-3.0.0.dylib`wxEventLoopBase::Run() + 162
    frame #14: 0x000000010c10c591
_eeschema.kiface`DIALOG_SHIM::ShowQuasiModal() + 673
    frame #15: 0x000000010bd44aaf
_eeschema.kiface`SCH_EDIT_FRAME::EditComponentFieldText(SCH_FIELD*) + 735
    frame #16: 0x000000010bf06846
_eeschema.kiface`SCH_EDIT_FRAME::OnEditItem(wxCommandEvent&) + 982
    frame #17: 0x000000010050161f
libwx_osx_cocoau-3.0.0.dylib`wxEventHashTable::HandleEvent(wxEvent&,
wxEvtHandler*) + 239
    frame #18: 0x0000000100502941
libwx_osx_cocoau-3.0.0.dylib`wxEvtHandler::ProcessEvent(wxEvent&) + 209
    frame #19: 0x000000010c131678
_eeschema.kiface`EDA_BASE_FRAME::ProcessEvent(wxEvent&) + 152
    frame #20: 0x0000000100502aa1
libwx_osx_cocoau-3.0.0.dylib`wxEvtHandler::ProcessEventLocally(wxEvent&) +
161
    frame #21: 0x00000001005028d4
libwx_osx_cocoau-3.0.0.dylib`wxEvtHandler::ProcessEvent(wxEvent&) + 100
    frame #22: 0x000000010bd89e26
_eeschema.kiface`SCH_EDIT_FRAME::OnHotKey(wxDC*, int, wxPoint const&,
EDA_ITEM*) + 3974
    frame #23: 0x000000010bd3f882
_eeschema.kiface`SCH_EDIT_FRAME::GeneralControl(wxDC*, wxPoint const&,
unsigned int) + 738
    frame #24: 0x000000010bdef40d
_eeschema.kiface`SCH_DRAW_PANEL::OnKeyEvent(wxKeyEvent&) + 861
    frame #25: 0x0000000100502cb2
libwx_osx_cocoau-3.0.0.dylib`wxEvtHandler::SearchDynamicEventTable(wxEvent&)
+ 178
    frame #26: 0x0000000100502a3b
libwx_osx_cocoau-3.0.0.dylib`wxEvtHandler::ProcessEventLocally(wxEvent&) +
59
    frame #27: 0x00000001005028d4
libwx_osx_cocoau-3.0.0.dylib`wxEvtHandler::ProcessEvent(wxEvent&) + 100
    frame #28: 0x0000000100738833
libwx_osx_cocoau-3.0.0.dylib`wxScrollHelperEvtHandler::ProcessEvent(wxEvent&)
+ 35
    frame #29: 0x0000000100502d5c
libwx_osx_cocoau-3.0.0.dylib`wxEvtHandler::SafelyProcessEvent(wxEvent&) +
12
    frame #30: 0x000000010053b021
libwx_osx_cocoau-3.0.0.dylib`wxWindow::OSXHandleKeyEvent(wxKeyEvent&) + 273
    frame #31: 0x00000001005fa4d9
libwx_osx_cocoau-3.0.0.dylib`wxWidgetCocoaImpl::DoHandleCharEvent(NSEvent*,
NSString*) + 249
    frame #32: 0x00000001005f6eab
libwx_osx_cocoau-3.0.0.dylib`wxWidgetCocoaImpl::insertText(NSString*,
NSView*, void*) + 315
    frame #33: 0x00007fff47667191
AppKit`-[NSTextInputContext(NSInputContext_WithCompletion)
insertText:replacementRange:completionHandler:] + 169
    frame #34: 0x00007fff47d2ce78 AppKit`__55-[NSTextInputContext
handleTSMEvent:completionHandler:]_block_invoke_2.309 + 102
    frame #35: 0x00007fff476670e2 AppKit`-[NSTextInputContext
do_HandleTSMEvent_insertFixLenTextLoop:whileCondition:dispatchWorkEach:afterEachInsertText:continuation:]
+ 105
    frame #36: 0x00007fff47d2b05b AppKit`-[NSTextInputContext
tryHandleTSMEvent_insertFixLenText_withContext:dispatchCondition:setupForDispatch:nestedWorkaroundCondition:nestedWorkaroundDispatchWork:loopCondition:dispatchWorkEach:afterEachInsertText:continuation:]
+ 308
    frame #37: 0x00007fff47d2c7e7 AppKit`__55-[NSTextInputContext
handleTSMEvent:completionHandler:]_block_invoke.265 + 2976
    frame #38: 0x00007fff47666d4e AppKit`__55-[NSTextInputContext
handleTSMEvent:completionHandler:]_block_invoke_2 + 74
    frame #39: 0x00007fff47666cd6 AppKit`-[NSTextInputContext
tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:]
+ 87
    frame #40: 0x00007fff476664ce AppKit`-[NSTextInputContext
handleTSMEvent:completionHandler:] + 1749
    frame #41: 0x00007fff47665d81 AppKit`_NSTSMEventHandler + 306
    frame #42: 0x00007fff48fa8a6e
HIToolbox`DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*,
HandlerCallRec*) + 1422
    frame #43: 0x00007fff48fa7e1f
HIToolbox`SendEventToEventTargetInternal(OpaqueEventRef*,
OpaqueEventTargetRef*, HandlerCallRec*) + 371
    frame #44: 0x00007fff48fa7ca5
HIToolbox`SendEventToEventTargetWithOptions + 45
    frame #45: 0x00007fff4900f4df
HIToolbox`SendTSMEvent_WithCompletionHandler + 383
    frame #46: 0x00007fff4900f94a
HIToolbox`__SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke
+ 387
    frame #47: 0x00007fff4900f7b8
HIToolbox`__SendFilterTextEvent_WithCompletionHandler_block_invoke + 221
    frame #48: 0x00007fff4900f52e
HIToolbox`SendTSMEvent_WithCompletionHandler + 462
    frame #49: 0x00007fff4900f333
HIToolbox`SendFilterTextEvent_WithCompletionHandler + 225
    frame #50: 0x00007fff4900eff4
HIToolbox`SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler + 280
    frame #51: 0x00007fff4900ed9e
HIToolbox`__utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 + 283
    frame #52: 0x00007fff4900ebfd
HIToolbox`__utDeliverTSMEvent_WithCompletionHandler_block_invoke + 355
    frame #53: 0x00007fff4900ea1b
HIToolbox`TSMKeyEvent_WithCompletionHandler + 598
    frame #54: 0x00007fff4900e7aa
HIToolbox`__TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4
+ 250
    frame #55: 0x00007fff4900e5d9
HIToolbox`__TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3
+ 257
    frame #56: 0x00007fff4900e31e
HIToolbox`__TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2
+ 282
    frame #57: 0x00007fff4900e082
HIToolbox`__TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke
+ 274
    frame #58: 0x00007fff4900d677
HIToolbox`TSMProcessRawKeyEventWithOptionsAndCompletionHandler + 3398
    frame #59: 0x00007fff47d31451 AppKit`__84-[NSTextInputContext
_handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke_3.779
+ 110
    frame #60: 0x00007fff47d30a4e AppKit`__204-[NSTextInputContext
tryTSMProcessRawKeyEvent_orSubstitution:dispatchCondition:setupForDispatch:furtherCondition:doubleSpaceSubstitutionCondition:doubleSpaceSubstitutionWork:dispatchTSMWork:continuation:]_block_invoke.734
+ 115
    frame #61: 0x00007fff47d3093f AppKit`-[NSTextInputContext
tryTSMProcessRawKeyEvent_orSubstitution:dispatchCondition:setupForDispatch:furtherCondition:doubleSpaceSubstitutionCondition:doubleSpaceSubstitutionWork:dispatchTSMWork:continuation:]
+ 245
    frame #62: 0x00007fff47d3100a AppKit`-[NSTextInputContext
_handleEvent:options:allowingSyntheticEvent:completionHandler:] + 1286
    frame #63: 0x00007fff47d307fe AppKit`-[NSTextInputContext
_handleEvent:allowingSyntheticEvent:] + 107
    frame #64: 0x00007fff47664840 AppKit`-[NSView interpretKeyEvents:] +
209
    frame #65: 0x00000001005fa742
libwx_osx_cocoau-3.0.0.dylib`wxWidgetCocoaImpl::DoHandleKeyEvent(NSEvent*)
+ 466
    frame #66: 0x00000001005f6d1c
libwx_osx_cocoau-3.0.0.dylib`wxWidgetCocoaImpl::keyEvent(NSEvent*, NSView*,
void*) + 348
    frame #67: 0x00007fff474b1b9f AppKit`-[NSWindow(NSEventRouting)
_reallySendEvent:isDelayedEvent:] + 6840
    frame #68: 0x00007fff474afe9f AppKit`-[NSWindow(NSEventRouting)
sendEvent:] + 478
    frame #69: 0x00000001005e4fab libwx_osx_cocoau-3.0.0.dylib`-[wxNSWindow
sendEvent:] + 123
    frame #70: 0x00007fff47350101 AppKit`-[NSApplication(NSEvent)
sendEvent:] + 2953
    frame #71: 0x0000000100510c12
libwx_osx_cocoau-3.0.0.dylib`-[wxNSApplication sendEvent:] + 98
    frame #72: 0x00007fff4733dee8 AppKit`-[NSApplication run] + 755
    frame #73: 0x00000001005da62e
libwx_osx_cocoau-3.0.0.dylib`wxGUIEventLoop::OSXDoRun() + 174
    frame #74: 0x00000001004d5111
libwx_osx_cocoau-3.0.0.dylib`wxCFEventLoop::DoRun() + 49
    frame #75: 0x0000000100422b72
libwx_osx_cocoau-3.0.0.dylib`wxEventLoopBase::Run() + 162
    frame #76: 0x00000001003f1463
libwx_osx_cocoau-3.0.0.dylib`wxAppConsoleBase::MainLoop() + 99
    frame #77: 0x000000010057393a
libwx_osx_cocoau-3.0.0.dylib`wxApp::OnRun() + 26
    frame #78: 0x000000010001fe78 kicad`APP_KICAD::OnRun() + 24
    frame #79: 0x000000010045c40a
libwx_osx_cocoau-3.0.0.dylib`wxEntry(int&, wchar_t**) + 58
    frame #80: 0x000000010001cd96 kicad`main + 38
    frame #81: 0x00007fff761e53d5 libdyld.dylib`start + 1
    frame #82: 0x00007fff761e53d5 libdyld.dylib`start + 1
(lldb)
```
Original tags: eeschema hotkeys

Story points: 6.0