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: 68953 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2180583qge; Tue, 31 May 2016 13:58:19 -0700 (PDT) X-Received: by 10.55.24.20 with SMTP id j20mr10625205qkh.168.1464728299748; Tue, 31 May 2016 13:58:19 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b23si15963936qkc.242.2016.05.31.13.58.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 31 May 2016 13:58:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:38425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7qjz-00022o-9m for patch@linaro.org; Tue, 31 May 2016 16:58:19 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" $ ./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(-) -- 2.5.5 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) {