Skip to content

Commit

Permalink
Export : set format combobox properly at init time
Browse files Browse the repository at this point in the history
Seemed it relied on value-changed signal side-effects to be set previously.
Protect comboboxes setting from segfaults
  • Loading branch information
aurelienpierre committed Nov 26, 2023
1 parent dbf4f4f commit 633d9b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bauhaus/bauhaus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,8 @@ void dt_bauhaus_combobox_set(GtkWidget *widget, const int pos)
struct dt_bauhaus_widget_t *w = DT_BAUHAUS_WIDGET(widget);
dt_bauhaus_combobox_data_t *d = &w->data.combobox;
const int old_pos = d->active;
const int new_pos = CLAMP(pos, -1, (int)d->entries->len - 1);
const int new_pos = (d->entries) ? CLAMP(pos, -1, (int)d->entries->len - 1)
: -1;

if(old_pos != new_pos)
{
Expand Down
6 changes: 6 additions & 0 deletions src/libs/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ void gui_init(dt_lib_module_t *self)
for(const GList *it = darktable.imageio->plugins_format; it; it = g_list_next(it))
{
const dt_imageio_module_format_t *module = (dt_imageio_module_format_t *)it->data;
dt_bauhaus_combobox_add(d->format, module->name(module));
if(module->widget)
{
gtk_container_add(GTK_CONTAINER(d->format_extra_container), module->widget);
Expand Down Expand Up @@ -1359,6 +1360,11 @@ void gui_init(dt_lib_module_t *self)
const int storage_index = dt_imageio_get_index_of_storage(dt_imageio_get_storage_by_name(setting));
dt_bauhaus_combobox_set(d->storage, storage_index);

// Set format
setting = dt_conf_get_string_const(CONFIG_PREFIX "format_name");
const int format_index = dt_imageio_get_index_of_format(dt_imageio_get_format_by_name(setting));
dt_bauhaus_combobox_set(d->format, format_index);

dt_bauhaus_combobox_set(d->upscale, dt_conf_get_bool(CONFIG_PREFIX "upscale") ? 1 : 0);
dt_bauhaus_combobox_set(d->high_quality, dt_conf_get_bool(CONFIG_PREFIX "high_quality_processing") ? 1 : 0);
dt_bauhaus_combobox_set(d->export_masks, dt_conf_get_bool(CONFIG_PREFIX "export_masks") ? 1 : 0);
Expand Down

0 comments on commit 633d9b7

Please sign in to comment.