From patchwork Tue May 31 20:56:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 9145657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F151160777 for ; Tue, 31 May 2016 20:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E46B02040D for ; Tue, 31 May 2016 20:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D996E263DC; Tue, 31 May 2016 20:57:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E4D22040D for ; Tue, 31 May 2016 20:57:24 +0000 (UTC) Received: from localhost ([::1]:38423 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7qj4-0001OT-VP for patchwork-qemu-devel@patchwork.kernel.org; Tue, 31 May 2016 16:57:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7qir-0001OI-2c for qemu-devel@nongnu.org; Tue, 31 May 2016 16:57:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7qin-000131-Gr for qemu-devel@nongnu.org; Tue, 31 May 2016 16:57:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7qin-00012w-Ap for qemu-devel@nongnu.org; Tue, 31 May 2016 16:57:05 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 117C67F092 for ; Tue, 31 May 2016 20:57:04 +0000 (UTC) Received: from worklaptop.bos.redhat.com (unused [10.16.197.141] (may be forged)) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4VKv3R3014697; Tue, 31 May 2016 16:57:03 -0400 From: Cole Robinson To: qemu-devel@nongnu.org Date: Tue, 31 May 2016 16:56:55 -0400 Message-Id: <2e555d67b7e53a86bef98f774a2706f2b0ec4ea0.1464728215.git.crobinso@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 31 May 2016 20:57:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , Cole Robinson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP $ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -sdl Segmentation fault (core dumped) 0 0x00005555559631af in sdl_display_init (ds=, full_screen=0, no_frame=) at ui/sdl2.c:822 1 0x00005555556c8a9a in main (argc=, argv=, envp=) 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) {