From patchwork Tue Aug 27 10:55:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Li X-Patchwork-Id: 270084 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E301B2C00D8 for ; Tue, 27 Aug 2013 20:57:19 +1000 (EST) Received: from localhost ([::1]:55494 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEGxa-0008CK-01 for incoming@patchwork.ozlabs.org; Tue, 27 Aug 2013 06:57:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEGxC-0008Bp-Uf for qemu-devel@nongnu.org; Tue, 27 Aug 2013 06:57:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEGx3-0000rW-69 for qemu-devel@nongnu.org; Tue, 27 Aug 2013 06:56:54 -0400 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:44850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEGx2-0000qz-IO for qemu-devel@nongnu.org; Tue, 27 Aug 2013 06:56:45 -0400 Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Aug 2013 20:45:29 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 27 Aug 2013 20:45:27 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 852592BB004F for ; Tue, 27 Aug 2013 20:56:33 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7RAuLPH61931660 for ; Tue, 27 Aug 2013 20:56:22 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r7RAuVYK011237 for ; Tue, 27 Aug 2013 20:56:32 +1000 Received: from localhost.localdomain ([9.125.29.84]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r7RAuUdq011166; Tue, 27 Aug 2013 20:56:30 +1000 From: Lei Li To: qemu-devel@nongnu.org Date: Tue, 27 Aug 2013 18:55:14 +0800 Message-Id: <1377600914-21259-1-git-send-email-lilei@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7.6 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13082710-6102-0000-0000-000004148692 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.145 Cc: sascha@srlabs.de, anthony@codemonkey.ws, Lei Li Subject: [Qemu-devel] [PATCH] sdl: Reverse support for video mode setting X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Currently, If the setting of video mode failed, qemu will exit. It should go back to the previous setting if the new screen resolution failed. This patch fixes LP#1216368, add support to revert to existing surface for the failure of video mode setting. Reported-by: Sascha Krissler Signed-off-by: Lei Li --- ui/sdl.c | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ui/sdl.c b/ui/sdl.c index 39a42d6..9d8583c 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -86,6 +86,7 @@ static void sdl_update(DisplayChangeListener *dcl, static void do_sdl_resize(int width, int height, int bpp) { int flags; + SDL_Surface *tmp_screen; // printf("resizing to %d %d\n", w, h); @@ -98,12 +99,26 @@ static void do_sdl_resize(int width, int height, int bpp) if (gui_noframe) flags |= SDL_NOFRAME; - real_screen = SDL_SetVideoMode(width, height, bpp, flags); + tmp_screen = SDL_SetVideoMode(width, height, bpp, flags); if (!real_screen) { - fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n", width, - height, bpp, SDL_GetError()); - exit(1); + if (!tmp_screen) { + fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n", + width, height, bpp, SDL_GetError()); + exit(1); + } + } else { + /* + * Revert to the previous video mode if the change of resizing or + * resolution failed. + */ + if (!tmp_screen) { + fprintf(stderr, "Failed to set SDL display (%dx%dx%d): %s\n", + width, height, bpp, SDL_GetError()); + return; + } } + + real_screen = tmp_screen; } static void sdl_switch(DisplayChangeListener *dcl,