karaxnim/karax

runtime error on redraw in `removeAllEventHandlers` proc

choltreppe opened this issue · 2 comments

So sometimes I get a runtime error on redraw:

Uncaught TypeError: d_1409286269 is null
    removeAllEventHandlers_1409286268
...

I fixed it in my local .nimble/pkgs2/ copy like this:

proc removeAllEventHandlers(d: Node) =
  if d != nil and d.karaxEvents != nil:
    for i in 0..<d.karaxEvents.len:
      d.removeEventListener(d.karaxEvents[i][0], d.karaxEvents[i][1])

but Im not sure if thats a real fix, or just fixing the symptoms

geotre commented

Are you able to narrow it down to a simple reproducible example? I suspect it’s an issue attaching event listeners to certain node types but I haven’t looked into it yet

it turned out this was an ID10t-error :)
I saved a static part of the site in a variable and place that at different spots, this fucked up some things.
Makes sense when you try to build a tree and put the same ref at multiple nodes, didnt think that through very well.