Skip to content

Commit

Permalink
darktable: Call dt_iop_set_darktable_iop_table when iop list is set.
Browse files Browse the repository at this point in the history
This is important as the list of all iop must be known to populate the
memory.darktable_iop_names table for the 'module' collection filter.

Fixes #18093.
  • Loading branch information
TurboGit committed Dec 28, 2024
1 parent f19e014 commit b3f1ec7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
3 changes: 0 additions & 3 deletions src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1731,9 +1731,6 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
darktable.mipmap_cache = (dt_mipmap_cache_t *)calloc(1, sizeof(dt_mipmap_cache_t));
dt_mipmap_cache_init(darktable.mipmap_cache);

// set up memory.darktable_iop_names table
dt_iop_set_darktable_iop_table();

// set up the list of exiv2 metadata
dt_exif_set_exiv2_taglist();

Expand Down
58 changes: 32 additions & 26 deletions src/develop/imageop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1729,13 +1729,45 @@ static void _init_module_so(void *m)
}
}

// to be called before issuing any query based on memory.darktable_iop_names
void _iop_set_darktable_iop_table()
{
// the iop list must have been set, so after dt_iop_load_modules_so()
assert(darktable.iop && g_list_length(darktable.iop) > 0);

sqlite3_stmt *stmt;
gchar *module_list = NULL;
for(GList *iop = darktable.iop; iop; iop = g_list_next(iop))
{
dt_iop_module_so_t *module = iop->data;
dt_util_str_cat(&module_list, "(\"%s\",\"%s\"),",
module->op, module->name());
}

if(module_list)
{
module_list[strlen(module_list) - 1] = '\0';
gchar *query =
g_strdup_printf("INSERT INTO memory.darktable_iop_names (operation, name)"
" VALUES %s", module_list);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), query, -1, &stmt, NULL);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
g_free(query);
g_free(module_list);
}
}

void dt_iop_load_modules_so(void)
{
darktable.iop = dt_module_load_modules
("/plugins", sizeof(dt_iop_module_so_t),
dt_iop_load_module_so, _init_module_so, NULL);

DT_CONTROL_SIGNAL_CONNECT(DT_SIGNAL_PREFERENCES_CHANGE, _iop_preferences_changed, darktable.iop);

// set up memory.darktable_iop_names table
_iop_set_darktable_iop_table();
}

gboolean dt_iop_load_module(dt_iop_module_t *module,
Expand Down Expand Up @@ -3348,32 +3380,6 @@ static void _enable_module_callback(dt_iop_module_t *module)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(module->off), !active);
}

// to be called before issuing any query based on memory.darktable_iop_names
void dt_iop_set_darktable_iop_table()
{
sqlite3_stmt *stmt;
gchar *module_list = NULL;
for(GList *iop = darktable.iop; iop; iop = g_list_next(iop))
{
dt_iop_module_so_t *module = iop->data;
dt_util_str_cat(&module_list, "(\"%s\",\"%s\"),",
module->op, module->name());
}

if(module_list)
{
module_list[strlen(module_list) - 1] = '\0';
gchar *query =
g_strdup_printf("INSERT INTO memory.darktable_iop_names (operation, name)"
" VALUES %s", module_list);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), query, -1, &stmt, NULL);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
g_free(query);
g_free(module_list);
}
}

const gchar *dt_iop_get_localized_name(const gchar *op)
{
// Prepare mapping op -> localized name
Expand Down
3 changes: 0 additions & 3 deletions src/develop/imageop.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,6 @@ dt_iop_module_t *dt_iop_gui_get_previous_visible_module(const dt_iop_module_t *m
/** returns the next visible module on the module list */
dt_iop_module_t *dt_iop_gui_get_next_visible_module(const dt_iop_module_t *module);

// initializes memory.darktable_iop_names
void dt_iop_set_darktable_iop_table();

/** adds keyboard accels to the first module in the pipe to handle
* where there are multiple instances */
void dt_iop_connect_accels_multi(dt_iop_module_so_t *module);
Expand Down

0 comments on commit b3f1ec7

Please sign in to comment.