yglukhov / nimx

GUI library
MIT License
1.1k stars 75 forks source link

Delay or crash when entering certain characters #138

Closed ghost closed 8 years ago

ghost commented 8 years ago

Here's a short example that can be used to reproduce the issue:

import nimx.window
import nimx.text_field
import nimx.system_logger
proc startApp() = newWindow(newRect(40, 40, 800, 600)).addSubview(newTextField(newRect(20, 40, 20, 20)))
runApplication: startApp()

The crash occurs when the first character entered into the field is '€' for example, but it only results in a delay when it is not the first character. Characters like 'å', 'ä', and 'ö' do not cause a crash, but they also result in a delay of about 2 seconds.

Here is the stack trace for when it crashes:

Traceback (most recent call last)
sdl_window.nim(333)      main
sdl_window.nim(324)      runUntilQuit
sdl_window.nim(304)      nextEvent
sdl_window.nim(253)      handleEvent
app.nim(54)              handleEvent
window_event_handling.nim(29) handleEvent
window_event_handling.nim(43) handleEvent
view_event_handling.nim(17) onTextInput
window_event_handling.nim(22) onTextInput
view_event_handling.nim(17) onTextInput
text_field.nim(318)      onTextInput
text_field.nim(221)      insertText
text_field.nim(203)      updateCursorOffset
font.nim(465)            cursorOffsetForPositionInString
font.nim(436)            getQuadDataForRune
font.nim(414)            chunkAndCharIndexForRune
font.nim(290)            bakeChars
ttf.nim(2119)            stbtt_MakeGlyphBitmap
ttf.nim(2116)            stbtt_MakeGlyphBitmapSubpixel
ttf.nim(2063)            stbtt_Rasterize
ttf.nim(1967)            stbtt_rasterize
SIGSEGV: Illegal storage access. (Attempt to read from nil?)