PATCH: add second argument to GWeakNotify
- From: James Henstridge <james daa com au>
- To: <gtk-devel-list gnome org>
- Subject: PATCH: add second argument to GWeakNotify
- Date: Fri, 17 Aug 2001 23:03:14 +0800 (WST)
Here is a patch that adds the second argument to the weak reference
notifier prototype, as discussed on the list.
The patch adds the object pointer as the second argument, rather than
first in order to keep compatibility. I didn't hide the second argument,
as Tim suggested, as it feels a bit messy (IMHO). The final argument
order and whether the GObject* argument is shown in the headers are up to
Tim and Owen though.
Is it okay to check this in?
James.
--
Email: james daa com au
WWW: http://www.daa.com.au/~james/
Index: gobject/ChangeLog
===================================================================
RCS file: /cvs/gnome/glib/gobject/ChangeLog,v
retrieving revision 1.135
diff -u -p -r1.135 ChangeLog
--- gobject/ChangeLog 2001/08/15 09:19:51 1.135
+++ gobject/ChangeLog 2001/08/17 14:57:38
@@ -1,3 +1,15 @@
+2001-08-17 James Henstridge <james daa com au>
+
+ * gobject.c (WeakRefStack): add an object member to the structure.
+ (weak_refs_notify): pass wstack->object as extra argument to
+ notify functions.
+ (g_object_weak_ref): set wstack->object when initialising
+ WeakRefStack.
+
+ * gobject.h (GWeakNotify): add second argument to prototype which
+ gives the pointer to where the object that is being disposed of
+ was.
+
Wed Jul 18 19:42:31 2001 Tim Janik <timj gtk org>
* gtype.h: if __GNUC__ is defined, inline a test for an exact type
Index: gobject/gobject.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gobject.c,v
retrieving revision 1.40
diff -u -p -r1.40 gobject.c
--- gobject/gobject.c 2001/08/06 20:55:11 1.40
+++ gobject/gobject.c 2001/08/17 14:57:41
@@ -1181,6 +1181,7 @@ g_object_disconnect (gpointer _objec
}
typedef struct {
+ GObject *object;
guint n_weak_refs;
struct {
GWeakNotify notify;
@@ -1195,7 +1196,7 @@ weak_refs_notify (gpointer data)
guint i;
for (i = 0; i < wstack->n_weak_refs; i++)
- wstack->weak_refs[i].notify (wstack->weak_refs[i].data);
+ wstack->weak_refs[i].notify (wstack->weak_refs[i].data, wstack->object);
g_free (wstack);
}
@@ -1220,6 +1221,7 @@ g_object_weak_ref (GObject *object,
else
{
wstack = g_renew (WeakRefStack, NULL, 1);
+ wstack->object = object;
wstack->n_weak_refs = 1;
i = 0;
}
Index: gobject/gobject.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gobject.h,v
retrieving revision 1.17
diff -u -p -r1.17 gobject.h
--- gobject/gobject.h 2001/08/06 20:55:11 1.17
+++ gobject/gobject.h 2001/08/17 14:57:41
@@ -54,7 +54,8 @@ typedef void (*GObjectSetPropertyFunc)
const GValue *value,
GParamSpec *pspec);
typedef void (*GObjectFinalizeFunc) (GObject *object);
-typedef void (*GWeakNotify) (gpointer data);
+typedef void (*GWeakNotify) (gpointer data,
+ GObject *where_the_object_was);
struct _GObject
{
GTypeInstance g_type_instance;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]