widgets: Prevent crash when converting to indexed image

Resolves #13092
GIMP crashed when converting an image to indexed mode,
if the user first changed the color in the Configure Grid
Dialogue. This was because signals were not being
properly disconnected from GimpColorMapSelection
after the dialogue was closed.

Jehan found the solution, to replace 
g_signal_connect_swapped () calls with
g_signal_connect_object () and flags set to
G_CONNECT_SWAPPED to retain the original
behavior. This ensures the signals are disconnected
after the widget is destroyed on dialogue close.
This commit is contained in:
Alx Sa 2025-03-14 15:18:48 +00:00
parent e139e016a5
commit 4d8073a3a0

View file

@ -796,12 +796,12 @@ gimp_colormap_selection_image_changed (GimpColormapSelection *selection,
if (image)
{
g_signal_connect_swapped (image, "colormap-changed",
g_signal_connect_object (image, "colormap-changed",
G_CALLBACK (gimp_colormap_selection_colormap_changed),
selection);
g_signal_connect_swapped (image, "mode-changed",
selection, G_CONNECT_SWAPPED);
g_signal_connect_object (image, "mode-changed",
G_CALLBACK (gimp_colormap_selection_set_palette),
selection);
selection, G_CONNECT_SWAPPED);
}
gimp_colormap_selection_set_palette (selection);