By-color-select now checks if the image it is working on still exists.

This fixes the crashes when closing an image with the by-color-select-dialog
associated to it still open and pressing "Reset" or clicking into the preview.

The checks produce some warnings like
** WARNING **: invalid class type (unknown)' in cast to impDrawable'
when failing, but I consider this less evil than a crash.

There is still a problem: Sometimes the by-color-select-dialog is closed
when the image is closed and can't be opened anymore. Anyone?


--Sven
This commit is contained in:
Sven Neumann 1998-03-30 12:10:54 +00:00
parent eb2a8f6708
commit 83ef9d15b3
4 changed files with 38 additions and 3 deletions

View File

@ -1,3 +1,8 @@
Mon Mar 30 14:04:26 MEST 1998 Sven Neumann <sven@gimp.org>
* app/by_color_select.c: now checks if the image it is
operating on still exists.
Sun Mar 29 14:29:34 PST 1998 Manish Singh <yosh@gimp.org>
* plug-ins/sparkle/sparkle.c: fixed improper use of types;

View File

@ -601,7 +601,7 @@ by_color_select_new_dialog ()
gtk_container_border_width (GTK_CONTAINER (options_box), 5);
gtk_box_pack_start (GTK_BOX (hbox), options_box, TRUE, TRUE, 0);
/* Create the active brush label */
/* Create the active image label */
util_box = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (options_box), util_box, FALSE, FALSE, 0);
bcd->gimage_name = gtk_label_new ("Inactive");
@ -832,9 +832,14 @@ by_color_select_reset_callback (GtkWidget *widget,
ByColorDialog *bcd;
bcd = (ByColorDialog *) client_data;
if (!bcd->gimage)
return;
/* check if the image associated to the mask still exists */
if (!drawable_gimage (GIMP_DRAWABLE(gimage_get_mask (bcd->gimage))))
return;
/* reset the mask */
gimage_mask_clear (bcd->gimage);
@ -889,8 +894,13 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
if (!bcd->gimage)
return;
drawable = gimage_active_drawable (bcd->gimage);
/* check if the gimage associated to the drawable still exists */
if (!drawable_gimage (drawable))
return;
/* Defaults */
replace = FALSE;
operation = REPLACE;

View File

@ -601,7 +601,7 @@ by_color_select_new_dialog ()
gtk_container_border_width (GTK_CONTAINER (options_box), 5);
gtk_box_pack_start (GTK_BOX (hbox), options_box, TRUE, TRUE, 0);
/* Create the active brush label */
/* Create the active image label */
util_box = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (options_box), util_box, FALSE, FALSE, 0);
bcd->gimage_name = gtk_label_new ("Inactive");
@ -832,9 +832,14 @@ by_color_select_reset_callback (GtkWidget *widget,
ByColorDialog *bcd;
bcd = (ByColorDialog *) client_data;
if (!bcd->gimage)
return;
/* check if the image associated to the mask still exists */
if (!drawable_gimage (GIMP_DRAWABLE(gimage_get_mask (bcd->gimage))))
return;
/* reset the mask */
gimage_mask_clear (bcd->gimage);
@ -889,8 +894,13 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
if (!bcd->gimage)
return;
drawable = gimage_active_drawable (bcd->gimage);
/* check if the gimage associated to the drawable still exists */
if (!drawable_gimage (drawable))
return;
/* Defaults */
replace = FALSE;
operation = REPLACE;

View File

@ -601,7 +601,7 @@ by_color_select_new_dialog ()
gtk_container_border_width (GTK_CONTAINER (options_box), 5);
gtk_box_pack_start (GTK_BOX (hbox), options_box, TRUE, TRUE, 0);
/* Create the active brush label */
/* Create the active image label */
util_box = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (options_box), util_box, FALSE, FALSE, 0);
bcd->gimage_name = gtk_label_new ("Inactive");
@ -832,9 +832,14 @@ by_color_select_reset_callback (GtkWidget *widget,
ByColorDialog *bcd;
bcd = (ByColorDialog *) client_data;
if (!bcd->gimage)
return;
/* check if the image associated to the mask still exists */
if (!drawable_gimage (GIMP_DRAWABLE(gimage_get_mask (bcd->gimage))))
return;
/* reset the mask */
gimage_mask_clear (bcd->gimage);
@ -889,8 +894,13 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
if (!bcd->gimage)
return;
drawable = gimage_active_drawable (bcd->gimage);
/* check if the gimage associated to the drawable still exists */
if (!drawable_gimage (drawable))
return;
/* Defaults */
replace = FALSE;
operation = REPLACE;