-
Notifications
You must be signed in to change notification settings - Fork 141
Attempt at getting Gdk events to get finalized and freed on the UI th… #254
Conversation
…read Possible fix for VSTS #739030 - Visual Studio Community 7.7 for Mac - crahses when holding down cursor key
cf4c089
to
24a198d
Compare
gdk/Event.cs
Outdated
if (!owned) | ||
System.GC.SuppressFinalize (this); | ||
} | ||
|
||
static object lockObject = new object (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static readonly
?
gdk/Event.cs
Outdated
{ | ||
if (owned) { | ||
System.GC.SuppressFinalize (this); | ||
gdk_event_free (Handle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero out Handle
to prevent crashes due to double free?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One double-Dispose bug!
gdk/Event.cs
Outdated
static List<Event> PendingFrees = new List<Event> (); | ||
static bool idleQueued; | ||
|
||
static GLib.TimeoutHandler PerformQueuedFreesHandler = PerformQueuedFrees; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static readonly
here too
Updated with PR feedback. |
@alanmcgovern can you review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to test this, but 👍 lgtm.
|
Actually, this doesn't fix the issue... The event goes out of scope and it gets freed by native gtk. I think our only solution is to make it a ref struct and avoid the value from escaping, otherwise it'll just free invalid memory. |
I thought it was an UI thread bug, but it can still happen. |
|
Closing. The problem with Gdk.Event is how it's bound and it requires breaking API to fix. We worked around it in VSMac by manually pinvoking |
…read
Possible fix for VSTS #739030 - Visual Studio Community 7.7 for Mac - crahses when holding down cursor key