emboss.c jigsaw.c max_rgb.c nlfilt.c wind.c When a radio button in GTK is

Sun Aug 20 21:02:22 BST 2000  Austin Donnelly  <austin@gimp.org>

	* emboss.c
	* jigsaw.c
	* max_rgb.c
	* nlfilt.c
	* wind.c
	* waves.c: When a radio button in GTK is clicked, the
	    widget that used to be selected gets a signal as well as the
	    one that was clicked.  Mostly people cope with this by
	    guarding their signal handers with a check to run to the code
	    only if the widget is active.  However, the callback functions
	    registered with gimp_radio_group_new2() in the above files
	    don't have this guard.  In most cases, this is a bad idea
	    since it causes previews to be updated too many times.  In the
	    emboss case it would also get the preview contents wrong when
	    first displaying the dialog, since the act of
	    gtk_widget_show()ing the dialog causes an event to be sent to
	    the widget that's just been de-selected, causing the preview
	    to redraw while the settings are inconsistent.

	* emboss.c: The emboss plugin also used uninitialised data the
	    first time it is started, which wasn't biting currently, but
	    might in the future or on other architectures which don't zero
	    their stacks.  Also made active region estimation more robust.

	    I still haven't been able to reproduce Bug #17660: Embross
	    plugin crashes, but I will admit that there's what could be
	    uninitialised memory in the preview bitmap the very first time
	    it is shown.
This commit is contained in:
BST 2000 Austin Donnelly 2000-08-20 20:34:26 +00:00 committed by Austin Donnelly
parent 614bc34d59
commit 547f482063
7 changed files with 57 additions and 20 deletions

View File

@ -1,3 +1,34 @@
Sun Aug 20 21:02:22 BST 2000 Austin Donnelly <austin@gimp.org>
* emboss.c
* jigsaw.c
* max_rgb.c
* nlfilt.c
* wind.c
* waves.c: When a radio button in GTK is clicked, the
widget that used to be selected gets a signal as well as the
one that was clicked. Mostly people cope with this by
guarding their signal handers with a check to run to the code
only if the widget is active. However, the callback functions
registered with gimp_radio_group_new2() in the above files
don't have this guard. In most cases, this is a bad idea
since it causes previews to be updated too many times. In the
emboss case it would also get the preview contents wrong when
first displaying the dialog, since the act of
gtk_widget_show()ing the dialog causes an event to be sent to
the widget that's just been de-selected, causing the preview
to redraw while the settings are inconsistent.
* emboss.c: The emboss plugin also used uninitialised data the
first time it is started, which wasn't biting currently, but
might in the future or on other architectures which don't zero
their stacks. Also made active region estimation more robust.
I still haven't been able to reproduce Bug #17660: Embross
plugin crashes, but I will admit that there's what could be
uninitialised memory in the preview bitmap the very first time
it is shown.
2000-08-20 Sven Neumann <sven@gimp.org>
* plug-ins/imagemap/Makefile.am

View File

@ -194,6 +194,7 @@ run (gchar *name,
{
case RUN_INTERACTIVE:
INIT_I18N_UI();
args.img = args.drw = 0;
gimp_get_data ("plug_in_emboss", &args);
if (args.img == 0 && args.drw == 0)
{
@ -203,7 +204,6 @@ run (gchar *name,
args.depth = 20;
args.embossp = FUNCTION_EMBOSS;
}
args.img = param[1].data.d_image;
args.drw = param[2].data.d_drawable;
drw = gimp_drawable_get (args.drw);
@ -389,10 +389,10 @@ pluginCore (struct piArgs *argp)
gimp_drawable_mask_bounds (argp->drw, &x1, &y1, &x2, &y2);
/* expand the bounds a little */
x1 = MAX (0, x1 - 5);
y1 = MAX (0, y1 - 5);
x2 = MIN (drw->width, x2 + 5);
y2 = MIN (drw->height, y2 + 5);
x1 = MAX (0, x1 - argp->depth);
y1 = MAX (0, y1 - argp->depth);
x2 = MIN (drw->width, x2 + argp->depth);
y2 = MIN (drw->height, y2 + argp->depth);
width = x2 - x1;
height = y2 - y1;
@ -432,13 +432,14 @@ pluginCore (struct piArgs *argp)
for (y = 0; y < height - 2; y++)
{
if (y % p_update == 0)
gimp_progress_update ((gdouble) y / (gdouble) height);
gimp_progress_update ((gdouble) y / (gdouble) height);
gimp_pixel_rgn_get_rect (&src, srcbuf, x1, y1+y, width, 3);
EmbossRow (srcbuf, argp->embossp ? (guchar *) 0 : srcbuf,
dstbuf, width, bypp, has_alpha);
gimp_pixel_rgn_set_row (&dst, dstbuf, x1, y1+y+1, width);
}
gimp_progress_update (1.0);
g_free (srcbuf);
g_free (dstbuf);
@ -466,13 +467,9 @@ static void
emboss_radio_button_callback (GtkWidget *widget,
gpointer data)
{
gint *toggle_val;
gimp_radio_button_update (widget, data);
toggle_val = (gint32 *) data;
*toggle_val = (gint32) gtk_object_get_user_data (GTK_OBJECT (widget));
if (do_preview)
if (do_preview && GTK_TOGGLE_BUTTON (widget)->active)
emboss_do_preview (NULL);
}

View File

@ -2688,7 +2688,8 @@ jigsaw_radio_button_update (GtkWidget *widget,
gpointer data)
{
gimp_radio_button_update (widget, data);
jigsaw (TRUE);
if (GTK_TOGGLE_BUTTON (widget)->active)
jigsaw (TRUE);
}

View File

@ -407,8 +407,12 @@ radio_callback (GtkWidget *widget,
GDrawable *drawable;
gimp_radio_button_update (widget, data);
drawable = gtk_object_get_data (GTK_OBJECT (widget), "drawable");
main_function (drawable, TRUE);
if (GTK_TOGGLE_BUTTON (widget)->active)
{
drawable = gtk_object_get_data (GTK_OBJECT (widget), "drawable");
main_function (drawable, TRUE);
}
}
static void

View File

@ -312,7 +312,7 @@ nlfilt_radio_button_update (GtkWidget *widget,
{
gimp_radio_button_update (widget, data);
if (do_preview)
if (do_preview && GTK_TOGGLE_BUTTON (widget)->active)
nlfilt_do_preview (NULL);
}

View File

@ -309,7 +309,7 @@ waves_radio_button_update (GtkWidget *widget,
{
gimp_radio_button_update (widget, data);
if (do_preview)
if (do_preview && GTK_TOGGLE_BUTTON (widget)->active)
waves_do_preview (NULL);
}

View File

@ -974,9 +974,13 @@ radio_callback (GtkWidget *widget,
GDrawable *drawable;
gimp_radio_button_update (widget, data);
drawable = gtk_object_get_data (GTK_OBJECT (widget), "drawable");
if(drawable != NULL)
render_effect (drawable, TRUE);
if (GTK_TOGGLE_BUTTON (widget)->active)
{
drawable = gtk_object_get_data (GTK_OBJECT (widget), "drawable");
if (drawable != NULL)
render_effect (drawable, TRUE);
}
}
static void