app: fix #12542 crash due to invalid monitor

We store an `initial_monitor` in several places, not taking into
consideration that a monitor object can become invalid, e.g. when
disconnecting or turning off a monitor. When the monitor is invalid,
it can cause a crash in `gimp_display_shell_set_initial_scale`.

Instead of referencing the initial monitor, we request the monitor for
our display shell. Since at that point we already know that shell is
valid, we should get a valid monitor too.
This commit is contained in:
Jacob Boerema 2025-04-16 13:21:23 -04:00 committed by Jehan
parent 2fc1fdd400
commit fedb647cb4

View file

@ -933,7 +933,7 @@ gimp_display_shell_set_initial_scale (GimpDisplayShell *shell,
image = gimp_display_get_image (shell->display);
gdk_monitor_get_workarea (shell->initial_monitor, &workarea);
gdk_monitor_get_workarea (gimp_widget_get_monitor (GTK_WIDGET (shell)), &workarea);
image_width = gimp_image_get_width (image);
image_height = gimp_image_get_height (image);