Files | |
| file | gnc-gobject-utils.h |
| Gobject helper routines. | |
| void gnc_gobject_tracking_dump | ( | void | ) |
Dump the entire object tracking database via the g_log() family of functions. This function is only called when gnucash exits, and at that point all of the objects should have been removed from the database and freed. Any object remaining is the result of a memory/object leakage.
Definition at line 105 of file gnc-gobject-utils.c.
00106 { 00107 GHashTable *table; 00108 00109 //printf("Enter %s:\n", G_STRFUNC); 00110 table = gnc_gobject_tracking_table(); 00111 00112 if (g_hash_table_size(table) > 0) 00113 { 00114 g_message("The following objects remain alive:"); 00115 g_hash_table_foreach_remove(table, (GHRFunc)gnc_gobject_dump_list, NULL); 00116 } 00117 //printf("Leave %s:\n", G_STRFUNC); 00118 }
| void gnc_gobject_tracking_forget | ( | GObject * | object | ) |
Tell gnucash to drop this object from the database.
| object | The object to be dropped. |
Definition at line 204 of file gnc-gobject-utils.c.
00205 { 00206 if (gnc_gobject_tracking_forget_internal(object)) 00207 g_object_weak_unref(object, gnc_gobject_weak_cb, NULL); 00208 }
| const GList* gnc_gobject_tracking_get_list | ( | const gchar * | name | ) |
Get a list of all known objects of a specified type.
| name | The type name of the objects to be found. This is the name used when the object type was initialized. If unknown, it can be found by calling G_OBJECT_TYPE_NAME(object). |
Definition at line 230 of file gnc-gobject-utils.c.
00231 { 00232 GHashTable *table; 00233 GList *list; 00234 00235 //printf("Enter %s: name %s\n", G_STRFUNC, name); 00236 table = gnc_gobject_tracking_table(); 00237 list = g_hash_table_lookup(table, name); 00238 //printf("Leave %s: list %p\n", G_STRFUNC, list); 00239 return list; 00240 }
| void gnc_gobject_tracking_remember | ( | GObject * | object, | |
| GObjectClass * | klass | |||
| ) |
Tell gnucash to remember this object in the database.
| object | The object to be tracked. This can be a fully or partially instantiated object. | |
| klass | The class structure for the object. This argument may be NULL if a fully instantiated object is passed in as the first argument. If a partially instantiated object is provided (I.E. a parent class called this function) then this argument is required. This is necessary because the class of the object changes as each of the parent class is instantiated. The class structure, however, status constant and always reflects the fully instantiated object. |
Definition at line 124 of file gnc-gobject-utils.c.
00125 { 00126 GHashTable *table; 00127 GList *list; 00128 const gchar *name; 00129 00130 g_return_if_fail(G_IS_OBJECT(object)); 00131 00132 /* Little dance here to handle startup conditions. During object 00133 * initialization the object type changes as each each parent class 00134 * is initialized. The class passed to the initialization function 00135 * is always the ultimate class of the object. */ 00136 if (klass == NULL) 00137 klass = G_OBJECT_GET_CLASS(object); 00138 name = g_type_name(G_TYPE_FROM_CLASS(klass)); 00139 00140 //printf("Enter %s: object %p of type %s\n", G_STRFUNC, object, name); 00141 table = gnc_gobject_tracking_table(); 00142 list = g_hash_table_lookup(table, name); 00143 00144 if (g_list_index(list, object) != -1) 00145 { 00146 g_critical("Object %p is already in list of %s", object, name); 00147 //printf("Leave %s: already in list\n", G_STRFUNC); 00148 return; 00149 } 00150 00151 list = g_list_append(list, object); 00152 g_hash_table_insert(table, g_strdup(name), list); 00153 00154 g_object_weak_ref(object, gnc_gobject_weak_cb, NULL); 00155 //printf("Leave %s:\n", G_STRFUNC); 00156 }
1.5.7.1