Skip to contentSkip to conversation

gtk: drop pointless code from gd_window_close

PATCH In review Gerd Hoffmann 3 participants 3 messages Mar 14, 2018 – Mar 16, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gtk: drop pointless code from gd_window_close

Unregistering the display change listener looks like a pointless excercise given we'll exit in a moment. When exiting qemu via menu/file/quit this will not happen either. Just drop the code.

Also return TRUE unconditionally. This will tell gtk to ignore the close request, so gtk will not start destroying widgets and causing warnings due to UI code trying to talk to widgets which are gone. Just depend on qmp_quit() doing it's job instead.

---
 ui/gtk.c | 8 --------
 1 file changed, 8 deletions(-)
ui/gtk.c +0 -8
index ef5bc42094..2925c66e0b 100644
@@ -786,21 +786,13 @@ static gboolean gd_window_close(GtkWidget *widget, GdkEvent *event,
 {
     GtkDisplayState *s = opaque;
     bool allow_close = true;
-    int i;
 
     if (s->opts->has_window_close && !s->opts->window_close) {
         allow_close = false;
     }
 
     if (allow_close) {
-        for (i = 0; i < s->nb_vcs; i++) {
-            if (s->vc[i].type != GD_VC_GFX) {
-                continue;
-            }
-            unregister_displaychangelistener(&s->vc[i].gfx.dcl);
-        }
         qmp_quit(NULL);
-        return FALSE;
     }
 
     return TRUE;
Signature · 1 line
2.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Gerd Hoffmann

Unregistering the display change listener looks like a pointless excercise given we'll exit in a moment. When exiting qemu via

exercise

Quoted 9 lines

menu/file/quit this will not happen either. Just drop the code.

Also return TRUE unconditionally. This will tell gtk to ignore the close request, so gtk will not start destroying widgets and causing warnings due to UI code trying to talk to widgets which are gone. Just depend on qmp_quit() doing it's job instead.

Looks fine to me.

Mark, is your issue resolved? (you might add your Tested-by).

Quoted 31 lines
---
 ui/gtk.c | 8 --------
 1 file changed, 8 deletions(-)
ui/gtk.c +0 -8
index ef5bc42094..2925c66e0b 100644
@@ -786,21 +786,13 @@ static gboolean gd_window_close(GtkWidget *widget, GdkEvent *event,
 {
     GtkDisplayState *s = opaque;
     bool allow_close = true;
-    int i;
 
     if (s->opts->has_window_close && !s->opts->window_close) {
         allow_close = false;
     }
 
     if (allow_close) {
-        for (i = 0; i < s->nb_vcs; i++) {
-            if (s->vc[i].type != GD_VC_GFX) {
-                continue;
-            }
-            unregister_displaychangelistener(&s->vc[i].gfx.dcl);
-        }
         qmp_quit(NULL);
-        return FALSE;
     }
 
     return TRUE;
#2 lore raw
Quoted 13 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Gerd Hoffmann

Unregistering the display change listener looks like a pointless excercise given we'll exit in a moment. When exiting qemu via

exercise

Quoted 7 lines

menu/file/quit this will not happen either. Just drop the code.

Also return TRUE unconditionally. This will tell gtk to ignore the close request, so gtk will not start destroying widgets and causing warnings due to UI code trying to talk to widgets which are gone. Just depend on qmp_quit() doing it's job instead.

Quoted 7 lines
Quoted 2 lines

Looks fine to me.

Mark, is your issue resolved? (you might add your Tested-by).

Yes, I can confirm that this patch fixes my test case.

ATB,

Mark.