2005-05-13 Mike Kestner <mkestner@novell.com>
* gtk/Object.custom : hold refs for all managed subclasses. Release on Destroy. Dispose plain wrappers on Destroy also. * gtk/Widget.custom : remove the parent set hack since it's "handled" on Gtk.Object now. All this will get fixed properly when we have access to owen's toggle_refs. svn path=/trunk/gtk-sharp/; revision=44506
This commit is contained in:
parent
9ac721885b
commit
afa17eacee
4 changed files with 59 additions and 32 deletions
|
@ -1,3 +1,11 @@
|
|||
2005-05-13 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* gtk/Object.custom : hold refs for all managed subclasses. Release on
|
||||
Destroy. Dispose plain wrappers on Destroy also.
|
||||
* gtk/Widget.custom : remove the parent set hack since it's "handled"
|
||||
on Gtk.Object now. All this will get fixed properly when we have
|
||||
access to owen's toggle_refs.
|
||||
|
||||
2005-05-13 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* generator/MethodBody.cs : don't create a new destroy notify
|
||||
|
|
|
@ -451,5 +451,34 @@ The object is only destroyed if all the references to the object are released, t
|
|||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="CreateNativeObject">
|
||||
<MemberSignature Language="C#" Value="protected override void CreateNativeObject (string [] names, GLib.Value[] vals);" />
|
||||
<MemberType>Method</MemberType>
|
||||
<ReturnValue>
|
||||
<ReturnType>System.Void</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters>
|
||||
<Parameter Name="names" Type="System.String[]" />
|
||||
<Parameter Name="vals" Type="GLib.Value[]" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Internal method used by language bindings.</summary>
|
||||
<param name="names">a <see cref="T:System.String" /></param>
|
||||
<param name="vals">a <see cref="T:GLib.Value" /></param>
|
||||
<remarks>Should not be called by user code typically.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="Dispose">
|
||||
<MemberSignature Language="C#" Value="public override void Dispose ();" />
|
||||
<MemberType>Method</MemberType>
|
||||
<ReturnValue>
|
||||
<ReturnType>System.Void</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters />
|
||||
<Docs>
|
||||
<summary>Releases object resources.</summary>
|
||||
<remarks />
|
||||
</Docs>
|
||||
</Member>
|
||||
</Members>
|
||||
</Type>
|
||||
|
|
|
@ -30,12 +30,21 @@
|
|||
[DllImport("libgobject-2.0-0.dll")]
|
||||
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)
|
||||
{
|
||||
Gtk.Object obj = o as Gtk.Object;
|
||||
if (obj == null)
|
||||
return;
|
||||
obj.Destroyed -= NativeDestroyHandler;
|
||||
ManagedSubclasses.Remove (obj);
|
||||
obj.Dispose ();
|
||||
}
|
||||
|
||||
|
@ -48,6 +57,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
protected override void CreateNativeObject (string[] names, GLib.Value[] vals)
|
||||
{
|
||||
base.CreateNativeObject (names, vals);
|
||||
ManagedSubclasses [this] = this;
|
||||
}
|
||||
|
||||
public override void Dispose ()
|
||||
{
|
||||
Destroyed -= NativeDestroyHandler;
|
||||
base.Dispose ();
|
||||
}
|
||||
|
||||
protected override IntPtr Raw {
|
||||
get {
|
||||
return base.Raw;
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
[Obsolete]
|
||||
protected Widget (GLib.GType gtype) : base(gtype)
|
||||
{
|
||||
IntPtr name = GLib.Marshaller.StringToPtrGStrdup ("parent-set");
|
||||
g_signal_connect_data (Handle, name, NativeParentSetHandler, IntPtr.Zero, IntPtr.Zero, 0);
|
||||
GLib.Marshaller.Free (name);
|
||||
}
|
||||
|
||||
public override void Destroy ()
|
||||
|
@ -35,37 +32,9 @@ public override void Destroy ()
|
|||
base.Destroy ();
|
||||
}
|
||||
|
||||
delegate void NativeParentSetDelegate (IntPtr obj, IntPtr prev, IntPtr data);
|
||||
|
||||
[DllImport("libgobject-2.0-0.dll")]
|
||||
static extern int g_signal_connect_data (IntPtr raw, IntPtr name, NativeParentSetDelegate hndlr, IntPtr data, IntPtr notify, int flags);
|
||||
|
||||
protected override void CreateNativeObject (string[] names, GLib.Value[] vals)
|
||||
{
|
||||
base.CreateNativeObject (names, vals);
|
||||
IntPtr name = GLib.Marshaller.StringToPtrGStrdup ("parent-set");
|
||||
g_signal_connect_data (Handle, name, NativeParentSetHandler, IntPtr.Zero, IntPtr.Zero, 0);
|
||||
GLib.Marshaller.Free (name);
|
||||
}
|
||||
|
||||
private static Hashtable ParentedWidgets = new Hashtable ();
|
||||
|
||||
private static NativeParentSetDelegate native_parent_set_handler;
|
||||
private static NativeParentSetDelegate NativeParentSetHandler {
|
||||
get {
|
||||
if (native_parent_set_handler == null)
|
||||
native_parent_set_handler = new NativeParentSetDelegate (Widget_ParentSet);
|
||||
return native_parent_set_handler;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Widget_ParentSet (IntPtr raw, IntPtr prev, IntPtr data)
|
||||
{
|
||||
Widget w = GLib.Object.GetObject (raw) as Widget;
|
||||
if (w.Parent == null)
|
||||
ParentedWidgets.Remove (w);
|
||||
else
|
||||
ParentedWidgets[w] = w;
|
||||
}
|
||||
|
||||
[DllImport("gtksharpglue-2")]
|
||||
|
|
Loading…
Reference in a new issue