Closed Therzok closed 5 years ago
Updated with PR feedback.
@alanmcgovern can you review?
using System;
using System.IO;
using Gdk;
using Gtk;
public partial class MainWindow : Gtk.Window
{
public MainWindow() : base(Gtk.WindowType.Toplevel)
{
Build();
}
protected override bool OnExposeEvent(EventExpose evnt)
{
for (int i = 0; i < 1000000; ++i)
{
var ev = Gtk.Application.CurrentEvent;
var copy = new Gdk.Event(ev.Handle, true);
}
System.GC.Collect();
System.GC.Collect();
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
return base.OnExposeEvent(evnt);
}
}
public class MainClass
{
public static void Main(string[] args)
{
Application.Init();
var mw = new MainWindow();
mw.ShowAll();
Application.Run();
}
}
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.
EventOwnerChange
as it's not read-only, the rest of the events could be solved by just making a copy of the GdkEvent.
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