gircore / gir.core

A C# binding generator for GObject based libraries providing a C# friendly API surface
https://gircore.github.io/
MIT License
279 stars 29 forks source link

GObject: Execute object disposal on main thread #1044

Closed badcel closed 2 months ago

badcel commented 2 months ago

To fix a bug occurring in Pinta the ObjectHandle should dispose the object instance on the main thread:

public void Dispose()
{    
    var sourceFunc = new SourceFuncAsyncHandler(() =>
    {
        Internal.Object.RemoveToggleRef(_handle, _callback, IntPtr.Zero);
        return false;
    });
    MainContext.Invoke(MainContextUnownedHandle.NullHandle, sourceFunc.NativeCallback, IntPtr.Zero);
}