Skip to content

Commit 1c9c8e5

Browse files
committed
Merge branch 'po/fix-mem-leak' into darktable-5.2.0
* po/fix-mem-leak: Properly localize the segmented snapshot's label. snapshots: Ensure the entry fill all the widget while editing. Fix memory leak when using dt_util_localize_segmented_name.
2 parents c2b3df9 + 9fdc599 commit 1c9c8e5

File tree

6 files changed

+32
-22
lines changed

6 files changed

+32
-22
lines changed

src/common/history.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2010-2024 darktable developers.
3+
Copyright (C) 2010-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -1023,13 +1023,15 @@ char *dt_history_get_name_label(const char *name,
10231023
}
10241024
else
10251025
{
1026-
const char *l_label = hand_edited
1027-
? label
1026+
char *l_label = hand_edited
1027+
? g_strdup (label)
10281028
: dt_util_localize_segmented_name(label, FALSE);
10291029

10301030
result = markup
10311031
? g_markup_printf_escaped("%s • <small>%s</small>", name, l_label)
10321032
: g_markup_printf_escaped("%s • %s", name, l_label);
1033+
1034+
g_free(l_label);
10331035
}
10341036

10351037
return result;

src/common/presets.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,28 +428,28 @@ char *dt_presets_get_module_label(const char *module_name,
428428
const char *name = (const char *)sqlite3_column_text(stmt, 0);
429429
const char *multi_name = (const char *)sqlite3_column_text(stmt, 1);
430430
if(multi_name && (strlen(multi_name) == 0 || multi_name[0] != ' '))
431-
result = g_strdup(dt_presets_get_multi_name(name, multi_name, FALSE));
431+
result = dt_presets_get_multi_name(name, multi_name, FALSE);
432432
}
433433
g_free(query);
434434
sqlite3_finalize(stmt);
435435

436436
return result;
437437
}
438438

439-
const char *dt_presets_get_multi_name(const char *name,
440-
const char *multi_name,
441-
const gboolean localize)
439+
char *dt_presets_get_multi_name(const char *name,
440+
const char *multi_name,
441+
const gboolean localize)
442442
{
443443
const gboolean auto_module = dt_conf_get_bool("darkroom/ui/auto_module_name_update");
444444

445445
// in auto-update mode : use either the multi_name if defined otherwise the name
446446
// in non auto-update mode : use only the multi_name if defined
447447
if(auto_module)
448448
return strlen(multi_name) > 0
449-
? multi_name
450-
: (localize ? dt_util_localize_segmented_name(name, FALSE) : name);
449+
? g_strdup(multi_name)
450+
: (localize ? dt_util_localize_segmented_name(name, FALSE) : g_strdup(name));
451451
else
452-
return strlen(multi_name) > 0 ? multi_name : "";
452+
return g_strdup(strlen(multi_name) > 0 ? multi_name : "");
453453
}
454454

455455
// clang-format off

src/common/presets.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2019-2023 darktable developers.
3+
Copyright (C) 2019-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -42,9 +42,9 @@ char *dt_presets_get_module_label(const char *module_name,
4242
and the recorded preset's multi_name. This depends on the preference
4343
darkroom/ui/auto_module_name_update
4444
*/
45-
const char *dt_presets_get_multi_name(const char *name,
46-
const char *multi_name,
47-
const gboolean localize);
45+
char *dt_presets_get_multi_name(const char *name,
46+
const char *multi_name,
47+
const gboolean localize);
4848

4949
/** get currently active preset name for the module */
5050
gchar *dt_get_active_preset_name(dt_iop_module_t *module, gboolean *writeprotect);

src/develop/imageop.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,11 @@ static void _iop_panel_name(dt_iop_module_t *module)
11981198
if(module->multi_name_hand_edited)
11991199
new_label = g_strdup_printf("• %s", module->multi_name);
12001200
else
1201-
new_label = g_strdup_printf("• %s", dt_util_localize_segmented_name(module->multi_name, FALSE));
1201+
{
1202+
char *loc = dt_util_localize_segmented_name(module->multi_name, FALSE);
1203+
new_label = g_strdup_printf("• %s", loc);
1204+
g_free(loc);
1205+
}
12021206
gtk_widget_set_name(GTK_WIDGET(iname), "iop-module-name");
12031207
}
12041208
}

src/gui/styles_dialog.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2010-2024 darktable developers.
3+
Copyright (C) 2010-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -1003,10 +1003,12 @@ GtkWidget *dt_gui_style_content_dialog(char *name, const dt_imgid_t imgid)
10031003

10041004
if(i->multi_name && strlen(i->multi_name) > 0)
10051005
{
1006-
snprintf(mn, sizeof(mn), "(%s)",
1007-
i->multi_name_hand_edited
1008-
? i->multi_name
1009-
: dt_util_localize_segmented_name(i->multi_name, TRUE));
1006+
char *mname = i->multi_name_hand_edited
1007+
? g_strdup(i->multi_name)
1008+
: dt_util_localize_segmented_name(i->multi_name, TRUE);
1009+
1010+
snprintf(mn, sizeof(mn), "(%s)", mname);
1011+
g_free(mname);
10101012
}
10111013
else
10121014
{

src/libs/snapshots.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ static void _init_snapshot_entry(dt_lib_module_t *self, dt_lib_snapshot_t *s)
558558
gtk_widget_set_halign(s->name, GTK_ALIGN_START);
559559

560560
s->entry = gtk_entry_new();
561-
gtk_widget_set_halign(s->entry, GTK_ALIGN_START);
561+
gtk_widget_set_halign(s->entry, GTK_ALIGN_FILL);
562562
g_signal_connect(G_OBJECT(s->entry), "activate",
563563
G_CALLBACK(_entry_activated_callback), self);
564564

@@ -878,7 +878,9 @@ static void _lib_snapshots_add_button_clicked_callback(GtkWidget *widget,
878878
if(strlen(history_item->multi_name) > 0
879879
&& history_item->multi_name[0] != ' ')
880880
{
881-
s->label = g_strdup(history_item->multi_name);
881+
s->label = history_item->multi_name_hand_edited
882+
? g_strdup(history_item->multi_name)
883+
: dt_util_localize_segmented_name(history_item->multi_name, TRUE);
882884
}
883885
}
884886
else

0 commit comments

Comments
 (0)