mcst-linux-kernel/patches-2024.06.26/atril-1.24.1/0001-Fix-segfault-when-usin...

26 lines
822 B
Diff

Link:
Subject: fix get_monitor_dpi when widget's window is not realized (aka shell)
Bug: 131216
Tags: common
--- a/previewer/ev-previewer-window.c 2021-03-31 22:20:31.890203388 +0300
+++ b/previewer/ev-previewer-window.c 2021-03-31 22:26:55.299077479 +0300
@@ -75,8 +75,14 @@
GdkDisplay *display;
gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
- display = gdk_window_get_display (gdk_window);
- monitor = gdk_display_get_monitor_at_window (display, gdk_window);
+
+ if (gdk_window) {
+ display = gdk_window_get_display (gdk_window);
+ monitor = gdk_display_get_monitor_at_window (display, gdk_window);
+ } else {
+ display = gdk_display_get_default();
+ monitor = gdk_display_get_primary_monitor(display);
+ }
return ev_document_misc_get_monitor_dpi (monitor);
}