yglukhov / nimx

GUI library
MIT License
1.08k stars 76 forks source link

sample02_controls and sample03_image crashes. #518

Closed veksha closed 10 months ago

veksha commented 1 year ago

these two samples are crashing with no message in console:

os: windows11 nim: latest

i see that they can't load cat image. tried to fix with the following patch, but only sample02 works fully after that. sample03 loads cat image ok, but also freezes the app completely.

Click to see diff ```diff diff --git a/nimx/assets/url_stream.nim b/nimx/assets/url_stream.nim index b37dbff..73856be 100644 --- a/nimx/assets/url_stream.nim +++ b/nimx/assets/url_stream.nim @@ -6,7 +6,7 @@ type Error = string type Handler* = proc(s: Stream, error: Error) {.gcsafe.} type UrlHandler = proc(url: string, handler: Handler) {.gcsafe.} -var urlHandlers {.threadvar.}: TableRef[string, UrlHandler] +var urlHandlers: TableRef[string, UrlHandler] template getUrlHandlers(): TableRef[string, UrlHandler] = urlHandlers @@ -21,7 +21,8 @@ proc openStreamForUrl*(url: string, handler: Handler) {.gcsafe.} = let scheme = url.urlScheme if scheme.len == 0: raise newException(Exception, "Invalid url: \"" & url & "\"") - let uh = getUrlHandlers().getOrDefault(scheme) + {.gcsafe.}: + let uh = getUrlHandlers().getOrDefault(scheme) if uh.isNil: raise newException(Exception, "No url handler for scheme " & scheme) uh(url, handler) ```
veksha commented 1 year ago

i think this issue is related: https://github.com/yglukhov/nimx/issues/323

but strange that i have no traceback on my system.

yglukhov commented 10 months ago

Most likely fixed in 3a832a2e593321407d940e0affece70ba67f6278