All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	libvir-list@redhat.com, "Markus Armbruster" <armbru@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PULL 02/10] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized
Date: Wed, 12 Feb 2020 17:18:27 +0100	[thread overview]
Message-ID: <20200212161835.28576-3-kraxel@redhat.com> (raw)
In-Reply-To: <20200212161835.28576-1-kraxel@redhat.com>

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

gtk_widget_get_window() returns NULL if the widget's window is not
realized, and QEMU crashes. Example under gtk 3.22.30 (mate 1.20.1):

  qemu-system-x86_64: Gdk: gdk_window_get_origin: assertion 'GDK_IS_WINDOW (window)' failed
  (gdb) bt
  #0  0x00007ffff496cf70 in gdk_window_get_origin () from /usr/lib64/libgdk-3.so.0
  #1  0x00007ffff49582a0 in gdk_display_get_monitor_at_window () from /usr/lib64/libgdk-3.so.0
  #2  0x0000555555bb73e2 in gd_refresh_rate_millihz (window=0x5555579d6280) at ui/gtk.c:1973
  #3  gd_vc_gfx_init (view_menu=0x5555579f0590, group=0x0, idx=0, con=<optimized out>, vc=0x5555579d4a90, s=0x5555579d49f0) at ui/gtk.c:2048
  #4  gd_create_menu_view (s=0x5555579d49f0) at ui/gtk.c:2149
  #5  gd_create_menus (s=0x5555579d49f0) at ui/gtk.c:2188
  #6  gtk_display_init (ds=<optimized out>, opts=0x55555661ed80 <dpy>) at ui/gtk.c:2256
  #7  0x000055555583d5a0 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4358

Fixes: c4c00922cc and 28b58f19d2 (display/gtk: get proper refreshrate)
Reported-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Jan Kiszka <jan.kiszka@web.de>
Message-id: 20200208161048.11311-3-f4bug@amsat.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index c59297ff4d2e..850c49bee02a 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1968,14 +1968,16 @@ static GtkWidget *gd_create_menu_machine(GtkDisplayState *s)
 static int gd_refresh_rate_millihz(GtkWidget *window)
 {
 #ifdef GDK_VERSION_3_22
-    GdkDisplay *dpy = gtk_widget_get_display(window);
     GdkWindow *win = gtk_widget_get_window(window);
-    GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
 
-    return gdk_monitor_get_refresh_rate(monitor);
-#else
+    if (win) {
+        GdkDisplay *dpy = gtk_widget_get_display(window);
+        GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
+
+        return gdk_monitor_get_refresh_rate(monitor);
+    }
+#endif
     return 0;
-#endif
 }
 
 static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
-- 
2.18.2



  parent reply	other threads:[~2020-02-12 16:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 16:18 [PULL 00/10] Ui 20200212 patches Gerd Hoffmann
2020-02-12 16:18 ` [PULL 01/10] ui/gtk: Update gd_refresh_rate_millihz() to handle VirtualConsole Gerd Hoffmann
2020-02-12 16:18 ` Gerd Hoffmann [this message]
2020-02-12 16:18 ` [PULL 03/10] ui: add show-cursor option Gerd Hoffmann
2020-02-12 16:18 ` [PULL 04/10] ui: wire up legacy -show-cursor option Gerd Hoffmann
2020-02-12 16:18 ` [PULL 05/10] ui/sdl: switch to new show-cursor option Gerd Hoffmann
2020-02-12 16:18 ` [PULL 06/10] ui/cocoa: " Gerd Hoffmann
2020-02-12 16:18 ` [PULL 07/10] ui/gtk: implement " Gerd Hoffmann
2020-02-12 16:18 ` [PULL 08/10] ui: drop curor_hide global variable Gerd Hoffmann
2020-02-12 16:18 ` [PULL 09/10] ui: deprecate legacy -show-cursor option Gerd Hoffmann
2020-02-12 16:18 ` [PULL 10/10] ui/cocoa: Drop workarounds for pre-10.12 OSX Gerd Hoffmann
2020-02-13 13:40 ` [PULL 00/10] Ui 20200212 patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200212161835.28576-3-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=armbru@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=libvir-list@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.