plug-ins: Fix crash when removing flares in Gradient Flare
Resolves #15113 There is code in the Gradient Flare plug-in to prevent deleting gradients when there is only one left. However, the flare count was not being properly updated. Due to a stray unbounded IF statement, "if (tmp->next == NULL)", the num_gflares variable was only decremented if you deleted from the bottom of the list. As a result, you could delete all the flares and cause the plug-in to crash when it tried to render a non-existent flare. This patch removes the stray IF statement and adds additional checks to make sure dlg->gflare exists before trying to get a pointer from it.
This commit is contained in:
parent
b3fe88323c
commit
3cb0eb2df5
1 changed files with 8 additions and 5 deletions
|
|
@ -1712,7 +1712,6 @@ gflares_list_remove (GFlare *gflare)
|
|||
if (tmp->data == gflare)
|
||||
{
|
||||
/* Found! */
|
||||
if (tmp->next == NULL)
|
||||
num_gflares--;
|
||||
gflares_list = g_list_remove (gflares_list, gflare);
|
||||
return n;
|
||||
|
|
@ -2577,6 +2576,10 @@ dlg_run (GimpProcedure *procedure,
|
|||
dlg_preview_update ();
|
||||
|
||||
run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (shell));
|
||||
|
||||
if (! dlg->gflare)
|
||||
run = FALSE;
|
||||
|
||||
if (run)
|
||||
{
|
||||
g_object_set (config,
|
||||
|
|
@ -2768,7 +2771,7 @@ dlg_preview_init_func (Preview *preview,
|
|||
|
||||
/* call init_params first, and iterate init_progress while
|
||||
it returns true */
|
||||
if (dlg->init_params_done == FALSE)
|
||||
if (dlg->init_params_done == FALSE && dlg->gflare)
|
||||
{
|
||||
gint xcenter;
|
||||
gint ycenter;
|
||||
|
|
@ -3369,8 +3372,8 @@ dlg_selector_do_delete_callback (GtkWidget *widget,
|
|||
dlg->gflare = NULL;
|
||||
|
||||
/* Remove from listbox */
|
||||
if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (dlg->selector_list),
|
||||
&iter, NULL, i))
|
||||
if (! gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (dlg->selector_list),
|
||||
&iter, NULL, i))
|
||||
{
|
||||
g_warning ("Unsynchronized lists. Bad things will happen!");
|
||||
return;
|
||||
|
|
@ -3380,7 +3383,7 @@ dlg_selector_do_delete_callback (GtkWidget *widget,
|
|||
/* Calculate new position of gflare and select it */
|
||||
new_i = (i < num_gflares) ? i : num_gflares - 1;
|
||||
if ((tmp = g_list_nth (gflares_list, new_i)))
|
||||
dlg->gflare = tmp->data;
|
||||
dlg->gflare = tmp->data;
|
||||
if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (dlg->selector_list),
|
||||
&iter, NULL, i))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue