libgimp: take into account case when gtk_settings_get_default() returns NULL.

I believe it should not happen in normal GUI case (which is when you create a
GimpProcedureDialog). I had the issue while moving around some plug-in code and
moved dialog creation before gimp_ui_init() by mistake. The issue was not
obvious until I followed the trace inside libgimp. This would be even more
frustrating for plug-in developers so let's have a clear warning message giving
the possible plug-in crash reason.
This commit is contained in:
Jehan 2023-08-29 15:27:02 +02:00
parent 36576c7276
commit a40357a165
1 changed files with 7 additions and 3 deletions

View File

@ -206,9 +206,13 @@ gimp_procedure_dialog_constructor (GType type,
gboolean use_header_bar_edited = FALSE;
gboolean help_func_edited = FALSE;
g_object_get (gtk_settings_get_default (),
"gtk-dialogs-use-header", &use_header_bar,
NULL);
if (gtk_settings_get_default () != NULL)
g_object_get (gtk_settings_get_default (),
"gtk-dialogs-use-header", &use_header_bar,
NULL);
else
g_warning ("%s: no default screen. Did you call gimp_ui_init()?", G_STRFUNC);
for (guint i = 0; i < n_construct_properties; i++)
{