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:
Mike Kestner 2002-09-04 05:25:58 +00:00
parent 6fea628be5
commit ab081f8358
6 changed files with 85 additions and 1 deletions

View file

@ -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>
* parser/Makefile.in: Use $(CC) instead of 'cc'.

View file

@ -185,6 +185,11 @@ namespace GtkSharp.Generation {
if (!Elem.HasAttribute("parent"))
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();

View file

@ -20,14 +20,50 @@ namespace GLib {
/// Wrapper class for GObject.
/// </remarks>
public class Object : IWrapper {
public class Object : IWrapper, IDisposable {
// Private class and instance members
IntPtr _obj;
EventHandlerList _events;
bool disposed = false;
Hashtable Data;
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>
/// GetObject Shared Method
/// </summary>

View file

@ -9,6 +9,7 @@ BASESOURCES = \
error.c \
event.c \
slist.c \
object.c \
paned.c \
style.c \
type.c \

17
glue/object.c Normal file
View 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
View 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);
}