mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
2005-08-15 Mike Kestner <mkestner@novell.com>
* glib/Object.cs : hold strong refs for managed subclasses and weakrefs for wrappers. * gtk/Object.custom : don't hold managed refs here, they are now held in GLib.Object. svn path=/trunk/gtk-sharp/; revision=48389
This commit is contained in:
parent
622c360576
commit
b5964c52d0
@ -1,3 +1,10 @@
|
|||||||
|
2005-08-15 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
|
* glib/Object.cs : hold strong refs for managed subclasses and
|
||||||
|
weakrefs for wrappers.
|
||||||
|
* gtk/Object.custom : don't hold managed refs here, they are now held
|
||||||
|
in GLib.Object.
|
||||||
|
|
||||||
2005-08-11 Dan Winship <danw@novell.com>
|
2005-08-11 Dan Winship <danw@novell.com>
|
||||||
|
|
||||||
* parser/gapi2xml.pl (addFuncElems): if a struct or boxed type has
|
* parser/gapi2xml.pl (addFuncElems): if a struct or boxed type has
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// Authors: Mike Kestner <mkestner@speakeasy.net>
|
// Authors: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004-2005 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the Lesser GNU General
|
// modify it under the terms of version 2 of the Lesser GNU General
|
||||||
@ -99,14 +99,18 @@ namespace GLib {
|
|||||||
if (o == IntPtr.Zero)
|
if (o == IntPtr.Zero)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Object obj;
|
Object obj = null;
|
||||||
WeakReference weak_ref = Objects[o] as WeakReference;
|
WeakReference weak_ref = Objects[o] as WeakReference;
|
||||||
|
|
||||||
if (weak_ref != null && weak_ref.IsAlive) {
|
if (weak_ref != null && weak_ref.IsAlive)
|
||||||
lock (PendingDestroys)
|
obj = weak_ref.Target as Object;
|
||||||
PendingDestroys.Remove (weak_ref.Target);
|
|
||||||
|
|
||||||
obj = weak_ref.Target as GLib.Object;
|
if (obj == null)
|
||||||
|
obj = Objects[o] as Object;
|
||||||
|
|
||||||
|
if (obj != null && obj._obj == o) {
|
||||||
|
lock (PendingDestroys)
|
||||||
|
PendingDestroys.Remove (obj);
|
||||||
if (owned_ref)
|
if (owned_ref)
|
||||||
g_object_unref (obj._obj);
|
g_object_unref (obj._obj);
|
||||||
return obj;
|
return obj;
|
||||||
@ -215,6 +219,7 @@ namespace GLib {
|
|||||||
for (int i = 0; i < names.Length; i++)
|
for (int i = 0; i < names.Length; i++)
|
||||||
native_names [i] = GLib.Marshaller.StringToPtrGStrdup (names [i]);
|
native_names [i] = GLib.Marshaller.StringToPtrGStrdup (names [i]);
|
||||||
Raw = gtksharp_object_newv (LookupGType ().Val, names.Length, native_names, vals);
|
Raw = gtksharp_object_newv (LookupGType ().Val, names.Length, native_names, vals);
|
||||||
|
Objects [_obj] = this;
|
||||||
foreach (IntPtr p in native_names)
|
foreach (IntPtr p in native_names)
|
||||||
GLib.Marshaller.Free (p);
|
GLib.Marshaller.Free (p);
|
||||||
}
|
}
|
||||||
|
@ -30,21 +30,11 @@
|
|||||||
[DllImport("libgobject-2.0-0.dll")]
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
private static extern void g_object_ref (IntPtr raw);
|
private static extern void g_object_ref (IntPtr raw);
|
||||||
|
|
||||||
static Hashtable managed_subclasses;
|
|
||||||
static Hashtable ManagedSubclasses {
|
|
||||||
get {
|
|
||||||
if (managed_subclasses == null)
|
|
||||||
managed_subclasses = new Hashtable ();
|
|
||||||
return managed_subclasses;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void NativeDestroy (object o, EventArgs args)
|
static void NativeDestroy (object o, EventArgs args)
|
||||||
{
|
{
|
||||||
Gtk.Object obj = o as Gtk.Object;
|
Gtk.Object obj = o as Gtk.Object;
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
return;
|
return;
|
||||||
ManagedSubclasses.Remove (obj);
|
|
||||||
obj.Destroyed -= NativeDestroyHandler;
|
obj.Destroyed -= NativeDestroyHandler;
|
||||||
obj.Dispose ();
|
obj.Dispose ();
|
||||||
}
|
}
|
||||||
@ -61,13 +51,13 @@
|
|||||||
protected override void CreateNativeObject (string[] names, GLib.Value[] vals)
|
protected override void CreateNativeObject (string[] names, GLib.Value[] vals)
|
||||||
{
|
{
|
||||||
base.CreateNativeObject (names, vals);
|
base.CreateNativeObject (names, vals);
|
||||||
ManagedSubclasses [this] = this;
|
|
||||||
Destroyed += NativeDestroyHandler;
|
Destroyed += NativeDestroyHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose ()
|
public override void Dispose ()
|
||||||
{
|
{
|
||||||
base.Dispose ();
|
base.Dispose ();
|
||||||
|
Destroyed -= NativeDestroyHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IntPtr Raw {
|
protected override IntPtr Raw {
|
||||||
|
Loading…
Reference in New Issue
Block a user