qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl


From: Cole Robinson
Subject: [Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl
Date: Tue, 31 May 2016 16:56:55 -0400

$ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -sdl
Segmentation fault (core dumped)

0  0x00005555559631af in sdl_display_init (ds=<optimized out>, full_screen=0, 
no_frame=<optimized out>) at ui/sdl2.c:822
1  0x00005555556c8a9a in main (argc=<optimized out>, argv=<optimized out>, 
envp=<optimized out>) at vl.c:4527

Setting the window icon assumes there's always an SDL output window
available, which isn't the case with when there's no video device,
like via -nodefaults. So don't try to set a window icon when we don't
have any outputs.

https://bugzilla.redhat.com/show_bug.cgi?id=1340931
---
 ui/sdl2.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/ui/sdl2.c b/ui/sdl2.c
index 909038f..d0e0a41 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -812,16 +812,18 @@ void sdl_display_init(DisplayState *ds, int full_screen, 
int no_frame)
         register_displaychangelistener(&sdl2_console[i].dcl);
     }
 
-    /* Load a 32x32x4 image. White pixels are transparent. */
-    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
-    if (filename) {
-        SDL_Surface *image = SDL_LoadBMP(filename);
-        if (image) {
-            uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
-            SDL_SetColorKey(image, SDL_TRUE, colorkey);
-            SDL_SetWindowIcon(sdl2_console[0].real_window, image);
+    if (sdl2_num_outputs) {
+        /* Load a 32x32x4 image. White pixels are transparent. */
+        filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
+        if (filename) {
+            SDL_Surface *image = SDL_LoadBMP(filename);
+            if (image) {
+                uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
+                SDL_SetColorKey(image, SDL_TRUE, colorkey);
+                SDL_SetWindowIcon(sdl2_console[0].real_window, image);
+            }
+            g_free(filename);
         }
-        g_free(filename);
     }
 
     if (full_screen) {
-- 
2.5.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]