-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1128 from gircore/fix-1125
Object: Fix ToggleNotify called after callback is disposed
- Loading branch information
Showing
3 changed files
with
70 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Libs/GObject-2.0/Internal/ObjectMapper.ToggleRegistration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace GObject.Internal; | ||
|
||
public partial class ObjectMapper | ||
{ | ||
private static unsafe class ToggleRegistration | ||
{ | ||
internal static void AddToggleRef(IntPtr handle) | ||
{ | ||
AddToggleRef(handle, &ToggleNotify, IntPtr.Zero); | ||
Internal.Object.Unref(handle); | ||
} | ||
|
||
internal static void RemoveToggleRef(IntPtr handle) | ||
{ | ||
var sourceFunc = new GLib.Internal.SourceFuncAsyncHandler(() => | ||
{ | ||
RemoveToggleRef(handle, &ToggleNotify, IntPtr.Zero); | ||
return false; | ||
}); | ||
GLib.Internal.MainContext.Invoke(GLib.Internal.MainContextUnownedHandle.NullHandle, sourceFunc.NativeCallback, IntPtr.Zero); | ||
} | ||
|
||
[DllImport(ImportResolver.Library, EntryPoint = "g_object_add_toggle_ref")] | ||
private static extern void AddToggleRef(IntPtr @object, delegate* unmanaged<IntPtr, IntPtr, int, void> toggleNotify, IntPtr data); | ||
|
||
[DllImport(ImportResolver.Library, EntryPoint = "g_object_remove_toggle_ref")] | ||
private static extern void RemoveToggleRef(IntPtr @object, delegate* unmanaged<IntPtr, IntPtr, int, void> toggleNotify, IntPtr data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters