plug-ins: Fix IFS Compose crash related to undos

As part of the color space invasion, we
converted the IFS Compose colors to
GeglColor. However, we forgot to initialize
them when we create a new AFFElement
in undo_update (). As a result, when we
try to clear them out later in aff_element_free (),
the plug-in crashes.
This patch resolves the issues by initializing
the five GeglColors on creation.
This commit is contained in:
Alx Sa 2024-10-16 11:32:22 +00:00
parent af8cc019e3
commit 0a9020bb0a
2 changed files with 17 additions and 8 deletions

View file

@ -671,7 +671,9 @@ aff_element_compute_click_boundary (AffElement *elem,
points[3].y = yc + axis1 * sth - axis2 * cth;
}
else
elem->click_boundary = elem->draw_boundary;
{
elem->click_boundary = elem->draw_boundary;
}
}
void
@ -813,7 +815,7 @@ aff_element_new (gdouble x,
void
aff_element_free (AffElement *elem)
{
if (elem->click_boundary != elem->draw_boundary)
if (elem->click_boundary && elem->click_boundary != elem->draw_boundary)
g_free (elem->click_boundary);
g_clear_object (&elem->v.red_color);

View file

@ -1470,11 +1470,11 @@ update_values (void)
ifsD->current_vals = elements[ifsD->current_element]->v;
ifsD->current_vals.theta *= 180/G_PI;
ifsD->current_vals.red_color = gegl_color_duplicate (ifsD->current_vals.red_color);
ifsD->current_vals.green_color = gegl_color_duplicate (ifsD->current_vals.green_color);
ifsD->current_vals.blue_color = gegl_color_duplicate (ifsD->current_vals.blue_color);
ifsD->current_vals.black_color = gegl_color_duplicate (ifsD->current_vals.black_color);
ifsD->current_vals.target_color = gegl_color_duplicate (ifsD->current_vals.target_color);
ifsD->current_vals.red_color = gegl_color_duplicate (ifsD->red_cmap->color);
ifsD->current_vals.green_color = gegl_color_duplicate (ifsD->green_cmap->color);
ifsD->current_vals.blue_color = gegl_color_duplicate (ifsD->blue_cmap->color);
ifsD->current_vals.black_color = gegl_color_duplicate (ifsD->black_cmap->color);
ifsD->current_vals.target_color = gegl_color_duplicate (ifsD->target_cmap->color);
value_pair_update (ifsD->prob_pair);
value_pair_update (ifsD->x_pair);
@ -1896,7 +1896,14 @@ undo_update (gint el)
= elem = g_new (AffElement, 1);
*elem = *elements[el];
elem->draw_boundary = NULL;
elem->v.red_color = gegl_color_duplicate (ifsD->red_cmap->color);
elem->v.blue_color = gegl_color_duplicate (ifsD->blue_cmap->color);
elem->v.green_color = gegl_color_duplicate (ifsD->green_cmap->color);
elem->v.black_color = gegl_color_duplicate (ifsD->black_cmap->color);
elem->v.target_color = gegl_color_duplicate (ifsD->target_cmap->color);
elem->draw_boundary = NULL;
elem->click_boundary = NULL;
}