Issue #8359: GIMP crashes from "open the font selection dialog" button.

Apparently GDK/Win32 sends the "grab-broken-event" signal before the "clicked"
signal. This has only been changed since GTK4 so far.

Anyway the bottom line is that GimpContainerPopup would process a handled on
"clicked", using the object destroyed when "grab-broken-event" happened as
callback data. The solution is to make sure that the object stays alive long
enough. So I'm changing gimp_editor_add_button() to connect to signals with
g_signal_connect_object() (since all usage of this function was used with
GObject callback data, it was not a problem).

See discussion in !815.

As a side change, gimp_container_popup_dialog_clicked() should emit the
"cancel", not "confirm". This part was taken from MR !815 by Lloyd Konneker.

(cherry picked from commit f77f772f56)
This commit is contained in:
Jehan
2023-02-09 21:50:54 +01:00
parent 22ca5248af
commit aeb5eaa890
11 changed files with 48 additions and 33 deletions

View File

@ -488,6 +488,21 @@ gimp_editor_popup_menu (GimpEditor *editor,
return FALSE;
}
/**
* gimp_editor_add_button:
* @editor:
* @icon_name:
* @tooltip:
* @help_id:
* @callback:
* @extended_callback:
* @callback_data:
*
* Creates a new button, connect @callback to the "clicked" signal and
* @extended_callback to the "extended-clicked" signal.
* The @callback_data has to be a %GObject so that we keep a ref on it and avoid
* bad surprises.
*/
GtkWidget *
gimp_editor_add_button (GimpEditor *editor,
const gchar *icon_name,
@ -495,7 +510,7 @@ gimp_editor_add_button (GimpEditor *editor,
const gchar *help_id,
GCallback callback,
GCallback extended_callback,
gpointer callback_data)
GObject *callback_data)
{
GtkWidget *button;
GtkWidget *image;
@ -516,14 +531,14 @@ gimp_editor_add_button (GimpEditor *editor,
gimp_help_set_help_data (button, tooltip, help_id);
if (callback)
g_signal_connect (button, "clicked",
callback,
callback_data);
g_signal_connect_object (button, "clicked",
callback,
callback_data, 0);
if (extended_callback)
g_signal_connect (button, "extended-clicked",
extended_callback,
callback_data);
g_signal_connect_object (button, "extended-clicked",
extended_callback,
callback_data, 0);
image = gtk_image_new_from_icon_name (icon_name, button_icon_size);
gtk_container_add (GTK_CONTAINER (button), image);