diff --git a/ChangeLog b/ChangeLog index 8257eb4c1e..7bdee61357 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +Sun Jan 23 14:33:57 CET 2000 Sven Neumann + + * app/gdisplay.c + * app/gdisplay_ops.c + * app/gimage.c + * app/gimpimage.c + * app/gimpimageP.h: Renamed gimage->ref_count to disp_count and + slightly changed the way it is used. As the new name suggests it + is only used to count the number of displays associated with an + image. It is now impossible to delete an image that has an + associated display. You have to delete the display instead. Before + this change it was possible to delete an image through the PDB that + was created through the UI and bad things happened soon... + + * app/gimage_cmds.c + * tools/pdbgen/pdb/gimage.pdb: Changed the help for gimp_image_delete + so it explains better what actually happens. The old help was quite + misleading. + Sat Jan 22 22:14:18 GMT 2000 Austin Donnelly * MAINTAINERS: update my entry. diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index a2afadf7c9..524f846bac 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -165,10 +165,10 @@ gimp_image_init (GimpImage *gimage) gimage->has_filename = FALSE; gimage->num_cols = 0; gimage->cmap = NULL; - /* ID and ref_count handled in gimage.c */ + gimage->disp_count = 0; gimage->instance_count = 0; gimage->shadow = NULL; - gimage->dirty = 1; + gimage->dirty = 1; /* Why is that? I doubt this is correct. --Sven */ gimage->undo_on = TRUE; gimage->construct_flag = -1; gimage->tattoo_state = 0; @@ -2868,7 +2868,7 @@ gimp_image_remove_layer_mask (GimpImage *gimage, /* Push the undo--Important to do it here, AFTER the call * to layer_apply_mask, in case the undo push fails and the - * mask is delete : NULL)d + * mask is deleted */ undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu); diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index a2afadf7c9..524f846bac 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -165,10 +165,10 @@ gimp_image_init (GimpImage *gimage) gimage->has_filename = FALSE; gimage->num_cols = 0; gimage->cmap = NULL; - /* ID and ref_count handled in gimage.c */ + gimage->disp_count = 0; gimage->instance_count = 0; gimage->shadow = NULL; - gimage->dirty = 1; + gimage->dirty = 1; /* Why is that? I doubt this is correct. --Sven */ gimage->undo_on = TRUE; gimage->construct_flag = -1; gimage->tattoo_state = 0; @@ -2868,7 +2868,7 @@ gimp_image_remove_layer_mask (GimpImage *gimage, /* Push the undo--Important to do it here, AFTER the call * to layer_apply_mask, in case the undo push fails and the - * mask is delete : NULL)d + * mask is deleted */ undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu); diff --git a/app/core/gimpimage-projection.c b/app/core/gimpimage-projection.c index a2afadf7c9..524f846bac 100644 --- a/app/core/gimpimage-projection.c +++ b/app/core/gimpimage-projection.c @@ -165,10 +165,10 @@ gimp_image_init (GimpImage *gimage) gimage->has_filename = FALSE; gimage->num_cols = 0; gimage->cmap = NULL; - /* ID and ref_count handled in gimage.c */ + gimage->disp_count = 0; gimage->instance_count = 0; gimage->shadow = NULL; - gimage->dirty = 1; + gimage->dirty = 1; /* Why is that? I doubt this is correct. --Sven */ gimage->undo_on = TRUE; gimage->construct_flag = -1; gimage->tattoo_state = 0; @@ -2868,7 +2868,7 @@ gimp_image_remove_layer_mask (GimpImage *gimage, /* Push the undo--Important to do it here, AFTER the call * to layer_apply_mask, in case the undo push fails and the - * mask is delete : NULL)d + * mask is deleted */ undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu); diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index a2afadf7c9..524f846bac 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -165,10 +165,10 @@ gimp_image_init (GimpImage *gimage) gimage->has_filename = FALSE; gimage->num_cols = 0; gimage->cmap = NULL; - /* ID and ref_count handled in gimage.c */ + gimage->disp_count = 0; gimage->instance_count = 0; gimage->shadow = NULL; - gimage->dirty = 1; + gimage->dirty = 1; /* Why is that? I doubt this is correct. --Sven */ gimage->undo_on = TRUE; gimage->construct_flag = -1; gimage->tattoo_state = 0; @@ -2868,7 +2868,7 @@ gimp_image_remove_layer_mask (GimpImage *gimage, /* Push the undo--Important to do it here, AFTER the call * to layer_apply_mask, in case the undo push fails and the - * mask is delete : NULL)d + * mask is deleted */ undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu); diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index a2afadf7c9..524f846bac 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -165,10 +165,10 @@ gimp_image_init (GimpImage *gimage) gimage->has_filename = FALSE; gimage->num_cols = 0; gimage->cmap = NULL; - /* ID and ref_count handled in gimage.c */ + gimage->disp_count = 0; gimage->instance_count = 0; gimage->shadow = NULL; - gimage->dirty = 1; + gimage->dirty = 1; /* Why is that? I doubt this is correct. --Sven */ gimage->undo_on = TRUE; gimage->construct_flag = -1; gimage->tattoo_state = 0; @@ -2868,7 +2868,7 @@ gimp_image_remove_layer_mask (GimpImage *gimage, /* Push the undo--Important to do it here, AFTER the call * to layer_apply_mask, in case the undo push fails and the - * mask is delete : NULL)d + * mask is deleted */ undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu); diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index a2afadf7c9..524f846bac 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -165,10 +165,10 @@ gimp_image_init (GimpImage *gimage) gimage->has_filename = FALSE; gimage->num_cols = 0; gimage->cmap = NULL; - /* ID and ref_count handled in gimage.c */ + gimage->disp_count = 0; gimage->instance_count = 0; gimage->shadow = NULL; - gimage->dirty = 1; + gimage->dirty = 1; /* Why is that? I doubt this is correct. --Sven */ gimage->undo_on = TRUE; gimage->construct_flag = -1; gimage->tattoo_state = 0; @@ -2868,7 +2868,7 @@ gimp_image_remove_layer_mask (GimpImage *gimage, /* Push the undo--Important to do it here, AFTER the call * to layer_apply_mask, in case the undo push fails and the - * mask is delete : NULL)d + * mask is deleted */ undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu); diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index a2afadf7c9..524f846bac 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -165,10 +165,10 @@ gimp_image_init (GimpImage *gimage) gimage->has_filename = FALSE; gimage->num_cols = 0; gimage->cmap = NULL; - /* ID and ref_count handled in gimage.c */ + gimage->disp_count = 0; gimage->instance_count = 0; gimage->shadow = NULL; - gimage->dirty = 1; + gimage->dirty = 1; /* Why is that? I doubt this is correct. --Sven */ gimage->undo_on = TRUE; gimage->construct_flag = -1; gimage->tattoo_state = 0; @@ -2868,7 +2868,7 @@ gimp_image_remove_layer_mask (GimpImage *gimage, /* Push the undo--Important to do it here, AFTER the call * to layer_apply_mask, in case the undo push fails and the - * mask is delete : NULL)d + * mask is deleted */ undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu); diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index be2059c4ad..6686b4c852 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -161,17 +161,17 @@ gdisplay_new (GimpImage *gimage, /* set the current tool cursor */ gdisplay_install_tool_cursor (gdisp, default_gdisplay_cursor); - gimage->instance_count++; - gimage->ref_count++; + gimage->instance_count++; /* this is obsolete */ + gimage->disp_count++; lc_dialog_preview_update(gimage); /* We're interested in clean and dirty signals so we can update the * title if need be. */ gtk_signal_connect (GTK_OBJECT (gimage), "dirty", - GTK_SIGNAL_FUNC(gdisplay_cleandirty_handler), gdisp); + GTK_SIGNAL_FUNC (gdisplay_cleandirty_handler), gdisp); gtk_signal_connect (GTK_OBJECT (gimage), "clean", - GTK_SIGNAL_FUNC(gdisplay_cleandirty_handler), gdisp); + GTK_SIGNAL_FUNC (gdisplay_cleandirty_handler), gdisp); return gdisp; } @@ -363,13 +363,14 @@ gdisplay_delete (GDisplay *gdisp) info_window_free (gdisp->window_info_dialog); /* Remove navigation dialog */ - nav_window_free(gdisp,gdisp->window_nav_dialog); + nav_window_free (gdisp, gdisp->window_nav_dialog); /* free the gimage */ + gdisp->gimage->disp_count--; gimage_delete (gdisp->gimage); if (gdisp->nav_popup) - nav_popup_free(gdisp->nav_popup); + nav_popup_free (gdisp->nav_popup); gtk_widget_unref (gdisp->shell); @@ -2176,9 +2177,9 @@ gdisplays_check_valid (GDisplay *gtest, while (list) { gdisp = (GDisplay *) list->data; - if(gdisp == gtest) + if (gdisp == gtest) return (gtest); - if(!gdisp_found && gdisp->gimage == gimage) + if (!gdisp_found && gdisp->gimage == gimage) gdisp_found = gdisp; list = g_slist_next (list); } @@ -2250,11 +2251,12 @@ gdisplay_reconnect (GDisplay *gdisp, } gtk_signal_disconnect_by_data (GTK_OBJECT (gdisp->gimage), gdisp); + gdisp->gimage->disp_count--; gimage_delete (gdisp->gimage); instance = gimage->instance_count; gimage->instance_count++; - gimage->ref_count++; + gimage->disp_count++; gdisp->gimage = gimage; gdisp->instance = instance; diff --git a/app/display/gimpdisplay-ops.c b/app/display/gimpdisplay-ops.c index e01d0cd548..885f562f67 100644 --- a/app/display/gimpdisplay-ops.c +++ b/app/display/gimpdisplay-ops.c @@ -113,9 +113,9 @@ gdisplay_close_window (GDisplay *gdisp, { /* If the image has been modified, give the user a chance to save * it before nuking it--this only applies if its the last view - * to an image canvas. (a gimage with ref_count = 1) + * to an image canvas. (a gimage with disp_count = 1) */ - if (!kill_it && (gdisp->gimage->ref_count == 1) && + if (!kill_it && (gdisp->gimage->disp_count == 1) && gdisp->gimage->dirty && confirm_on_close) { gdisplay_close_warning_dialog diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index be2059c4ad..6686b4c852 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -161,17 +161,17 @@ gdisplay_new (GimpImage *gimage, /* set the current tool cursor */ gdisplay_install_tool_cursor (gdisp, default_gdisplay_cursor); - gimage->instance_count++; - gimage->ref_count++; + gimage->instance_count++; /* this is obsolete */ + gimage->disp_count++; lc_dialog_preview_update(gimage); /* We're interested in clean and dirty signals so we can update the * title if need be. */ gtk_signal_connect (GTK_OBJECT (gimage), "dirty", - GTK_SIGNAL_FUNC(gdisplay_cleandirty_handler), gdisp); + GTK_SIGNAL_FUNC (gdisplay_cleandirty_handler), gdisp); gtk_signal_connect (GTK_OBJECT (gimage), "clean", - GTK_SIGNAL_FUNC(gdisplay_cleandirty_handler), gdisp); + GTK_SIGNAL_FUNC (gdisplay_cleandirty_handler), gdisp); return gdisp; } @@ -363,13 +363,14 @@ gdisplay_delete (GDisplay *gdisp) info_window_free (gdisp->window_info_dialog); /* Remove navigation dialog */ - nav_window_free(gdisp,gdisp->window_nav_dialog); + nav_window_free (gdisp, gdisp->window_nav_dialog); /* free the gimage */ + gdisp->gimage->disp_count--; gimage_delete (gdisp->gimage); if (gdisp->nav_popup) - nav_popup_free(gdisp->nav_popup); + nav_popup_free (gdisp->nav_popup); gtk_widget_unref (gdisp->shell); @@ -2176,9 +2177,9 @@ gdisplays_check_valid (GDisplay *gtest, while (list) { gdisp = (GDisplay *) list->data; - if(gdisp == gtest) + if (gdisp == gtest) return (gtest); - if(!gdisp_found && gdisp->gimage == gimage) + if (!gdisp_found && gdisp->gimage == gimage) gdisp_found = gdisp; list = g_slist_next (list); } @@ -2250,11 +2251,12 @@ gdisplay_reconnect (GDisplay *gdisp, } gtk_signal_disconnect_by_data (GTK_OBJECT (gdisp->gimage), gdisp); + gdisp->gimage->disp_count--; gimage_delete (gdisp->gimage); instance = gimage->instance_count; gimage->instance_count++; - gimage->ref_count++; + gimage->disp_count++; gdisp->gimage = gimage; gdisp->instance = instance; diff --git a/app/gdisplay.c b/app/gdisplay.c index be2059c4ad..6686b4c852 100644 --- a/app/gdisplay.c +++ b/app/gdisplay.c @@ -161,17 +161,17 @@ gdisplay_new (GimpImage *gimage, /* set the current tool cursor */ gdisplay_install_tool_cursor (gdisp, default_gdisplay_cursor); - gimage->instance_count++; - gimage->ref_count++; + gimage->instance_count++; /* this is obsolete */ + gimage->disp_count++; lc_dialog_preview_update(gimage); /* We're interested in clean and dirty signals so we can update the * title if need be. */ gtk_signal_connect (GTK_OBJECT (gimage), "dirty", - GTK_SIGNAL_FUNC(gdisplay_cleandirty_handler), gdisp); + GTK_SIGNAL_FUNC (gdisplay_cleandirty_handler), gdisp); gtk_signal_connect (GTK_OBJECT (gimage), "clean", - GTK_SIGNAL_FUNC(gdisplay_cleandirty_handler), gdisp); + GTK_SIGNAL_FUNC (gdisplay_cleandirty_handler), gdisp); return gdisp; } @@ -363,13 +363,14 @@ gdisplay_delete (GDisplay *gdisp) info_window_free (gdisp->window_info_dialog); /* Remove navigation dialog */ - nav_window_free(gdisp,gdisp->window_nav_dialog); + nav_window_free (gdisp, gdisp->window_nav_dialog); /* free the gimage */ + gdisp->gimage->disp_count--; gimage_delete (gdisp->gimage); if (gdisp->nav_popup) - nav_popup_free(gdisp->nav_popup); + nav_popup_free (gdisp->nav_popup); gtk_widget_unref (gdisp->shell); @@ -2176,9 +2177,9 @@ gdisplays_check_valid (GDisplay *gtest, while (list) { gdisp = (GDisplay *) list->data; - if(gdisp == gtest) + if (gdisp == gtest) return (gtest); - if(!gdisp_found && gdisp->gimage == gimage) + if (!gdisp_found && gdisp->gimage == gimage) gdisp_found = gdisp; list = g_slist_next (list); } @@ -2250,11 +2251,12 @@ gdisplay_reconnect (GDisplay *gdisp, } gtk_signal_disconnect_by_data (GTK_OBJECT (gdisp->gimage), gdisp); + gdisp->gimage->disp_count--; gimage_delete (gdisp->gimage); instance = gimage->instance_count; gimage->instance_count++; - gimage->ref_count++; + gimage->disp_count++; gdisp->gimage = gimage; gdisp->instance = instance; diff --git a/app/gdisplay_ops.c b/app/gdisplay_ops.c index e01d0cd548..885f562f67 100644 --- a/app/gdisplay_ops.c +++ b/app/gdisplay_ops.c @@ -113,9 +113,9 @@ gdisplay_close_window (GDisplay *gdisp, { /* If the image has been modified, give the user a chance to save * it before nuking it--this only applies if its the last view - * to an image canvas. (a gimage with ref_count = 1) + * to an image canvas. (a gimage with disp_count = 1) */ - if (!kill_it && (gdisp->gimage->ref_count == 1) && + if (!kill_it && (gdisp->gimage->disp_count == 1) && gdisp->gimage->dirty && confirm_on_close) { gdisplay_close_warning_dialog diff --git a/app/gimage.c b/app/gimage.c index 61fdc4e5f3..224cb6bb75 100644 --- a/app/gimage.c +++ b/app/gimage.c @@ -69,15 +69,19 @@ gimage_get_ID (gint ID) } -/* Ack! GImages have their own ref counts! This is going to cause +/* Ack, GImages have their own ref counts! This is going to cause trouble.. It should be pretty easy to convert to proper GtkObject ref counting, though. */ +/* This caused trouble indeed. The ref_count was only used by the + displays showing the image, so I renamed it to disp_count to + make clear that it should only be used for display references. + (Sven, 23.01.2000) */ + void gimage_delete (GImage *gimage) { - gimage->ref_count--; - if (gimage->ref_count <= 0) + if (gimage->disp_count <= 0) gtk_object_unref (GTK_OBJECT (gimage)); } diff --git a/app/gimage_cmds.c b/app/gimage_cmds.c index 75000a05d5..8f9a5c462d 100644 --- a/app/gimage_cmds.c +++ b/app/gimage_cmds.c @@ -471,7 +471,7 @@ static ProcRecord image_delete_proc = { "gimp_image_delete", "Delete the specified image.", - "If there are no other references to this image it will be deleted. Other references are possible when more than one view to an image exists.", + "If there are no displays associated with this image it will be deleted. This means that you can not delete an image through the PDB that was created by the user. If the associated display was however created through the PDB and you know the display ID, you may delete the display. Removal of the last associated display will then delete the image.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", diff --git a/app/gimpimage.c b/app/gimpimage.c index a2afadf7c9..524f846bac 100644 --- a/app/gimpimage.c +++ b/app/gimpimage.c @@ -165,10 +165,10 @@ gimp_image_init (GimpImage *gimage) gimage->has_filename = FALSE; gimage->num_cols = 0; gimage->cmap = NULL; - /* ID and ref_count handled in gimage.c */ + gimage->disp_count = 0; gimage->instance_count = 0; gimage->shadow = NULL; - gimage->dirty = 1; + gimage->dirty = 1; /* Why is that? I doubt this is correct. --Sven */ gimage->undo_on = TRUE; gimage->construct_flag = -1; gimage->tattoo_state = 0; @@ -2868,7 +2868,7 @@ gimp_image_remove_layer_mask (GimpImage *gimage, /* Push the undo--Important to do it here, AFTER the call * to layer_apply_mask, in case the undo push fails and the - * mask is delete : NULL)d + * mask is deleted */ undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu); diff --git a/app/gimpimageP.h b/app/gimpimageP.h index 58522092ab..85c8452749 100644 --- a/app/gimpimageP.h +++ b/app/gimpimageP.h @@ -53,7 +53,7 @@ struct _GimpImage gboolean undo_on; /* Is undo enabled? */ gint instance_count; /* number of instances */ - gint ref_count; /* number of references */ + gint disp_count; /* number of displays */ Tattoo tattoo_state; /* the next unique tattoo to use*/ diff --git a/tools/pdbgen/pdb/gimage.pdb b/tools/pdbgen/pdb/gimage.pdb index 4d131e319e..b47e232a50 100644 --- a/tools/pdbgen/pdb/gimage.pdb +++ b/tools/pdbgen/pdb/gimage.pdb @@ -328,8 +328,11 @@ sub image_delete { $blurb = 'Delete the specified image.'; $help = <<'HELP'; -If there are no other references to this image it will be deleted. Other -references are possible when more than one view to an image exists. +If there are no displays associated with this image it will be deleted. +This means that you can not delete an image through the PDB that was +created by the user. If the associated display was however created +through the PDB and you know the display ID, you may delete the display. +Removal of the last associated display will then delete the image. HELP &std_pdb_misc; diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb index 4d131e319e..b47e232a50 100644 --- a/tools/pdbgen/pdb/image.pdb +++ b/tools/pdbgen/pdb/image.pdb @@ -328,8 +328,11 @@ sub image_delete { $blurb = 'Delete the specified image.'; $help = <<'HELP'; -If there are no other references to this image it will be deleted. Other -references are possible when more than one view to an image exists. +If there are no displays associated with this image it will be deleted. +This means that you can not delete an image through the PDB that was +created by the user. If the associated display was however created +through the PDB and you know the display ID, you may delete the display. +Removal of the last associated display will then delete the image. HELP &std_pdb_misc;