Windows: Clean up window in case of exception thrown from WindowsDisplay.createWindow

This commit is contained in:
Elias Naur 2008-05-02 11:05:49 +00:00
parent b11fcc99f6
commit b6b83936ac
1 changed files with 12 additions and 7 deletions

View File

@ -173,13 +173,18 @@ final class WindowsDisplay implements DisplayImplementation {
nDestroyWindow(hwnd, hdc); nDestroyWindow(hwnd, hdc);
throw new LWJGLException("Failed to get dc"); throw new LWJGLException("Failed to get dc");
} }
peer_info.initDC(getHwnd(), getHdc()); try {
int format = WindowsPeerInfo.choosePixelFormat(getHdc(), 0, 0, peer_info.getPixelFormat(), null, true, true, false, true); int format = WindowsPeerInfo.choosePixelFormat(getHdc(), 0, 0, peer_info.getPixelFormat(), null, true, true, false, true);
WindowsPeerInfo.setPixelFormat(getHdc(), format); WindowsPeerInfo.setPixelFormat(getHdc(), format);
showWindow(getHwnd(), SW_SHOWDEFAULT); peer_info.initDC(getHwnd(), getHdc());
if (parent == null) { showWindow(getHwnd(), SW_SHOWDEFAULT);
setForegroundWindow(getHwnd()); if (parent == null) {
setFocus(getHwnd()); setForegroundWindow(getHwnd());
setFocus(getHwnd());
}
} catch (LWJGLException e) {
nDestroyWindow(hwnd, hdc);
throw e;
} }
} }
private native long nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; private native long nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException;