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


--Sven
This commit is contained in:
Sven Neumann 2000-01-23 13:44:12 +00:00
parent d365b12c1a
commit bceb97a993
19 changed files with 99 additions and 64 deletions

View file

@ -1,3 +1,22 @@
Sun Jan 23 14:33:57 CET 2000 Sven Neumann <sven@gimp.org>
* 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 <austin@gimp.org>
* MAINTAINERS: update my entry.

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

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

View file

@ -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;

View file

@ -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;

View file

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

View file

@ -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));
}

View file

@ -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",

View file

@ -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);

View file

@ -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*/

View file

@ -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;

View file

@ -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;