qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized
@ 2020-02-08 16:10 Philippe Mathieu-Daudé
  2020-02-08 16:10 ` [PATCH v2 1/2] ui/gtk: Update gd_refresh_rate_millihz() to handle VirtualConsole Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-08 16:10 UTC (permalink / raw)
  To: qemu-devel, Jan Kiszka
  Cc: Philippe Mathieu-Daudé, Gerd Hoffmann, Nikola Pavlica

Fix bug report from Jan Kiszka:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg678130.html
https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg02260.html

Supersedes: <20200208143008.6157-1-f4bug@amsat.org>

Philippe Mathieu-Daudé (2):
  ui/gtk: Update gd_refresh_rate_millihz() to handle VirtualConsole
  ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not
    realized

 ui/gtk.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

-- 
2.21.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] ui/gtk: Update gd_refresh_rate_millihz() to handle VirtualConsole
  2020-02-08 16:10 [PATCH v2 0/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized Philippe Mathieu-Daudé
@ 2020-02-08 16:10 ` Philippe Mathieu-Daudé
  2020-02-08 16:10 ` [PATCH v2 2/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-08 16:10 UTC (permalink / raw)
  To: qemu-devel, Jan Kiszka
  Cc: Philippe Mathieu-Daudé, Gerd Hoffmann, Nikola Pavlica

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 ui/gtk.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index d18892d1de..c59297ff4d 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1965,11 +1965,11 @@ static GtkWidget *gd_create_menu_machine(GtkDisplayState *s)
  * If available, return the refresh rate of the display in milli-Hertz,
  * else return 0.
  */
-static int gd_refresh_rate_millihz(GtkDisplayState *s)
+static int gd_refresh_rate_millihz(GtkWidget *window)
 {
 #ifdef GDK_VERSION_3_22
-    GdkDisplay *dpy = gtk_widget_get_display(s->window);
-    GdkWindow *win = gtk_widget_get_window(s->window);
+    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);
@@ -2045,7 +2045,8 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
     vc->gfx.kbd = qkbd_state_init(con);
     vc->gfx.dcl.con = con;
 
-    refresh_rate_millihz = gd_refresh_rate_millihz(s);
+    refresh_rate_millihz = gd_refresh_rate_millihz(vc->window ?
+                                                   vc->window : s->window);
     if (refresh_rate_millihz) {
         vc->gfx.dcl.update_interval = MILLISEC_PER_SEC / refresh_rate_millihz;
     }
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized
  2020-02-08 16:10 [PATCH v2 0/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized Philippe Mathieu-Daudé
  2020-02-08 16:10 ` [PATCH v2 1/2] ui/gtk: Update gd_refresh_rate_millihz() to handle VirtualConsole Philippe Mathieu-Daudé
@ 2020-02-08 16:10 ` Philippe Mathieu-Daudé
  2020-02-08 17:27 ` [PATCH v2 0/2] " Jan Kiszka
  2020-02-12 12:23 ` Gerd Hoffmann
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-08 16:10 UTC (permalink / raw)
  To: qemu-devel, Jan Kiszka
  Cc: Philippe Mathieu-Daudé, Gerd Hoffmann, Nikola Pavlica

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>
---
 ui/gtk.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index c59297ff4d..850c49bee0 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
-    return 0;
+    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;
 }
 
 static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized
  2020-02-08 16:10 [PATCH v2 0/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized Philippe Mathieu-Daudé
  2020-02-08 16:10 ` [PATCH v2 1/2] ui/gtk: Update gd_refresh_rate_millihz() to handle VirtualConsole Philippe Mathieu-Daudé
  2020-02-08 16:10 ` [PATCH v2 2/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized Philippe Mathieu-Daudé
@ 2020-02-08 17:27 ` Jan Kiszka
  2020-02-12 12:23 ` Gerd Hoffmann
  3 siblings, 0 replies; 5+ messages in thread
From: Jan Kiszka @ 2020-02-08 17:27 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Gerd Hoffmann, Nikola Pavlica

On 08.02.20 17:10, Philippe Mathieu-Daudé wrote:
> Fix bug report from Jan Kiszka:
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg678130.html
> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg02260.html
>
> Supersedes: <20200208143008.6157-1-f4bug@amsat.org>
>
> Philippe Mathieu-Daudé (2):
>    ui/gtk: Update gd_refresh_rate_millihz() to handle VirtualConsole
>    ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not
>      realized
>
>   ui/gtk.c | 19 +++++++++++--------
>   1 file changed, 11 insertions(+), 8 deletions(-)
>

Yep.

Tested-by: Jan Kiszka <jan.kiszka@web.de>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized
  2020-02-08 16:10 [PATCH v2 0/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2020-02-08 17:27 ` [PATCH v2 0/2] " Jan Kiszka
@ 2020-02-12 12:23 ` Gerd Hoffmann
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2020-02-12 12:23 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Jan Kiszka, qemu-devel, Nikola Pavlica

On Sat, Feb 08, 2020 at 05:10:46PM +0100, Philippe Mathieu-Daudé wrote:
> Fix bug report from Jan Kiszka:
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg678130.html
> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg02260.html

Added to UI queue.

thanks,
  Gerd



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-12 12:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-08 16:10 [PATCH v2 0/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized Philippe Mathieu-Daudé
2020-02-08 16:10 ` [PATCH v2 1/2] ui/gtk: Update gd_refresh_rate_millihz() to handle VirtualConsole Philippe Mathieu-Daudé
2020-02-08 16:10 ` [PATCH v2 2/2] ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized Philippe Mathieu-Daudé
2020-02-08 17:27 ` [PATCH v2 0/2] " Jan Kiszka
2020-02-12 12:23 ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).