diff --git a/ChangeLog b/ChangeLog index 99d10b8919..a171aa9c62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +2001-08-12 Michael Natterer + + Switched to GObject reference counting: + + * app/core/gimpcontainer.c: only ref(), not ref()/sink() children + of strong containers. Reordered gimp_container_remove() so we + don't need to ref the object while removing it. + + * app/core/gimpcontext.c: misc fixes. Needs to be badly tortured... + + * app/app_procs.c + * app/gdisplay.c + * app/gimprc.c + * app/core/gimp.c + * app/core/gimpbrush.c + * app/core/gimpbrushpipe.c + * app/core/gimpdatafactory.c + * app/core/gimpdocuments.c + * app/core/gimpgradient.c + * app/core/gimpimage.c + * app/core/gimplayer.c + * app/core/gimplist.c + * app/core/gimpobject.c + * app/core/gimpparasite.c + * app/core/gimppattern.c + * app/core/gimpundostack.c + * app/gui/dialogs.c + * app/tools/gimpbezierselecttool.c + * app/tools/gimpfuzzyselecttool.c: changed accordingly: don't + ref()/sink() any more, unref all (??) objects after adding them to + strong containers, misc. minor fixes. + + * app/gui/dialogs-constructors.c + * app/widgets/gimpwidgets.c: use g_object_add_weak_pointer() + instead of simply crashing because g_object_weak_ref() was used + with gtk_widget_destroyed, brrr. + + * app/widgets/gimpdnd.c: removed unneeded g_return_if_fail()'s. + 2001-08-12 Sven Neumann * TODO.xml: fixed an error, updated some numbers and added new items. diff --git a/app/app_procs.c b/app/app_procs.c index 7dd60c98b9..c76edeb7d1 100644 --- a/app/app_procs.c +++ b/app/app_procs.c @@ -101,9 +101,6 @@ app_init (gint gimp_argc, */ the_gimp = gimp_new (); - gtk_object_ref (GTK_OBJECT (the_gimp)); - gtk_object_sink (GTK_OBJECT (the_gimp)); - /* Check if the user's gimp_directory exists */ gimp_dir = gimp_directory (); diff --git a/app/core/gimp-documents.c b/app/core/gimp-documents.c index 4bc454da55..83753e1308 100644 --- a/app/core/gimp-documents.c +++ b/app/core/gimp-documents.c @@ -45,8 +45,6 @@ gimp_documents_init (Gimp *gimp) gimp->documents = gimp_list_new (GIMP_TYPE_IMAGEFILE, GIMP_CONTAINER_POLICY_STRONG); - gtk_object_ref (GTK_OBJECT (gimp->documents)); - gtk_object_sink (GTK_OBJECT (gimp->documents)); } void @@ -151,8 +149,6 @@ gimp_documents_add (Gimp *gimp, imagefile = gimp_imagefile_new (filename); gimp_container_add (gimp->documents, GIMP_OBJECT (imagefile)); - - gtk_object_ref (GTK_OBJECT (imagefile)); - gtk_object_sink (GTK_OBJECT (imagefile)); + g_object_unref (G_OBJECT (imagefile)); } } diff --git a/app/core/gimp-parasites.c b/app/core/gimp-parasites.c index 9b32c0a311..ae3858bf4c 100644 --- a/app/core/gimp-parasites.c +++ b/app/core/gimp-parasites.c @@ -43,9 +43,6 @@ gimp_parasites_init (Gimp *gimp) g_return_if_fail (gimp->parasites == NULL); gimp->parasites = gimp_parasite_list_new (); - - gtk_object_ref (GTK_OBJECT (gimp->parasites)); - gtk_object_sink (GTK_OBJECT (gimp->parasites)); } void diff --git a/app/core/gimp.c b/app/core/gimp.c index 510da59350..5784c5d609 100644 --- a/app/core/gimp.c +++ b/app/core/gimp.c @@ -127,9 +127,6 @@ gimp_init (Gimp *gimp) gimp->images = gimp_list_new (GIMP_TYPE_IMAGE, GIMP_CONTAINER_POLICY_WEAK); - gtk_object_ref (GTK_OBJECT (gimp->images)); - gtk_object_sink (GTK_OBJECT (gimp->images)); - gimp->next_image_ID = 1; gimp->next_guide_ID = 1; gimp->image_table = g_hash_table_new (g_direct_hash, NULL); @@ -140,9 +137,6 @@ gimp_init (Gimp *gimp) gimp->global_buffer = NULL; gimp->named_buffers = gimp_list_new (GIMP_TYPE_BUFFER, GIMP_CONTAINER_POLICY_STRONG); - gtk_object_ref (GTK_OBJECT (gimp->named_buffers)); - gtk_object_sink (GTK_OBJECT (gimp->named_buffers)); - gimp->brush_factory = NULL; gimp->pattern_factory = NULL; gimp->gradient_factory = NULL; @@ -152,8 +146,6 @@ gimp_init (Gimp *gimp) gimp->tool_info_list = gimp_list_new (GIMP_TYPE_TOOL_INFO, GIMP_CONTAINER_POLICY_STRONG); - gtk_object_ref (GTK_OBJECT (gimp->tool_info_list)); - gtk_object_sink (GTK_OBJECT (gimp->tool_info_list)); gimp_documents_init (gimp); @@ -344,7 +336,6 @@ gimp_initialize (Gimp *gimp) static gint n_palette_loader_entries = (sizeof (palette_loader_entries) / sizeof (palette_loader_entries[0])); - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); gimp->brush_factory = @@ -354,8 +345,6 @@ gimp_initialize (Gimp *gimp) n_brush_loader_entries, gimp_brush_new, gimp_brush_get_standard); - gtk_object_ref (GTK_OBJECT (gimp->brush_factory)); - gtk_object_sink (GTK_OBJECT (gimp->brush_factory)); gimp->pattern_factory = gimp_data_factory_new (GIMP_TYPE_PATTERN, @@ -364,8 +353,6 @@ gimp_initialize (Gimp *gimp) n_pattern_loader_entries, gimp_pattern_new, gimp_pattern_get_standard); - gtk_object_ref (GTK_OBJECT (gimp->pattern_factory)); - gtk_object_sink (GTK_OBJECT (gimp->pattern_factory)); gimp->gradient_factory = gimp_data_factory_new (GIMP_TYPE_GRADIENT, @@ -374,8 +361,6 @@ gimp_initialize (Gimp *gimp) n_gradient_loader_entries, gimp_gradient_new, gimp_gradient_get_standard); - gtk_object_ref (GTK_OBJECT (gimp->gradient_factory)); - gtk_object_sink (GTK_OBJECT (gimp->gradient_factory)); gimp->palette_factory = gimp_data_factory_new (GIMP_TYPE_PALETTE, @@ -384,30 +369,32 @@ gimp_initialize (Gimp *gimp) n_palette_loader_entries, gimp_palette_new, gimp_palette_get_standard); - gtk_object_ref (GTK_OBJECT (gimp->palette_factory)); - gtk_object_sink (GTK_OBJECT (gimp->palette_factory)); gimp_image_new_init (gimp); gimp->standard_context = gimp_create_context (gimp, "Standard", NULL); - gtk_object_ref (GTK_OBJECT (gimp->standard_context)); - gtk_object_sink (GTK_OBJECT (gimp->standard_context)); - /* TODO: load from disk */ + /* the default context contains the user's saved preferences + * + * TODO: load from disk + */ context = gimp_create_context (gimp, "Default", NULL); gimp_set_default_context (gimp, context); + g_object_unref (G_OBJECT (context)); + /* the initial user_context is a straight copy of the default context + */ context = gimp_create_context (gimp, "User", context); gimp_set_user_context (gimp, context); gimp_set_current_context (gimp, context); + g_object_unref (G_OBJECT (context)); } void gimp_restore (Gimp *gimp, gboolean no_data) { - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); /* initialize the global parasite table */ @@ -440,7 +427,6 @@ gimp_restore (Gimp *gimp, void gimp_shutdown (Gimp *gimp) { - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); gimp_data_factory_data_save (gimp->brush_factory); @@ -455,7 +441,6 @@ gimp_shutdown (Gimp *gimp) void gimp_set_busy (Gimp *gimp) { - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); /* FIXME: gimp_busy HACK */ @@ -482,7 +467,6 @@ gimp_idle_unset_busy (gpointer data) void gimp_set_busy_until_idle (Gimp *gimp) { - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); if (! gimp->busy_idle_id) @@ -498,7 +482,6 @@ gimp_set_busy_until_idle (Gimp *gimp) void gimp_unset_busy (Gimp *gimp) { - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); if (gimp->gui_unset_busy_func) @@ -517,7 +500,6 @@ gimp_create_image (Gimp *gimp, { GimpImage *gimage; - g_return_val_if_fail (gimp != NULL, NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); gimage = gimp_image_new (gimp, width, height, type); @@ -543,7 +525,6 @@ void gimp_create_display (Gimp *gimp, GimpImage *gimage) { - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); if (gimp->create_display_func) @@ -559,7 +540,6 @@ gimp_open_file (Gimp *gimp, GimpImage *gimage; gint status; - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (filename != NULL); @@ -601,7 +581,6 @@ gimp_create_context (Gimp *gimp, { GimpContext *context; - g_return_val_if_fail (gimp != NULL, NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (!template || GIMP_IS_CONTEXT (template), NULL); @@ -631,7 +610,6 @@ gimp_context_disconnect_callback (GimpContext *context, GimpContext * gimp_get_standard_context (Gimp *gimp) { - g_return_val_if_fail (gimp != NULL, NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); return gimp->standard_context; @@ -641,7 +619,6 @@ void gimp_set_default_context (Gimp *gimp, GimpContext *context) { - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (! context || GIMP_IS_CONTEXT (context)); @@ -654,15 +631,13 @@ gimp_set_default_context (Gimp *gimp, if (gimp->default_context) { - gtk_object_ref (GTK_OBJECT (gimp->default_context)); - gtk_object_sink (GTK_OBJECT (gimp->default_context)); + g_object_ref (G_OBJECT (gimp->default_context)); } } GimpContext * gimp_get_default_context (Gimp *gimp) { - g_return_val_if_fail (gimp != NULL, NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); return gimp->default_context; @@ -672,7 +647,6 @@ void gimp_set_user_context (Gimp *gimp, GimpContext *context) { - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (! context || GIMP_IS_CONTEXT (context)); @@ -685,15 +659,13 @@ gimp_set_user_context (Gimp *gimp, if (gimp->user_context) { - gtk_object_ref (GTK_OBJECT (gimp->user_context)); - gtk_object_sink (GTK_OBJECT (gimp->user_context)); + g_object_ref (G_OBJECT (gimp->user_context)); } } GimpContext * gimp_get_user_context (Gimp *gimp) { - g_return_val_if_fail (gimp != NULL, NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); return gimp->user_context; @@ -703,7 +675,6 @@ void gimp_set_current_context (Gimp *gimp, GimpContext *context) { - g_return_if_fail (gimp != NULL); g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (! context || GIMP_IS_CONTEXT (context)); @@ -723,7 +694,6 @@ gimp_set_current_context (Gimp *gimp, GimpContext * gimp_get_current_context (Gimp *gimp) { - g_return_val_if_fail (gimp != NULL, NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); return gimp->current_context; diff --git a/app/core/gimpbrush-load.c b/app/core/gimpbrush-load.c index b6edc1297f..4ae7616702 100644 --- a/app/core/gimpbrush-load.c +++ b/app/core/gimpbrush-load.c @@ -322,8 +322,6 @@ gimp_brush_get_standard (void) /* set ref_count to 2 --> never swap the standard brush */ g_object_ref (G_OBJECT (standard_brush)); - gtk_object_ref (GTK_OBJECT (standard_brush)); - gtk_object_sink (GTK_OBJECT (standard_brush)); } return GIMP_DATA (standard_brush); diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c index b6edc1297f..4ae7616702 100644 --- a/app/core/gimpbrush.c +++ b/app/core/gimpbrush.c @@ -322,8 +322,6 @@ gimp_brush_get_standard (void) /* set ref_count to 2 --> never swap the standard brush */ g_object_ref (G_OBJECT (standard_brush)); - gtk_object_ref (GTK_OBJECT (standard_brush)); - gtk_object_sink (GTK_OBJECT (standard_brush)); } return GIMP_DATA (standard_brush); diff --git a/app/core/gimpbrushpipe-load.c b/app/core/gimpbrushpipe-load.c index 16176017fd..fd072ea73b 100644 --- a/app/core/gimpbrushpipe-load.c +++ b/app/core/gimpbrushpipe-load.c @@ -321,7 +321,7 @@ gimp_brush_pipe_load (const gchar *filename) g_message (_("Brush pipes should have at least one brush:\n\"%s\""), filename); close (fd); - gtk_object_sink (GTK_OBJECT (pipe)); + g_object_unref (G_OBJECT (pipe)); g_string_free (buffer, TRUE); return NULL; } @@ -401,9 +401,6 @@ gimp_brush_pipe_load (const gchar *filename) if (pipe->brushes[pipe->nbrushes]) { - gtk_object_ref (GTK_OBJECT (pipe->brushes[pipe->nbrushes])); - gtk_object_sink (GTK_OBJECT (pipe->brushes[pipe->nbrushes])); - gimp_object_set_name (GIMP_OBJECT (pipe->brushes[pipe->nbrushes]), NULL); } @@ -412,7 +409,7 @@ gimp_brush_pipe_load (const gchar *filename) g_message (_("Failed to load one of the brushes in the brush pipe\n\"%s\""), filename); close (fd); - gtk_object_sink (GTK_OBJECT (pipe)); + g_object_unref (G_OBJECT (pipe)); return NULL; } diff --git a/app/core/gimpbrushpipe.c b/app/core/gimpbrushpipe.c index 16176017fd..fd072ea73b 100644 --- a/app/core/gimpbrushpipe.c +++ b/app/core/gimpbrushpipe.c @@ -321,7 +321,7 @@ gimp_brush_pipe_load (const gchar *filename) g_message (_("Brush pipes should have at least one brush:\n\"%s\""), filename); close (fd); - gtk_object_sink (GTK_OBJECT (pipe)); + g_object_unref (G_OBJECT (pipe)); g_string_free (buffer, TRUE); return NULL; } @@ -401,9 +401,6 @@ gimp_brush_pipe_load (const gchar *filename) if (pipe->brushes[pipe->nbrushes]) { - gtk_object_ref (GTK_OBJECT (pipe->brushes[pipe->nbrushes])); - gtk_object_sink (GTK_OBJECT (pipe->brushes[pipe->nbrushes])); - gimp_object_set_name (GIMP_OBJECT (pipe->brushes[pipe->nbrushes]), NULL); } @@ -412,7 +409,7 @@ gimp_brush_pipe_load (const gchar *filename) g_message (_("Failed to load one of the brushes in the brush pipe\n\"%s\""), filename); close (fd); - gtk_object_sink (GTK_OBJECT (pipe)); + g_object_unref (G_OBJECT (pipe)); return NULL; } diff --git a/app/core/gimpcontainer.c b/app/core/gimpcontainer.c index 56daed3519..e1a634336f 100644 --- a/app/core/gimpcontainer.c +++ b/app/core/gimpcontainer.c @@ -52,11 +52,13 @@ enum /* local function prototypes */ -static void gimp_container_init (GimpContainer *container); -static void gimp_container_class_init (GimpContainerClass *klass); -static void gimp_container_dispose (GObject *object); -static void gimp_container_disconnect_callback (GimpObject *object, - gpointer data); +static void gimp_container_class_init (GimpContainerClass *klass); +static void gimp_container_init (GimpContainer *container); + +static void gimp_container_dispose (GObject *object); + +static void gimp_container_disconnect_callback (GimpObject *object, + gpointer data); static guint container_signals[LAST_SIGNAL] = { 0 }; @@ -93,18 +95,7 @@ gimp_container_get_type (void) } static void -gimp_container_init (GimpContainer *container) -{ - container->children_type = GIMP_TYPE_OBJECT; - container->policy = GIMP_CONTAINER_POLICY_STRONG; - container->num_children = 0; - - container->handlers = NULL; - container->freeze_count = 0; -} - -static void -gimp_container_class_init (GimpContainerClass* klass) +gimp_container_class_init (GimpContainerClass *klass) { GObjectClass *object_class; @@ -166,13 +157,25 @@ gimp_container_class_init (GimpContainerClass* klass) klass->add = NULL; klass->remove = NULL; klass->reorder = NULL; + klass->freeze = NULL; + klass->thaw = NULL; + klass->have = NULL; klass->foreach = NULL; klass->get_child_by_name = NULL; klass->get_child_by_index = NULL; klass->get_child_index = NULL; - klass->freeze = NULL; - klass->thaw = NULL; +} + +static void +gimp_container_init (GimpContainer *container) +{ + container->children_type = GIMP_TYPE_OBJECT; + container->policy = GIMP_CONTAINER_POLICY_STRONG; + container->num_children = 0; + + container->handlers = NULL; + container->freeze_count = 0; } static void @@ -263,8 +266,7 @@ gimp_container_add (GimpContainer *container, switch (container->policy) { case GIMP_CONTAINER_POLICY_STRONG: - gtk_object_ref (GTK_OBJECT (object)); - gtk_object_sink (GTK_OBJECT (object)); + g_object_ref (G_OBJECT (object)); break; case GIMP_CONTAINER_POLICY_WEAK: @@ -316,7 +318,10 @@ gimp_container_remove (GimpContainer *container, } } - g_object_ref (G_OBJECT (object)); + container->num_children--; + + g_signal_emit (G_OBJECT (container), container_signals[REMOVE], 0, + object); switch (container->policy) { @@ -332,13 +337,6 @@ gimp_container_remove (GimpContainer *container, break; } - container->num_children--; - - g_signal_emit (G_OBJECT (container), container_signals[REMOVE], 0, - object); - - g_object_unref (G_OBJECT (object)); - return TRUE; } diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c index 5677025b46..d218c76511 100644 --- a/app/core/gimpcontext.c +++ b/app/core/gimpcontext.c @@ -357,7 +357,7 @@ gimp_context_class_init (GimpContextClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + GIMP_TYPE_IMAGE); gimp_context_signals[DISPLAY_CHANGED] = g_signal_new (gimp_context_signal_names[DISPLAY_CHANGED], @@ -377,7 +377,7 @@ gimp_context_class_init (GimpContextClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + GIMP_TYPE_TOOL_INFO); gimp_context_signals[FOREGROUND_CHANGED] = g_signal_new (gimp_context_signal_names[FOREGROUND_CHANGED], @@ -427,7 +427,7 @@ gimp_context_class_init (GimpContextClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + GIMP_TYPE_BRUSH); gimp_context_signals[PATTERN_CHANGED] = g_signal_new (gimp_context_signal_names[PATTERN_CHANGED], @@ -437,7 +437,7 @@ gimp_context_class_init (GimpContextClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + GIMP_TYPE_PATTERN); gimp_context_signals[GRADIENT_CHANGED] = g_signal_new (gimp_context_signal_names[GRADIENT_CHANGED], @@ -447,7 +447,7 @@ gimp_context_class_init (GimpContextClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + GIMP_TYPE_GRADIENT); gimp_context_signals[PALETTE_CHANGED] = g_signal_new (gimp_context_signal_names[PALETTE_CHANGED], @@ -457,7 +457,7 @@ gimp_context_class_init (GimpContextClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + GIMP_TYPE_PALETTE); gimp_context_signals[BUFFER_CHANGED] = g_signal_new (gimp_context_signal_names[BUFFER_CHANGED], @@ -467,7 +467,7 @@ gimp_context_class_init (GimpContextClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + GIMP_TYPE_BUFFER); object_class->set_property = gimp_context_set_property; object_class->get_property = gimp_context_get_property; @@ -927,6 +927,7 @@ gimp_context_set_parent (GimpContext *context, g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_if_fail (! parent || GIMP_IS_CONTEXT (parent)); + g_return_if_fail (context != parent); if (context == parent || context->parent == parent) return; @@ -949,14 +950,12 @@ void gimp_context_unset_parent (GimpContext *context) { g_return_if_fail (GIMP_IS_CONTEXT (context)); + g_return_if_fail (GIMP_IS_CONTEXT (context->parent)); - if (context->parent) - { - if (context->defined_props != GIMP_CONTEXT_ALL_PROPS_MASK) - gtk_signal_disconnect_by_data (GTK_OBJECT (context->parent), context); + if (context->defined_props != GIMP_CONTEXT_ALL_PROPS_MASK) + gtk_signal_disconnect_by_data (GTK_OBJECT (context->parent), context); - context->parent = NULL; - } + context->parent = NULL; } /* define / undefinine context properties */ @@ -1097,11 +1096,12 @@ gimp_context_get_by_type (GimpContext *context, GimpObject *object = NULL; g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); - g_return_val_if_fail ((prop = gimp_context_type_to_property (type)) != -1, NULL); + g_return_val_if_fail ((prop = gimp_context_type_to_property (type)) != -1, + NULL); - gtk_object_get (GTK_OBJECT (context), - gimp_context_prop_names[prop], &object, - NULL); + g_object_get (GTK_OBJECT (context), + gimp_context_prop_names[prop], &object, + NULL); return object; } @@ -1116,9 +1116,9 @@ gimp_context_set_by_type (GimpContext *context, g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_if_fail ((prop = gimp_context_type_to_property (type)) != -1); - gtk_object_set (GTK_OBJECT (context), - gimp_context_prop_names[prop], object, - NULL); + g_object_set (GTK_OBJECT (context), + gimp_context_prop_names[prop], object, + NULL); } void @@ -1288,10 +1288,8 @@ void gimp_context_set_tool (GimpContext *context, GimpToolInfo *tool_info) { - g_return_if_fail (! context || GIMP_IS_CONTEXT (context)); - g_return_if_fail (! tool_info || GIMP_IS_TOOL_INFO (tool_info)); - g_return_if_fail (GIMP_IS_CONTEXT (context)); + g_return_if_fail (! tool_info || GIMP_IS_TOOL_INFO (tool_info)); context_find_defined (context, GIMP_CONTEXT_TOOL_MASK); gimp_context_real_set_tool (context, tool_info); @@ -1300,8 +1298,6 @@ gimp_context_set_tool (GimpContext *context, void gimp_context_tool_changed (GimpContext *context) { - g_return_if_fail (! context || GIMP_IS_CONTEXT (context)); - g_return_if_fail (GIMP_IS_CONTEXT (context)); g_signal_emit (G_OBJECT (context), @@ -1328,7 +1324,7 @@ gimp_context_tool_list_thaw (GimpContainer *container, GimpToolInfo *tool_info; if (! context->tool_name) - context->tool_name = g_strdup ("Color Picker"); + context->tool_name = g_strdup ("gimp:rect-select-tool"); if ((tool_info = (GimpToolInfo *) gimp_container_get_child_by_name (container, @@ -1419,7 +1415,7 @@ gimp_context_copy_tool (GimpContext *src, { gimp_context_real_set_tool (dest, src->tool_info); - if ((!src->tool_info || src->tool_info == standard_tool_info) && + if ((! src->tool_info || src->tool_info == standard_tool_info) && src->tool_name) { g_free (dest->tool_name); @@ -1436,7 +1432,6 @@ gimp_context_get_foreground (GimpContext *context, GimpRGB *color) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - g_return_if_fail (color != NULL); *color = context->foreground; @@ -1447,9 +1442,8 @@ gimp_context_set_foreground (GimpContext *context, const GimpRGB *color) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_FOREGROUND_MASK); - g_return_if_fail (color != NULL); + context_find_defined (context, GIMP_CONTEXT_FOREGROUND_MASK); gimp_context_real_set_foreground (context, color); } @@ -1502,9 +1496,8 @@ gimp_context_set_background (GimpContext *context, const GimpRGB *color) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_BACKGROUND_MASK); - g_return_if_fail (color != NULL); + context_find_defined (context, GIMP_CONTEXT_BACKGROUND_MASK); gimp_context_real_set_background (context, color); } @@ -1696,10 +1689,8 @@ void gimp_context_set_brush (GimpContext *context, GimpBrush *brush) { - g_return_if_fail (! context || GIMP_IS_CONTEXT (context)); - g_return_if_fail (! brush || GIMP_IS_BRUSH (brush)); - g_return_if_fail (GIMP_IS_CONTEXT (context)); + g_return_if_fail (! brush || GIMP_IS_BRUSH (brush)); context_find_defined (context, GIMP_CONTEXT_BRUSH_MASK); gimp_context_real_set_brush (context, brush); @@ -1708,8 +1699,6 @@ gimp_context_set_brush (GimpContext *context, void gimp_context_brush_changed (GimpContext *context) { - g_return_if_fail (! context || GIMP_IS_CONTEXT (context)); - g_return_if_fail (GIMP_IS_CONTEXT (context)); g_signal_emit (G_OBJECT (context), @@ -1790,20 +1779,21 @@ gimp_context_real_set_brush (GimpContext *context, context->brush_name = NULL; } - /* make sure the active brush is swapped before we get a new one... */ - if (base_config->stingy_memory_use && - context->brush && context->brush->mask && - G_OBJECT (context->brush)->ref_count == 2) - { - temp_buf_swap (brush->mask); - } - /* disconnect from the old brush's signals */ if (context->brush) { + /* make sure the active brush is swapped before we get a new one... */ + if (base_config->stingy_memory_use && + context->brush->mask && + G_OBJECT (context->brush)->ref_count == 2) + { + temp_buf_swap (context->brush->mask); + } + g_signal_handlers_disconnect_by_func (G_OBJECT (context->brush), gimp_context_brush_dirty, context); + g_object_unref (G_OBJECT (context->brush)); } @@ -1843,7 +1833,7 @@ gimp_context_copy_brush (GimpContext *src, { gimp_context_real_set_brush (dest, src->brush); - if ((!src->brush || src->brush == standard_brush) && src->brush_name) + if ((! src->brush || src->brush == standard_brush) && src->brush_name) { g_free (dest->brush_name); dest->brush_name = g_strdup (src->brush_name); diff --git a/app/core/gimpdatafactory.c b/app/core/gimpdatafactory.c index 81e9ea5251..6782c078f3 100644 --- a/app/core/gimpdatafactory.c +++ b/app/core/gimpdatafactory.c @@ -133,9 +133,6 @@ gimp_data_factory_new (GType data_type, factory->container = gimp_data_list_new (data_type); - gtk_object_ref (GTK_OBJECT (factory->container)); - gtk_object_sink (GTK_OBJECT (factory->container)); - factory->data_path = data_path; factory->loader_entries = loader_entries; @@ -241,6 +238,7 @@ gimp_data_factory_data_new (GimpDataFactory *factory, data = factory->data_new_func (name); gimp_container_add (factory->container, GIMP_OBJECT (data)); + g_object_unref (G_OBJECT (data)); return data; } @@ -296,8 +294,13 @@ gimp_data_factory_data_load_callback (const gchar *filename, data = (GimpData *) (* factory->loader_entries[i].load_func) (filename); if (! data) - g_message (_("Warning: Failed to load data from\n\"%s\""), filename); + { + g_message (_("Warning: Failed to load data from\n\"%s\""), filename); + } else - gimp_container_add (factory->container, GIMP_OBJECT (data)); + { + gimp_container_add (factory->container, GIMP_OBJECT (data)); + g_object_unref (G_OBJECT (data)); + } } } diff --git a/app/core/gimpdocumentlist.c b/app/core/gimpdocumentlist.c index 4bc454da55..83753e1308 100644 --- a/app/core/gimpdocumentlist.c +++ b/app/core/gimpdocumentlist.c @@ -45,8 +45,6 @@ gimp_documents_init (Gimp *gimp) gimp->documents = gimp_list_new (GIMP_TYPE_IMAGEFILE, GIMP_CONTAINER_POLICY_STRONG); - gtk_object_ref (GTK_OBJECT (gimp->documents)); - gtk_object_sink (GTK_OBJECT (gimp->documents)); } void @@ -151,8 +149,6 @@ gimp_documents_add (Gimp *gimp, imagefile = gimp_imagefile_new (filename); gimp_container_add (gimp->documents, GIMP_OBJECT (imagefile)); - - gtk_object_ref (GTK_OBJECT (imagefile)); - gtk_object_sink (GTK_OBJECT (imagefile)); + g_object_unref (G_OBJECT (imagefile)); } } diff --git a/app/core/gimpdocuments.c b/app/core/gimpdocuments.c index 4bc454da55..83753e1308 100644 --- a/app/core/gimpdocuments.c +++ b/app/core/gimpdocuments.c @@ -45,8 +45,6 @@ gimp_documents_init (Gimp *gimp) gimp->documents = gimp_list_new (GIMP_TYPE_IMAGEFILE, GIMP_CONTAINER_POLICY_STRONG); - gtk_object_ref (GTK_OBJECT (gimp->documents)); - gtk_object_sink (GTK_OBJECT (gimp->documents)); } void @@ -151,8 +149,6 @@ gimp_documents_add (Gimp *gimp, imagefile = gimp_imagefile_new (filename); gimp_container_add (gimp->documents, GIMP_OBJECT (imagefile)); - - gtk_object_ref (GTK_OBJECT (imagefile)); - gtk_object_sink (GTK_OBJECT (imagefile)); + g_object_unref (G_OBJECT (imagefile)); } } diff --git a/app/core/gimpgradient.c b/app/core/gimpgradient.c index 7473201cb2..4f9ca4a2a6 100644 --- a/app/core/gimpgradient.c +++ b/app/core/gimpgradient.c @@ -282,8 +282,7 @@ gimp_gradient_get_standard (void) { standard_gradient = GIMP_GRADIENT (gimp_gradient_new ("Standard")); - gtk_object_ref (GTK_OBJECT (standard_gradient)); - gtk_object_sink (GTK_OBJECT (standard_gradient)); + g_object_ref (G_OBJECT (standard_gradient)); } return GIMP_DATA (standard_gradient); diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index 83b0b62d88..40c234ca76 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -3605,6 +3605,7 @@ gimp_image_add_layer (GimpImage *gimage, } gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position); + g_object_unref (G_OBJECT (layer)); /* notify the layers dialog of the currently active layer */ gimp_image_set_active_layer (gimage, layer); @@ -3801,6 +3802,7 @@ gimp_image_add_channel (GimpImage *gimage, /* add the channel to the list */ gimp_container_add (gimage->channels, GIMP_OBJECT (channel)); + g_object_unref (G_OBJECT (channel)); /* notify this gimage of the currently active channel */ gimp_image_set_active_channel (gimage, channel); diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index 83b0b62d88..40c234ca76 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -3605,6 +3605,7 @@ gimp_image_add_layer (GimpImage *gimage, } gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position); + g_object_unref (G_OBJECT (layer)); /* notify the layers dialog of the currently active layer */ gimp_image_set_active_layer (gimage, layer); @@ -3801,6 +3802,7 @@ gimp_image_add_channel (GimpImage *gimage, /* add the channel to the list */ gimp_container_add (gimage->channels, GIMP_OBJECT (channel)); + g_object_unref (G_OBJECT (channel)); /* notify this gimage of the currently active channel */ gimp_image_set_active_channel (gimage, channel); diff --git a/app/core/gimpimage-projection.c b/app/core/gimpimage-projection.c index 83b0b62d88..40c234ca76 100644 --- a/app/core/gimpimage-projection.c +++ b/app/core/gimpimage-projection.c @@ -3605,6 +3605,7 @@ gimp_image_add_layer (GimpImage *gimage, } gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position); + g_object_unref (G_OBJECT (layer)); /* notify the layers dialog of the currently active layer */ gimp_image_set_active_layer (gimage, layer); @@ -3801,6 +3802,7 @@ gimp_image_add_channel (GimpImage *gimage, /* add the channel to the list */ gimp_container_add (gimage->channels, GIMP_OBJECT (channel)); + g_object_unref (G_OBJECT (channel)); /* notify this gimage of the currently active channel */ gimp_image_set_active_channel (gimage, channel); diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index 83b0b62d88..40c234ca76 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -3605,6 +3605,7 @@ gimp_image_add_layer (GimpImage *gimage, } gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position); + g_object_unref (G_OBJECT (layer)); /* notify the layers dialog of the currently active layer */ gimp_image_set_active_layer (gimage, layer); @@ -3801,6 +3802,7 @@ gimp_image_add_channel (GimpImage *gimage, /* add the channel to the list */ gimp_container_add (gimage->channels, GIMP_OBJECT (channel)); + g_object_unref (G_OBJECT (channel)); /* notify this gimage of the currently active channel */ gimp_image_set_active_channel (gimage, channel); diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index 83b0b62d88..40c234ca76 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -3605,6 +3605,7 @@ gimp_image_add_layer (GimpImage *gimage, } gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position); + g_object_unref (G_OBJECT (layer)); /* notify the layers dialog of the currently active layer */ gimp_image_set_active_layer (gimage, layer); @@ -3801,6 +3802,7 @@ gimp_image_add_channel (GimpImage *gimage, /* add the channel to the list */ gimp_container_add (gimage->channels, GIMP_OBJECT (channel)); + g_object_unref (G_OBJECT (channel)); /* notify this gimage of the currently active channel */ gimp_image_set_active_channel (gimage, channel); diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 83b0b62d88..40c234ca76 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -3605,6 +3605,7 @@ gimp_image_add_layer (GimpImage *gimage, } gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position); + g_object_unref (G_OBJECT (layer)); /* notify the layers dialog of the currently active layer */ gimp_image_set_active_layer (gimage, layer); @@ -3801,6 +3802,7 @@ gimp_image_add_channel (GimpImage *gimage, /* add the channel to the list */ gimp_container_add (gimage->channels, GIMP_OBJECT (channel)); + g_object_unref (G_OBJECT (channel)); /* notify this gimage of the currently active channel */ gimp_image_set_active_channel (gimage, channel); diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c index a089483026..6ca9bb8098 100644 --- a/app/core/gimplayer.c +++ b/app/core/gimplayer.c @@ -415,9 +415,6 @@ gimp_layer_copy (GimpLayer *layer, { new_layer->mask = gimp_layer_mask_copy (layer->mask); - gtk_object_ref (GTK_OBJECT (new_layer->mask)); - gtk_object_sink (GTK_OBJECT (new_layer->mask)); - gimp_layer_mask_set_layer (new_layer->mask, new_layer); } @@ -552,9 +549,6 @@ gimp_layer_add_mask (GimpLayer *layer, layer->mask = mask; - gtk_object_ref (GTK_OBJECT (layer->mask)); - gtk_object_sink (GTK_OBJECT (layer->mask)); - gimp_layer_mask_set_layer (mask, layer); gimp_drawable_update (GIMP_DRAWABLE (layer), diff --git a/app/core/gimplist.c b/app/core/gimplist.c index 804781c437..86a483186b 100644 --- a/app/core/gimplist.c +++ b/app/core/gimplist.c @@ -32,7 +32,9 @@ static void gimp_list_class_init (GimpListClass *klass); static void gimp_list_init (GimpList *list); + static void gimp_list_dispose (GObject *object); + static void gimp_list_add (GimpContainer *container, GimpObject *object); static void gimp_list_remove (GimpContainer *container, diff --git a/app/core/gimpobject.c b/app/core/gimpobject.c index e91b5fae24..3a24795745 100644 --- a/app/core/gimpobject.c +++ b/app/core/gimpobject.c @@ -122,6 +122,7 @@ gimp_object_class_init (GimpObjectClass *klass) object_class->set_property = gimp_object_set_property; object_class->get_property = gimp_object_get_property; + klass->disconnect = NULL; klass->name_changed = NULL; g_object_class_install_property (object_class, @@ -141,7 +142,18 @@ gimp_object_init (GimpObject *object) static void gimp_object_dispose (GObject *object) { - g_signal_emit (G_OBJECT (object), object_signals[DISCONNECT], 0); + gboolean disconnected; + + disconnected = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (object), + "disconnected")); + + if (! disconnected) + { + g_signal_emit (G_OBJECT (object), object_signals[DISCONNECT], 0); + + g_object_set_data (G_OBJECT (object), "disconnected", + GINT_TO_POINTER (TRUE)); + } G_OBJECT_CLASS (parent_class)->dispose (object); } diff --git a/app/core/gimpparasite.c b/app/core/gimpparasite.c index 9b32c0a311..ae3858bf4c 100644 --- a/app/core/gimpparasite.c +++ b/app/core/gimpparasite.c @@ -43,9 +43,6 @@ gimp_parasites_init (Gimp *gimp) g_return_if_fail (gimp->parasites == NULL); gimp->parasites = gimp_parasite_list_new (); - - gtk_object_ref (GTK_OBJECT (gimp->parasites)); - gtk_object_sink (GTK_OBJECT (gimp->parasites)); } void diff --git a/app/core/gimppattern-load.c b/app/core/gimppattern-load.c index c6f64303a3..376ba73808 100644 --- a/app/core/gimppattern-load.c +++ b/app/core/gimppattern-load.c @@ -250,9 +250,7 @@ gimp_pattern_get_standard (void) } /* set ref_count to 2 --> never swap the standard pattern */ - gtk_object_ref (GTK_OBJECT (standard_pattern)); - gtk_object_ref (GTK_OBJECT (standard_pattern)); - gtk_object_sink (GTK_OBJECT (standard_pattern)); + g_object_ref (G_OBJECT (standard_pattern)); } return GIMP_DATA (standard_pattern); diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c index c6f64303a3..376ba73808 100644 --- a/app/core/gimppattern.c +++ b/app/core/gimppattern.c @@ -250,9 +250,7 @@ gimp_pattern_get_standard (void) } /* set ref_count to 2 --> never swap the standard pattern */ - gtk_object_ref (GTK_OBJECT (standard_pattern)); - gtk_object_ref (GTK_OBJECT (standard_pattern)); - gtk_object_sink (GTK_OBJECT (standard_pattern)); + g_object_ref (G_OBJECT (standard_pattern)); } return GIMP_DATA (standard_pattern); diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index 83b0b62d88..40c234ca76 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -3605,6 +3605,7 @@ gimp_image_add_layer (GimpImage *gimage, } gimp_container_insert (gimage->layers, GIMP_OBJECT (layer), position); + g_object_unref (G_OBJECT (layer)); /* notify the layers dialog of the currently active layer */ gimp_image_set_active_layer (gimage, layer); @@ -3801,6 +3802,7 @@ gimp_image_add_channel (GimpImage *gimage, /* add the channel to the list */ gimp_container_add (gimage->channels, GIMP_OBJECT (channel)); + g_object_unref (G_OBJECT (channel)); /* notify this gimage of the currently active channel */ gimp_image_set_active_channel (gimage, channel); diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index df7426685d..25fa6d8b61 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -266,8 +266,7 @@ gdisplay_new (GimpImage *gimage, gimage->instance_count++; /* this is obsolete */ gimage->disp_count++; - gtk_object_ref (GTK_OBJECT (gimage)); - gtk_object_sink (GTK_OBJECT (gimage)); + g_object_ref (G_OBJECT (gimage)); /* We're interested in clean and dirty signals so we can update the * title if need be. @@ -490,7 +489,7 @@ gdisplay_delete (GDisplay *gdisp) gdk_drawable_unref (gdisp->icon); gdk_drawable_unref (gdisp->iconmask); - gtk_widget_unref (gdisp->shell); + gtk_widget_destroy (gdisp->shell); g_free (gdisp); } diff --git a/app/core/gimpundostack.c b/app/core/gimpundostack.c index e3706c595a..f9e8330886 100644 --- a/app/core/gimpundostack.c +++ b/app/core/gimpundostack.c @@ -92,9 +92,7 @@ gimp_undo_stack_init (GimpUndoStack *stack) undos = gimp_list_new (GIMP_TYPE_UNDO, GIMP_CONTAINER_POLICY_STRONG); - stack->undos = undos; - gtk_object_ref (GTK_OBJECT (undos)); - gtk_object_sink (GTK_OBJECT (undos)); + stack->undos = undos; g_signal_connect (G_OBJECT (undos), "add", G_CALLBACK (gimp_undo_stack_add_callback), @@ -146,6 +144,7 @@ gimp_undo_stack_push (GimpUndoStack *stack, gimp_undo_push (undo, stack->gimage); gimp_container_add (GIMP_CONTAINER (stack->undos), GIMP_OBJECT (undo)); + g_object_unref (G_OBJECT (undo)); } GimpUndo * diff --git a/app/dialogs/dialogs-constructors.c b/app/dialogs/dialogs-constructors.c index 592de6f0cb..311598a3e1 100644 --- a/app/dialogs/dialogs-constructors.c +++ b/app/dialogs/dialogs-constructors.c @@ -704,9 +704,7 @@ dialogs_path_list_view_new (GimpDialogFactory *factory, view = paths_dialog_create (); - g_object_weak_ref (G_OBJECT (view), - (GDestroyNotify) gtk_widget_destroyed, - &view); + g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view); dockable = dialogs_dockable_new (view, "Path List", "Paths", @@ -777,9 +775,7 @@ dialogs_error_console_get (GimpDialogFactory *factory, view = error_console_create (); - g_object_weak_ref (G_OBJECT (view), - (GDestroyNotify) gtk_widget_destroyed, - &view); + g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view); dockable = dialogs_dockable_new (view, "Error Console", "Errors", diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c index 1c7c754f10..165d39d0f8 100644 --- a/app/dialogs/dialogs.c +++ b/app/dialogs/dialogs.c @@ -103,15 +103,11 @@ dialogs_init (Gimp *gimp) gimp_get_user_context (gimp), NULL, NULL); - gtk_object_ref (GTK_OBJECT (global_dialog_factory)); - gtk_object_sink (GTK_OBJECT (global_dialog_factory)); global_dock_factory = gimp_dialog_factory_new ("dock", gimp_get_user_context (gimp), menus_get_dialogs_factory (), dialogs_dock_new); - gtk_object_ref (GTK_OBJECT (global_dock_factory)); - gtk_object_sink (GTK_OBJECT (global_dock_factory)); for (i = 0; i < n_toplevel_entries; i++) gimp_dialog_factory_register_entry (global_dialog_factory, diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index df7426685d..25fa6d8b61 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -266,8 +266,7 @@ gdisplay_new (GimpImage *gimage, gimage->instance_count++; /* this is obsolete */ gimage->disp_count++; - gtk_object_ref (GTK_OBJECT (gimage)); - gtk_object_sink (GTK_OBJECT (gimage)); + g_object_ref (G_OBJECT (gimage)); /* We're interested in clean and dirty signals so we can update the * title if need be. @@ -490,7 +489,7 @@ gdisplay_delete (GDisplay *gdisp) gdk_drawable_unref (gdisp->icon); gdk_drawable_unref (gdisp->iconmask); - gtk_widget_unref (gdisp->shell); + gtk_widget_destroy (gdisp->shell); g_free (gdisp); } diff --git a/app/gdisplay.c b/app/gdisplay.c index df7426685d..25fa6d8b61 100644 --- a/app/gdisplay.c +++ b/app/gdisplay.c @@ -266,8 +266,7 @@ gdisplay_new (GimpImage *gimage, gimage->instance_count++; /* this is obsolete */ gimage->disp_count++; - gtk_object_ref (GTK_OBJECT (gimage)); - gtk_object_sink (GTK_OBJECT (gimage)); + g_object_ref (G_OBJECT (gimage)); /* We're interested in clean and dirty signals so we can update the * title if need be. @@ -490,7 +489,7 @@ gdisplay_delete (GDisplay *gdisp) gdk_drawable_unref (gdisp->icon); gdk_drawable_unref (gdisp->iconmask); - gtk_widget_unref (gdisp->shell); + gtk_widget_destroy (gdisp->shell); g_free (gdisp); } diff --git a/app/gimprc.c b/app/gimprc.c index 18c201023b..2d820a31ed 100644 --- a/app/gimprc.c +++ b/app/gimprc.c @@ -2844,9 +2844,6 @@ parse_document (gpointer val1p, GIMP_LIST (the_gimp->documents)->list = g_list_append (GIMP_LIST (the_gimp->documents)->list, imagefile); - gtk_object_ref (GTK_OBJECT (imagefile)); - gtk_object_sink (GTK_OBJECT (imagefile)); - the_gimp->documents->num_children++; return OK; diff --git a/app/gui/dialogs-constructors.c b/app/gui/dialogs-constructors.c index 592de6f0cb..311598a3e1 100644 --- a/app/gui/dialogs-constructors.c +++ b/app/gui/dialogs-constructors.c @@ -704,9 +704,7 @@ dialogs_path_list_view_new (GimpDialogFactory *factory, view = paths_dialog_create (); - g_object_weak_ref (G_OBJECT (view), - (GDestroyNotify) gtk_widget_destroyed, - &view); + g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view); dockable = dialogs_dockable_new (view, "Path List", "Paths", @@ -777,9 +775,7 @@ dialogs_error_console_get (GimpDialogFactory *factory, view = error_console_create (); - g_object_weak_ref (G_OBJECT (view), - (GDestroyNotify) gtk_widget_destroyed, - &view); + g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view); dockable = dialogs_dockable_new (view, "Error Console", "Errors", diff --git a/app/gui/dialogs.c b/app/gui/dialogs.c index 1c7c754f10..165d39d0f8 100644 --- a/app/gui/dialogs.c +++ b/app/gui/dialogs.c @@ -103,15 +103,11 @@ dialogs_init (Gimp *gimp) gimp_get_user_context (gimp), NULL, NULL); - gtk_object_ref (GTK_OBJECT (global_dialog_factory)); - gtk_object_sink (GTK_OBJECT (global_dialog_factory)); global_dock_factory = gimp_dialog_factory_new ("dock", gimp_get_user_context (gimp), menus_get_dialogs_factory (), dialogs_dock_new); - gtk_object_ref (GTK_OBJECT (global_dock_factory)); - gtk_object_sink (GTK_OBJECT (global_dock_factory)); for (i = 0; i < n_toplevel_entries; i++) gimp_dialog_factory_register_entry (global_dialog_factory, diff --git a/app/tools/gimpbezierselecttool.c b/app/tools/gimpbezierselecttool.c index 325d53cea5..cc80b4d5f7 100644 --- a/app/tools/gimpbezierselecttool.c +++ b/app/tools/gimpbezierselecttool.c @@ -1075,7 +1075,10 @@ bezier_select_reset (GimpBezierSelectTool *bezier_sel) } if (bezier_sel->mask) - g_object_unref (G_OBJECT (bezier_sel->mask)); + { + g_object_unref (G_OBJECT (bezier_sel->mask)); + bezier_sel->mask = NULL; + } bezier_sel->state = BEZIER_START; /* we are starting the curve */ bezier_sel->draw_mode = BEZIER_DRAW_ALL; /* draw everything by default */ @@ -2898,9 +2901,6 @@ bezier_convert (GimpBezierSelectTool *bezier_sel, gdisp->gimage->width, gdisp->gimage->height); - gtk_object_ref (GTK_OBJECT (bezier_sel->mask)); - gtk_object_sink (GTK_OBJECT (bezier_sel->mask)); - /* allocate room for the scanlines */ bezier_sel->scanlines = g_malloc (sizeof (GSList *) * height); diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c index 70d1272d4f..302662adf0 100644 --- a/app/tools/gimpfuzzyselecttool.c +++ b/app/tools/gimpfuzzyselecttool.c @@ -647,9 +647,6 @@ fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, fuzzy_mask = new; - gtk_object_ref (GTK_OBJECT (fuzzy_mask)); - gtk_object_sink (GTK_OBJECT (fuzzy_mask)); - /* calculate and allocate a new XSegment array which represents the boundary * of the color-contiguous region */ diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c index 70d1272d4f..302662adf0 100644 --- a/app/tools/gimpregionselecttool.c +++ b/app/tools/gimpregionselecttool.c @@ -647,9 +647,6 @@ fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, fuzzy_mask = new; - gtk_object_ref (GTK_OBJECT (fuzzy_mask)); - gtk_object_sink (GTK_OBJECT (fuzzy_mask)); - /* calculate and allocate a new XSegment array which represents the boundary * of the color-contiguous region */ diff --git a/app/widgets/gimpdnd.c b/app/widgets/gimpdnd.c index d67be9f496..3a0afdd6c7 100644 --- a/app/widgets/gimpdnd.c +++ b/app/widgets/gimpdnd.c @@ -959,7 +959,6 @@ gimp_gtk_drag_source_set_by_type (GtkWidget *widget, { GimpDndDataType dnd_type; - g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); dnd_type = gimp_dnd_data_type_get_by_gtk_type (type); @@ -981,7 +980,6 @@ gimp_gtk_drag_dest_set_by_type (GtkWidget *widget, { GimpDndDataType dnd_type; - g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); dnd_type = gimp_dnd_data_type_get_by_gtk_type (type); @@ -1003,7 +1001,6 @@ gimp_dnd_viewable_source_set (GtkWidget *widget, { GimpDndDataType dnd_type; - g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (get_viewable_func != NULL); @@ -1023,7 +1020,6 @@ gimp_dnd_viewable_source_unset (GtkWidget *widget, { GimpDndDataType dnd_type; - g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); dnd_type = gimp_dnd_data_type_get_by_gtk_type (type); @@ -1042,7 +1038,6 @@ gimp_dnd_viewable_dest_set (GtkWidget *widget, { GimpDndDataType dnd_type; - g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (set_viewable_func != NULL); @@ -1062,7 +1057,6 @@ gimp_dnd_viewable_dest_unset (GtkWidget *widget, { GimpDndDataType dnd_type; - g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); dnd_type = gimp_dnd_data_type_get_by_gtk_type (type); @@ -1080,7 +1074,6 @@ gimp_dnd_get_drag_data (GtkWidget *widget) GimpDndDragViewableFunc get_data_func; gpointer get_data_data; - g_return_val_if_fail (widget != NULL, NULL); g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); data_type = diff --git a/app/widgets/gimppreview.c b/app/widgets/gimppreview.c index 05c97f22e0..338a253cda 100644 --- a/app/widgets/gimppreview.c +++ b/app/widgets/gimppreview.c @@ -377,9 +377,8 @@ gimp_preview_set_viewable (GimpPreview *preview, G_TYPE_FROM_INSTANCE (preview->viewable)); } - g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable), - G_CALLBACK (gtk_widget_destroyed), - &preview->viewable); + g_object_remove_weak_pointer (G_OBJECT (preview->viewable), + (gpointer *) &preview->viewable); g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable), G_CALLBACK (gimp_preview_paint), @@ -407,9 +406,8 @@ gimp_preview_set_viewable (GimpPreview *preview, NULL); } - g_object_weak_ref (G_OBJECT (preview->viewable), - (GWeakNotify) gtk_widget_destroyed, - &preview->viewable); + g_object_add_weak_pointer (G_OBJECT (preview->viewable), + (gpointer *) &preview->viewable); g_signal_connect_swapped (G_OBJECT (preview->viewable), "invalidate_preview", diff --git a/app/widgets/gimppreviewrenderer.c b/app/widgets/gimppreviewrenderer.c index 05c97f22e0..338a253cda 100644 --- a/app/widgets/gimppreviewrenderer.c +++ b/app/widgets/gimppreviewrenderer.c @@ -377,9 +377,8 @@ gimp_preview_set_viewable (GimpPreview *preview, G_TYPE_FROM_INSTANCE (preview->viewable)); } - g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable), - G_CALLBACK (gtk_widget_destroyed), - &preview->viewable); + g_object_remove_weak_pointer (G_OBJECT (preview->viewable), + (gpointer *) &preview->viewable); g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable), G_CALLBACK (gimp_preview_paint), @@ -407,9 +406,8 @@ gimp_preview_set_viewable (GimpPreview *preview, NULL); } - g_object_weak_ref (G_OBJECT (preview->viewable), - (GWeakNotify) gtk_widget_destroyed, - &preview->viewable); + g_object_add_weak_pointer (G_OBJECT (preview->viewable), + (gpointer *) &preview->viewable); g_signal_connect_swapped (G_OBJECT (preview->viewable), "invalidate_preview", diff --git a/app/widgets/gimpview.c b/app/widgets/gimpview.c index 05c97f22e0..338a253cda 100644 --- a/app/widgets/gimpview.c +++ b/app/widgets/gimpview.c @@ -377,9 +377,8 @@ gimp_preview_set_viewable (GimpPreview *preview, G_TYPE_FROM_INSTANCE (preview->viewable)); } - g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable), - G_CALLBACK (gtk_widget_destroyed), - &preview->viewable); + g_object_remove_weak_pointer (G_OBJECT (preview->viewable), + (gpointer *) &preview->viewable); g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable), G_CALLBACK (gimp_preview_paint), @@ -407,9 +406,8 @@ gimp_preview_set_viewable (GimpPreview *preview, NULL); } - g_object_weak_ref (G_OBJECT (preview->viewable), - (GWeakNotify) gtk_widget_destroyed, - &preview->viewable); + g_object_add_weak_pointer (G_OBJECT (preview->viewable), + (gpointer *) &preview->viewable); g_signal_connect_swapped (G_OBJECT (preview->viewable), "invalidate_preview", diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c index 05c97f22e0..338a253cda 100644 --- a/app/widgets/gimpviewrenderer.c +++ b/app/widgets/gimpviewrenderer.c @@ -377,9 +377,8 @@ gimp_preview_set_viewable (GimpPreview *preview, G_TYPE_FROM_INSTANCE (preview->viewable)); } - g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable), - G_CALLBACK (gtk_widget_destroyed), - &preview->viewable); + g_object_remove_weak_pointer (G_OBJECT (preview->viewable), + (gpointer *) &preview->viewable); g_signal_handlers_disconnect_by_func (G_OBJECT (preview->viewable), G_CALLBACK (gimp_preview_paint), @@ -407,9 +406,8 @@ gimp_preview_set_viewable (GimpPreview *preview, NULL); } - g_object_weak_ref (G_OBJECT (preview->viewable), - (GWeakNotify) gtk_widget_destroyed, - &preview->viewable); + g_object_add_weak_pointer (G_OBJECT (preview->viewable), + (gpointer *) &preview->viewable); g_signal_connect_swapped (G_OBJECT (preview->viewable), "invalidate_preview",