app: initial monitor information is only needed at display shell construction.

Making sure that it's private then NULLified at end of construction so
that none tries to use this again later on during the life of the
display shell (it may have become invalid since then, cf. #12542).

Also NULLifying a similar variable stored in GimpImageWindow (though it
was already a private variable not used outside in this case).
This commit is contained in:
Jehan 2025-05-05 19:05:47 +02:00
parent 07f9402f82
commit 83e213d770
3 changed files with 22 additions and 5 deletions

View file

@ -118,6 +118,11 @@ enum
LAST_SIGNAL
};
struct _GimpDisplayShellPrivate
{
GdkMonitor *initial_monitor;
};
typedef struct _GimpDisplayShellOverlay GimpDisplayShellOverlay;
@ -194,6 +199,7 @@ static gboolean gimp_display_shell_draw (GimpDisplayShell *shell,
G_DEFINE_TYPE_WITH_CODE (GimpDisplayShell, gimp_display_shell,
GTK_TYPE_EVENT_BOX,
G_ADD_PRIVATE (GimpDisplayShell)
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
gimp_display_shell_progress_iface_init)
G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED,
@ -336,6 +342,9 @@ gimp_display_shell_init (GimpDisplayShell *shell)
{
const gchar *env;
shell->priv = gimp_display_shell_get_instance_private (shell);
shell->priv->initial_monitor = NULL;
shell->options = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS, NULL);
shell->fullscreen_options = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_FULLSCREEN, NULL);
shell->no_image_options = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_NO_IMAGE, NULL);
@ -492,7 +501,7 @@ gimp_display_shell_constructed (GObject *object)
if (config->monitor_res_from_gdk)
{
gimp_get_monitor_resolution (shell->initial_monitor,
gimp_get_monitor_resolution (shell->priv->initial_monitor,
&shell->monitor_xres, &shell->monitor_yres);
}
else
@ -817,6 +826,9 @@ gimp_display_shell_constructed (GObject *object)
gimp_display_shell_scale_update (shell);
gimp_display_shell_set_show_all (shell, config->default_show_all);
/* This was only useful during construction and should not be further used. */
shell->priv->initial_monitor = NULL;
}
static void
@ -926,7 +938,7 @@ gimp_display_shell_set_property (GObject *object,
shell->popup_manager = g_value_get_object (value);
break;
case PROP_INITIAL_MONITOR:
shell->initial_monitor = g_value_get_object (value);
shell->priv->initial_monitor = g_value_get_object (value);
break;
case PROP_DISPLAY:
shell->display = g_value_get_object (value);
@ -966,7 +978,7 @@ gimp_display_shell_get_property (GObject *object,
g_value_set_object (value, shell->popup_manager);
break;
case PROP_INITIAL_MONITOR:
g_value_set_object (value, shell->initial_monitor);
g_value_set_object (value, shell->priv->initial_monitor);
break;
case PROP_DISPLAY:
g_value_set_object (value, shell->display);

View file

@ -43,7 +43,8 @@
#define GIMP_DISPLAY_SHELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShellClass))
typedef struct _GimpDisplayShellClass GimpDisplayShellClass;
typedef struct _GimpDisplayShellClass GimpDisplayShellClass;
typedef struct _GimpDisplayShellPrivate GimpDisplayShellPrivate;
struct _GimpDisplayShell
{
@ -54,7 +55,6 @@ struct _GimpDisplayShell
GBytes *window_handle;
GimpUIManager *popup_manager;
GdkMonitor *initial_monitor;
GimpDisplayOptions *options;
GimpDisplayOptions *fullscreen_options;
@ -255,6 +255,8 @@ struct _GimpDisplayShell
GimpLayer *near_layer_vertical2;
gboolean drawn;
GimpDisplayShellPrivate *priv;
};
struct _GimpDisplayShellClass

View file

@ -569,6 +569,9 @@ gimp_image_window_constructed (GObject *object)
gimp_container_foreach (GIMP_CONTAINER (device_manager),
(GFunc) gimp_image_window_init_pad_foreach,
window);
/* This was only useful during construction and should not be further used. */
private->initial_monitor = NULL;
}
static void