Commit 4c0754d0 authored by Tobias Ellinghaus's avatar Tobias Ellinghaus

Fix a crash from spot's legacy_params

I am not sure if the crash is really fixed by this, and if it maybe has
side effects with legacy_params not working as intended, but the old
code assumed that it was only run while in darkroom view, which is not
necessarily true for legacy_params which is also run when generating
thumbnails.
Another part of the crash was libs/history.c getting the
DT_SIGNAL_DEVELOP_HISTORY_CHANGE signal while in lighttable and doing
bad things because of that. I didn't change that, but the crash seems to
not happen any more. I assume it's just luck and that we have to revisit
our signal system some day to either not emit those signals while not in
darkroom, don't run callbacks from libs not visible at the moment, or at
least check the current view before assuming that we are in darkroom and
accessing darktable.develop.
parent f2d5c722
......@@ -293,7 +293,7 @@ void dt_masks_events_post_expose(struct dt_iop_module_t *module, cairo_t *cr, in
void dt_masks_gui_form_create(dt_masks_form_t *form, dt_masks_form_gui_t *gui, int index);
void dt_masks_gui_form_remove(dt_masks_form_t *form, dt_masks_form_gui_t *gui, int index);
void dt_masks_gui_form_test_create(dt_masks_form_t *form, dt_masks_form_gui_t *gui);
void dt_masks_gui_form_save_creation(struct dt_iop_module_t *module, dt_masks_form_t *form,
void dt_masks_gui_form_save_creation(dt_develop_t *dev, struct dt_iop_module_t *module, dt_masks_form_t *form,
dt_masks_form_gui_t *gui);
void dt_masks_group_ungroup(dt_masks_form_t *dest_grp, dt_masks_form_t *grp);
dt_masks_point_group_t *dt_masks_group_add_form(dt_masks_form_t *grp, dt_masks_form_t *form);
......
......@@ -1583,7 +1583,7 @@ static int dt_brush_events_button_released(struct dt_iop_module_t *module, float
gui->guipoints_count = 0;
// we save the form and quit creation mode
dt_masks_gui_form_save_creation(crea_module, form, gui);
dt_masks_gui_form_save_creation(darktable.develop, crea_module, form, gui);
if(crea_module)
{
dt_dev_add_history_item(darktable.develop, crea_module, TRUE);
......
......@@ -188,7 +188,7 @@ static int dt_circle_events_button_pressed(struct dt_iop_module_t *module, float
form->source[0] = form->source[1] = 0.0f;
}
form->points = g_list_append(form->points, circle);
dt_masks_gui_form_save_creation(crea_module, form, gui);
dt_masks_gui_form_save_creation(darktable.develop, crea_module, form, gui);
if(crea_module)
{
......
......@@ -369,7 +369,7 @@ static int dt_ellipse_events_button_pressed(struct dt_iop_module_t *module, floa
form->source[0] = form->source[1] = 0.0f;
}
form->points = g_list_append(form->points, ellipse);
dt_masks_gui_form_save_creation(crea_module, form, gui);
dt_masks_gui_form_save_creation(darktable.develop, crea_module, form, gui);
if(crea_module)
{
......
......@@ -169,7 +169,7 @@ static int dt_gradient_events_button_pressed(struct dt_iop_module_t *module, flo
form->points = g_list_append(form->points, gradient);
dt_masks_gui_form_save_creation(crea_module, form, gui);
dt_masks_gui_form_save_creation(darktable.develop, crea_module, form, gui);
if(crea_module)
{
......
......@@ -318,15 +318,16 @@ void _check_id(dt_masks_form_t *form)
}
}
void dt_masks_gui_form_save_creation(dt_iop_module_t *module, dt_masks_form_t *form, dt_masks_form_gui_t *gui)
void dt_masks_gui_form_save_creation(dt_develop_t *dev, dt_iop_module_t *module, dt_masks_form_t *form,
dt_masks_form_gui_t *gui)
{
// we check if the id is already registered
_check_id(form);
darktable.develop->forms = g_list_append(darktable.develop->forms, form);
dev->forms = g_list_append(dev->forms, form);
if(gui) gui->creation = FALSE;
guint nb = g_list_length(darktable.develop->forms);
guint nb = g_list_length(dev->forms);
if(form->type & DT_MASKS_CIRCLE)
snprintf(form->name, sizeof(form->name), _("circle #%d"), nb);
......@@ -339,13 +340,13 @@ void dt_masks_gui_form_save_creation(dt_iop_module_t *module, dt_masks_form_t *f
else if(form->type & DT_MASKS_BRUSH)
snprintf(form->name, sizeof(form->name), _("brush #%d"), nb);
dt_masks_write_form(form, darktable.develop);
dt_masks_write_form(form, dev);
if(module)
{
// is there already a masks group for this module ?
int grpid = module->blend_params->mask_id;
dt_masks_form_t *grp = dt_masks_get_from_id(darktable.develop, grpid);
dt_masks_form_t *grp = dt_masks_get_from_id(dev, grpid);
if(!grp)
{
// we create a new group
......@@ -357,7 +358,7 @@ void dt_masks_gui_form_save_creation(dt_iop_module_t *module, dt_masks_form_t *f
snprintf(grp->name, sizeof(grp->name), "grp %s", module_label);
g_free(module_label);
_check_id(grp);
darktable.develop->forms = g_list_append(darktable.develop->forms, grp);
dev->forms = g_list_append(dev->forms, grp);
module->blend_params->mask_id = grpid = grp->formid;
}
// we add the form in this group
......@@ -369,14 +370,14 @@ void dt_masks_gui_form_save_creation(dt_iop_module_t *module, dt_masks_form_t *f
grpt->opacity = 1.0f;
grp->points = g_list_append(grp->points, grpt);
// we save the group
dt_masks_write_form(grp, darktable.develop);
dt_masks_write_form(grp, dev);
// we update module gui
if(gui) dt_masks_iop_update(module);
dt_dev_add_history_item(darktable.develop, module, TRUE);
dt_dev_add_history_item(dev, module, TRUE);
}
// show the form if needed
if(gui) darktable.develop->form_gui->formid = form->formid;
if(gui) dt_dev_masks_list_change(darktable.develop);
if(gui) dev->form_gui->formid = form->formid;
if(gui) dt_dev_masks_list_change(dev);
}
int dt_masks_form_duplicate(dt_develop_t *dev, int formid)
......
......@@ -992,7 +992,7 @@ static int dt_path_events_button_pressed(struct dt_iop_module_t *module, float p
_path_init_ctrl_points(form);
// we save the form and quit creation mode
dt_masks_gui_form_save_creation(crea_module, form, gui);
dt_masks_gui_form_save_creation(darktable.develop, crea_module, form, gui);
if(crea_module)
{
dt_dev_add_history_item(darktable.develop, crea_module, TRUE);
......
......@@ -106,7 +106,7 @@ int legacy_params(dt_iop_module_t *self, const void *const old_params, const int
// adapt for raw orientation changes
dt_masks_legacy_params(self->dev, form, form->version, dt_masks_version());
dt_masks_gui_form_save_creation(self, form, NULL);
dt_masks_gui_form_save_creation(self->dev, self, form, NULL);
// and add it to the module params
n->clone_id[i] = form->formid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment