From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 From: Lei Li Date: Tue, 27 Aug 2013 18:55:14 +0800 Message-Id: <1377600914-21259-1-git-send-email-lilei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] sdl: Reverse support for video mode setting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: sascha@srlabs.de, anthony@codemonkey.ws, Lei Li 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, -- 1.7.7.6