New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullReferenceExceptions randomly thrown in HandleSizeAllocated
when modifying table
#2181
Comments
New update; It's something to do with the |
Hey @EternalClickbait, this is likely due to creating/destroying many labels often, where Gtk is still sending events to some of them after they have been garbage collected on the .NET side. That method need to do what (most) of the others do, where it bails if the Handler is null, such as:
|
One way that might get around this is to always create a new TableLayout, and only call A more efficient way would be to keep references to each of the labels and update their text instead of recreating this table and the labels each time. |
Yeah I switched to modifying the table each tick instead of recreating the labels (unless necessary). I also added a load of calls to What Solved It
|
Expected Behavior
No exceptions are thrown
Actual Behavior
Steps to Reproduce the Problem
(Specific to my project)
UpdateStatsTable()
Context:
I'm working on a RayTracer, and I'm making a realtime display for the progress of the render. I have a task running on a worker thread that intermittently updates the UI.
Whenever
UpdateStatsTable()
is called, the error starts to appear. Removing the call seems to remove all errors.The error occurs when the app is running (not long after Start Render is clicked - see full project). No interaction is performed (no mouse, no resizing, no minimizing etc). The issue seems to happen more consistently when i maximize/resize the app window.See comment below, I think it's the calls totable.Add(...)
. Also only happens when resizing the window, I think before my logs were just getting delayed due to the sheer amount of errors and the console not being fast enoughCode that Demonstrates the Problem
It's a full project, so you might want to find it here, but I'll put the
UpdateStatsTable
code hereThe code that seems to be throwing the exception is:
When I was debugging at
ClosureInvokedCB
, I managed to find out it's callingHandleSizeAllocated()
on aGtkControl<LabelHandler.EtoLabel, Label, TextControl.ICallback>.GtkControlConnector
. The problem is that theGtkControlConnector
has a.Handler
property set tonull
, so that when it tries to accessthis.Handler.asize
it gets aNullReferenceException
becausethis.Handler
is null. This exception then gets propagated back to my code. I'm not really sure how to fix this since the methods are being called from native code, sorry.Specifications
The text was updated successfully, but these errors were encountered: