From 4318e6a147e78b2663c5e0ea6ba0d351a1e87f98 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sat, 5 Mar 2011 17:34:42 +0000 Subject: [PATCH] Cygwin/X: Handle failure during winScreenInit() Handle failure during winScreenInit() a bit more cleanly, rather than crashing This avoids a crash with 'XWin -fullscreen -screen 0 @2 -screen 1 @1' Also document that fullscreen may only be applied to one screen. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison Tested-by: Colin Harrison --- hw/xwin/man/XWin.man | 3 ++- hw/xwin/winpfbdd.c | 3 ++- hw/xwin/winscrinit.c | 4 ++++ hw/xwin/winshaddd.c | 3 ++- hw/xwin/winshadddnl.c | 3 ++- hw/xwin/winshadgdi.c | 3 ++- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man index e7933c9c8..aad29cf25 100644 --- a/hw/xwin/man/XWin.man +++ b/hw/xwin/man/XWin.man @@ -67,7 +67,7 @@ The default behaviour is to create a single screen 0 that is roughly the size of useful area of the primary monitor (allowing for any window decorations and the task-bar). -Screen specific parameters, such as \fB\-fullscreen\fP, can be applied as a +Screen specific parameters can be applied as a default to all screens by placing those screen specific parameters before any \fB\-screen\fP parameter. Screen specific parameters placed after the first \fB\-screen\fP parameter will apply only to the immediately @@ -108,6 +108,7 @@ in \fB-multiwindow\fP or \fB-rootless\fP mode. .B "\-fullscreen" The X server window takes the full screen, covering completely the \fIWindows\fP desktop. +Currently \fB\-fullscreen\fP may only be applied to one X screen. .TP 8 .B \-nodecoration Do not give the Cygwin/X window a \fIWindows\fP window border, title bar, diff --git a/hw/xwin/winpfbdd.c b/hw/xwin/winpfbdd.c index c0bca71e3..a3990208d 100644 --- a/hw/xwin/winpfbdd.c +++ b/hw/xwin/winpfbdd.c @@ -294,7 +294,8 @@ winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen) /* Call the wrapped CloseScreen procedure */ WIN_UNWRAP(CloseScreen); - fReturn = (*pScreen->CloseScreen) (nIndex, pScreen); + if (pScreen->CloseScreen) + fReturn = (*pScreen->CloseScreen) (nIndex, pScreen); /* Delete the window property */ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP); diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c index 691237e6f..983ff5730 100644 --- a/hw/xwin/winscrinit.c +++ b/hw/xwin/winscrinit.c @@ -220,6 +220,10 @@ winScreenInit (int index, if (!((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv))) { ErrorF ("winScreenInit - winFinishScreenInit () failed\n"); + + /* call the engine dependent screen close procedure to clean up from a failure */ + pScreenPriv->pwinCloseScreen(index, pScreen); + return FALSE; } diff --git a/hw/xwin/winshaddd.c b/hw/xwin/winshaddd.c index 00d7a379f..6dad2782f 100644 --- a/hw/xwin/winshaddd.c +++ b/hw/xwin/winshaddd.c @@ -728,7 +728,8 @@ winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen) /* Call the wrapped CloseScreen procedure */ WIN_UNWRAP(CloseScreen); - fReturn = (*pScreen->CloseScreen) (nIndex, pScreen); + if (pScreen->CloseScreen) + fReturn = (*pScreen->CloseScreen) (nIndex, pScreen); winFreeFBShadowDD(pScreen); diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c index 0a0b4ae13..63d48adb6 100644 --- a/hw/xwin/winshadddnl.c +++ b/hw/xwin/winshadddnl.c @@ -802,7 +802,8 @@ winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen) /* Call the wrapped CloseScreen procedure */ WIN_UNWRAP(CloseScreen); - fReturn = (*pScreen->CloseScreen) (nIndex, pScreen); + if (pScreen->CloseScreen) + fReturn = (*pScreen->CloseScreen) (nIndex, pScreen); winFreeFBShadowDDNL(pScreen); diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c index 499037656..1e7cb006c 100644 --- a/hw/xwin/winshadgdi.c +++ b/hw/xwin/winshadgdi.c @@ -636,7 +636,8 @@ winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen) /* Call the wrapped CloseScreen procedure */ WIN_UNWRAP(CloseScreen); - fReturn = (*pScreen->CloseScreen) (nIndex, pScreen); + if (pScreen->CloseScreen) + fReturn = (*pScreen->CloseScreen) (nIndex, pScreen); /* Delete the window property */ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);