added new function g_nullify_pointer().

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().
This commit is contained in:
Sven Neumann 2001-08-06 20:55:11 +00:00 committed by Sven Neumann
parent ec759772de
commit d1d623b072
15 changed files with 155 additions and 0 deletions

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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>

View 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

View 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>

View File

@ -1045,6 +1045,20 @@ g_int_hash (gconstpointer v)
return *(const gint*) 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:
*

View 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); */

View 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)
{

View 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,