mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
2008-04-17 Mike Kestner <mkestner@novell.com>
* glib/ToggleRef.cs: Add a Harden method to switch to a standard ref and just leak it. * gtk/Application.cs: revert the QuitPrepare stuff since it didn't always work. svn path=/trunk/gtk-sharp/; revision=101021
This commit is contained in:
parent
cff6726824
commit
d2a74c9a37
@ -1,3 +1,10 @@
|
|||||||
|
2008-04-17 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
|
* glib/ToggleRef.cs: Add a Harden method to switch to a standard
|
||||||
|
ref and just leak it.
|
||||||
|
* gtk/Application.cs: revert the QuitPrepare stuff since it didn't
|
||||||
|
always work.
|
||||||
|
|
||||||
2008-04-17 Mike Kestner <mkestner@novell.com>
|
2008-04-17 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* gtk/TreeModelAdapter.custom:
|
* gtk/TreeModelAdapter.custom:
|
||||||
|
@ -27,6 +27,7 @@ namespace GLib {
|
|||||||
|
|
||||||
internal class ToggleRef {
|
internal class ToggleRef {
|
||||||
|
|
||||||
|
bool hardened;
|
||||||
IntPtr handle;
|
IntPtr handle;
|
||||||
object reference;
|
object reference;
|
||||||
GCHandle gch;
|
GCHandle gch;
|
||||||
@ -81,11 +82,30 @@ namespace GLib {
|
|||||||
foreach (Signal s in Signals.Values)
|
foreach (Signal s in Signals.Values)
|
||||||
s.Free ();
|
s.Free ();
|
||||||
Signals.Clear ();
|
Signals.Clear ();
|
||||||
g_object_remove_toggle_ref (handle, ToggleNotifyCallback, (IntPtr) gch);
|
if (hardened)
|
||||||
|
g_object_unref (handle);
|
||||||
|
else
|
||||||
|
g_object_remove_toggle_ref (handle, ToggleNotifyCallback, (IntPtr) gch);
|
||||||
reference = null;
|
reference = null;
|
||||||
gch.Free ();
|
gch.Free ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void Harden ()
|
||||||
|
{
|
||||||
|
// Added for the benefit of GnomeProgram. It releases a final ref in
|
||||||
|
// an atexit handler which causes toggle ref notifications to occur after
|
||||||
|
// our delegates are gone, so we need a mechanism to override the
|
||||||
|
// notifications. This method effectively leaks all objects which invoke it,
|
||||||
|
// but since it is only used by Gnome.Program, which is a singleton object
|
||||||
|
// with program duration persistence, who cares.
|
||||||
|
|
||||||
|
g_object_ref (handle);
|
||||||
|
g_object_remove_toggle_ref (handle, ToggleNotifyCallback, (IntPtr) gch);
|
||||||
|
if (reference is WeakReference)
|
||||||
|
reference = (reference as WeakReference).Target;
|
||||||
|
hardened = true;
|
||||||
|
}
|
||||||
|
|
||||||
void Toggle (bool is_last_ref)
|
void Toggle (bool is_last_ref)
|
||||||
{
|
{
|
||||||
if (is_last_ref && reference is GLib.Object)
|
if (is_last_ref && reference is GLib.Object)
|
||||||
@ -126,6 +146,9 @@ namespace GLib {
|
|||||||
[DllImport("libgobject-2.0-0.dll")]
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
static extern void g_object_remove_toggle_ref (IntPtr raw, ToggleNotifyHandler notify_cb, IntPtr data);
|
static extern void g_object_remove_toggle_ref (IntPtr raw, ToggleNotifyHandler notify_cb, IntPtr data);
|
||||||
|
|
||||||
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
|
static extern IntPtr g_object_ref (IntPtr raw);
|
||||||
|
|
||||||
[DllImport("libgobject-2.0-0.dll")]
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
static extern void g_object_unref (IntPtr raw);
|
static extern void g_object_unref (IntPtr raw);
|
||||||
|
|
||||||
|
@ -131,15 +131,11 @@ namespace Gtk {
|
|||||||
return gtk_main_iteration_do (blocking);
|
return gtk_main_iteration_do (blocking);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static event EventHandler QuitPrepare;
|
|
||||||
|
|
||||||
[DllImport("libgtk-win32-2.0-0.dll")]
|
[DllImport("libgtk-win32-2.0-0.dll")]
|
||||||
static extern void gtk_main_quit ();
|
static extern void gtk_main_quit ();
|
||||||
|
|
||||||
public static void Quit ()
|
public static void Quit ()
|
||||||
{
|
{
|
||||||
if (QuitPrepare != null)
|
|
||||||
QuitPrepare (null, EventArgs.Empty);
|
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user