these two samples are crashing with no message in console:
sample02_controls
sample03_image
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)
```
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) ```