added new function g_nullify_pointer().
authorSven Neumann <sven@gimp.org>
Mon, 6 Aug 2001 20:55:11 +0000 (20:55 +0000)
committerSven Neumann <neo@src.gnome.org>
Mon, 6 Aug 2001 20:55:11 +0000 (20:55 +0000)
2001-08-06  Sven Neumann  <sven@gimp.org>

* glib/gutils.[ch]: added new function g_nullify_pointer().

* gobject/gobject.[ch]:
added new functions g_object_[add|remove]_weak_pointer().

15 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/gobject/gobject-sections.txt
docs/reference/gobject/tmpl/objects.sgml
glib/gutils.c
glib/gutils.h
gobject/gobject.c
gobject/gobject.h

index 81fa4dc..a032052 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-08-06  Sven Neumann  <sven@gimp.org>
+
+       * glib/gutils.[ch]: added new function g_nullify_pointer().
+       
+       * gobject/gobject.[ch]: 
+       added new functions g_object_[add|remove]_weak_pointer().
+
 2001-08-05  Ron Steinke  <rsteinke@w-link.net>
 
        * glib/giochannel.c glib/giochannel.c glib/glib.def
index 81fa4dc..a032052 100644 (file)
@@ -1,3 +1,10 @@
+2001-08-06  Sven Neumann  <sven@gimp.org>
+
+       * glib/gutils.[ch]: added new function g_nullify_pointer().
+       
+       * gobject/gobject.[ch]: 
+       added new functions g_object_[add|remove]_weak_pointer().
+
 2001-08-05  Ron Steinke  <rsteinke@w-link.net>
 
        * glib/giochannel.c glib/giochannel.c glib/glib.def
index 81fa4dc..a032052 100644 (file)
@@ -1,3 +1,10 @@
+2001-08-06  Sven Neumann  <sven@gimp.org>
+
+       * glib/gutils.[ch]: added new function g_nullify_pointer().
+       
+       * gobject/gobject.[ch]: 
+       added new functions g_object_[add|remove]_weak_pointer().
+
 2001-08-05  Ron Steinke  <rsteinke@w-link.net>
 
        * glib/giochannel.c glib/giochannel.c glib/glib.def
index 81fa4dc..a032052 100644 (file)
@@ -1,3 +1,10 @@
+2001-08-06  Sven Neumann  <sven@gimp.org>
+
+       * glib/gutils.[ch]: added new function g_nullify_pointer().
+       
+       * gobject/gobject.[ch]: 
+       added new functions g_object_[add|remove]_weak_pointer().
+
 2001-08-05  Ron Steinke  <rsteinke@w-link.net>
 
        * glib/giochannel.c glib/giochannel.c glib/glib.def
index 81fa4dc..a032052 100644 (file)
@@ -1,3 +1,10 @@
+2001-08-06  Sven Neumann  <sven@gimp.org>
+
+       * glib/gutils.[ch]: added new function g_nullify_pointer().
+       
+       * gobject/gobject.[ch]: 
+       added new functions g_object_[add|remove]_weak_pointer().
+
 2001-08-05  Ron Steinke  <rsteinke@w-link.net>
 
        * glib/giochannel.c glib/giochannel.c glib/glib.def
index 81fa4dc..a032052 100644 (file)
@@ -1,3 +1,10 @@
+2001-08-06  Sven Neumann  <sven@gimp.org>
+
+       * glib/gutils.[ch]: added new function g_nullify_pointer().
+       
+       * gobject/gobject.[ch]: 
+       added new functions g_object_[add|remove]_weak_pointer().
+
 2001-08-05  Ron Steinke  <rsteinke@w-link.net>
 
        * glib/giochannel.c glib/giochannel.c glib/glib.def
index 81fa4dc..a032052 100644 (file)
@@ -1,3 +1,10 @@
+2001-08-06  Sven Neumann  <sven@gimp.org>
+
+       * glib/gutils.[ch]: added new function g_nullify_pointer().
+       
+       * gobject/gobject.[ch]: 
+       added new functions g_object_[add|remove]_weak_pointer().
+
 2001-08-05  Ron Steinke  <rsteinke@w-link.net>
 
        * glib/giochannel.c glib/giochannel.c glib/glib.def
index 81fa4dc..a032052 100644 (file)
@@ -1,3 +1,10 @@
+2001-08-06  Sven Neumann  <sven@gimp.org>
+
+       * glib/gutils.[ch]: added new function g_nullify_pointer().
+       
+       * gobject/gobject.[ch]: 
+       added new functions g_object_[add|remove]_weak_pointer().
+
 2001-08-05  Ron Steinke  <rsteinke@w-link.net>
 
        * glib/giochannel.c glib/giochannel.c glib/glib.def
index 63f5503..5e2a570 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-06  Sven Neumann  <sven@gimp.org>
+
+       * docs/reference/gobject/gobject-sections.txt
+       * docs/reference/gobject/tmpl/objects.sgml: added documentation for
+       g_object_[add|remove]_weak_pointer().
+
 2001-07-19  Darin Adler  <darin@bentspoon.com>
 
        reviewed by: <delete if not using a buddy>
index 9d43e4b..43a70b5 100644 (file)
@@ -157,6 +157,10 @@ g_object_class_find_property
 g_object_new
 g_object_ref
 g_object_unref
+g_object_weak_ref
+g_object_weak_unref
+g_object_add_weak_pointer
+g_object_remove_weak_pointer
 g_object_connect
 g_object_disconnect
 g_object_set
index 2e69507..cc3c2be 100644 (file)
@@ -207,6 +207,49 @@ The Base Object Type
 @object: 
 
 
+<!-- ##### FUNCTION g_object_weak_ref ##### -->
+<para>
+
+</para>
+
+@object: 
+@notify: 
+@data: 
+
+
+<!-- ##### FUNCTION g_object_weak_unref ##### -->
+<para>
+
+</para>
+
+@object: 
+@notify: 
+@data: 
+
+
+<!-- ##### FUNCTION g_object_add_weak_pointer ##### -->
+<para>
+Adds a weak reference from weak_pointer to @object to indicate that
+the pointer located at @weak_pointer_location is only valid during the 
+lifetime of @object. When the @object is finalized, @weak_pointer will 
+be set to %NULL.
+</para>
+
+@object: the object that should be weak referenced.
+@weak_pointer_location: the memory address of a pointer.
+
+
+<!-- ##### FUNCTION g_object_remove_weak_pointer ##### -->
+<para>
+Removes a weak reference from @object that was previously added
+using g_object_add_weak_pointer(). The @weak_pointer_location has
+to match the one used with g_object_add_weak_pointer().
+</para>
+
+@object: the object that is weak referenced.
+@weak_pointer_location: the memory address of a pointer.
+
+
 <!-- ##### FUNCTION g_object_connect ##### -->
 <para>
 
index 24d7ad9..17e1514 100644 (file)
@@ -1046,6 +1046,20 @@ g_int_hash (gconstpointer v)
 }
 
 /**
+ * g_nullify_pointer:
+ * @nullify_location: the memory address of the pointer.
+ * 
+ * Set the pointer at the specified location to %NULL.
+ **/
+void
+g_nullify_pointer (gpointer *nullify_location)
+{
+  g_return_if_fail (nullify_location != NULL);
+
+  *nullify_location = NULL;
+}
+
+/**
  * g_get_codeset:
  * 
  * Get the codeset for the current locale.
index f4c9098..f449483 100644 (file)
@@ -165,6 +165,10 @@ gchar*                g_get_current_dir    (void);
 gchar*                g_path_get_basename  (const gchar *file_name);
 gchar*                g_path_get_dirname   (const gchar *file_name);
 
+
+/* Set the pointer at the specified location to NULL */
+void                  g_nullify_pointer    (gpointer    *nullify_location);
+
 /* Get the codeset for the current locale */
 /* gchar * g_get_codeset    (void); */
 
index 7e68087..e1855e1 100644 (file)
@@ -1262,6 +1262,30 @@ g_object_weak_unref (GObject    *object,
     g_warning (G_STRLOC ": couldn't find weak ref %p(%p)", notify, data);
 }
 
+void
+g_object_add_weak_pointer (GObject  *object, 
+                           gpointer *weak_pointer_location)
+{
+  g_return_if_fail (G_IS_OBJECT (object));
+  g_return_if_fail (weak_pointer_location != NULL);
+
+  g_object_weak_ref (object, 
+                     (GWeakNotify) g_nullify_pointer, 
+                     weak_pointer_location);
+}
+
+void
+g_object_remove_weak_pointer (GObject  *object, 
+                              gpointer *weak_pointer_location)
+{
+  g_return_if_fail (G_IS_OBJECT (object));
+  g_return_if_fail (weak_pointer_location != NULL);
+
+  g_object_weak_unref (object, 
+                       (GWeakNotify) g_nullify_pointer, 
+                       weak_pointer_location);
+}
+
 gpointer
 g_object_ref (gpointer _object)
 {
index 43740f0..582f81c 100644 (file)
@@ -154,6 +154,10 @@ void           g_object_weak_ref                 (GObject        *object,
 void       g_object_weak_unref               (GObject        *object,
                                               GWeakNotify     notify,
                                               gpointer        data);
+void        g_object_add_weak_pointer         (GObject        *object, 
+                                               gpointer       *weak_pointer_location);
+void        g_object_remove_weak_pointer      (GObject        *object, 
+                                               gpointer       *weak_pointer_location);
 gpointer    g_object_get_qdata                (GObject        *object,
                                               GQuark          quark);
 void        g_object_set_qdata                (GObject        *object,