2002-09-04 Mike Kestner <mkestner@speakeasy.net>
* generator/ObjectGen.cs : generate dtors. * glib/Object.cs : Implement IDisposable. Add a new DisposeNative method. Implement default dtor. * glue/object.c : new gtksharp_object_unref_if_floating method. * gtk/Object.custom : override DisposeNative to check float bit. svn path=/trunk/gtk-sharp/; revision=7235
This commit is contained in:
parent
6fea628be5
commit
ab081f8358
6 changed files with 85 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2002-09-04 Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
|
||||||
|
* generator/ObjectGen.cs : generate dtors.
|
||||||
|
* glib/Object.cs : Implement IDisposable. Add a new DisposeNative
|
||||||
|
method. Implement default dtor.
|
||||||
|
* glue/object.c : new gtksharp_object_unref_if_floating method.
|
||||||
|
* gtk/Object.custom : override DisposeNative to check float bit.
|
||||||
|
|
||||||
2002-09-03 Juli Mallett <jmallett@FreeBSD.org>
|
2002-09-03 Juli Mallett <jmallett@FreeBSD.org>
|
||||||
|
|
||||||
* parser/Makefile.in: Use $(CC) instead of 'cc'.
|
* parser/Makefile.in: Use $(CC) instead of 'cc'.
|
||||||
|
|
|
@ -185,6 +185,11 @@ namespace GtkSharp.Generation {
|
||||||
if (!Elem.HasAttribute("parent"))
|
if (!Elem.HasAttribute("parent"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
sw.WriteLine("\t\t~" + Name + "()");
|
||||||
|
sw.WriteLine("\t\t{");
|
||||||
|
sw.WriteLine("\t\t\tDispose();");
|
||||||
|
sw.WriteLine("\t\t}");
|
||||||
|
sw.WriteLine();
|
||||||
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,50 @@ namespace GLib {
|
||||||
/// Wrapper class for GObject.
|
/// Wrapper class for GObject.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public class Object : IWrapper {
|
public class Object : IWrapper, IDisposable {
|
||||||
|
|
||||||
// Private class and instance members
|
// Private class and instance members
|
||||||
IntPtr _obj;
|
IntPtr _obj;
|
||||||
EventHandlerList _events;
|
EventHandlerList _events;
|
||||||
|
bool disposed = false;
|
||||||
Hashtable Data;
|
Hashtable Data;
|
||||||
static Hashtable Objects = new Hashtable();
|
static Hashtable Objects = new Hashtable();
|
||||||
|
|
||||||
|
~Object ()
|
||||||
|
{
|
||||||
|
Dispose ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dispose Method
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Disposes of the raw object. Only override this if
|
||||||
|
/// the Raw object should not be unref'd when the object
|
||||||
|
/// is garbage collected.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
public void Dispose ()
|
||||||
|
{
|
||||||
|
if (disposed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DisposeNative ();
|
||||||
|
disposed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("gobject-2.0")]
|
||||||
|
static extern void g_object_unref (IntPtr raw);
|
||||||
|
|
||||||
|
protected virtual void DisposeNative ()
|
||||||
|
{
|
||||||
|
if (_obj == IntPtr.Zero)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_object_unref (_obj);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GetObject Shared Method
|
/// GetObject Shared Method
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -9,6 +9,7 @@ BASESOURCES = \
|
||||||
error.c \
|
error.c \
|
||||||
event.c \
|
event.c \
|
||||||
slist.c \
|
slist.c \
|
||||||
|
object.c \
|
||||||
paned.c \
|
paned.c \
|
||||||
style.c \
|
style.c \
|
||||||
type.c \
|
type.c \
|
||||||
|
|
17
glue/object.c
Normal file
17
glue/object.c
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/* object.c : Glue to clean up GtkObject references.
|
||||||
|
*
|
||||||
|
* Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
*
|
||||||
|
* <c> 2002 Mike Kestner
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <gtk/gtkobject.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
gtksharp_object_unref_if_floating (GObject *obj)
|
||||||
|
{
|
||||||
|
if (GTK_OBJECT_FLOATING (obj))
|
||||||
|
g_object_unref (obj);
|
||||||
|
}
|
||||||
|
|
17
gtk/Object.custom
Executable file
17
gtk/Object.custom
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
// Gtk.Object.custom - Gtk Window class customizations
|
||||||
|
//
|
||||||
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
//
|
||||||
|
// (c) 2002 Mike Kestner
|
||||||
|
//
|
||||||
|
// This code is inserted after the automatically generated code.
|
||||||
|
|
||||||
|
|
||||||
|
[DllImport("gtksharpglue")]
|
||||||
|
static extern void gtksharp_object_unref_if_floating (IntPtr raw);
|
||||||
|
|
||||||
|
protected override void DisposeNative ()
|
||||||
|
{
|
||||||
|
gtksharp_object_unref_if_floating (Handle);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue