Browse Source

Merge pull request #205 from bruceoutdoors/invaders-sample-fix

Fixes NULL pointer dereference due to the window being resized before shell_renderer is set, which results shell_renderer->SetViewport causing an exception.
David Wimsey 11 years ago
parent
commit
a3317ea5f3
1 changed files with 8 additions and 8 deletions
  1. 8 8
      Samples/shell/src/win32/ShellWin32.cpp

+ 8 - 8
Samples/shell/src/win32/ShellWin32.cpp

@@ -137,14 +137,6 @@ bool Shell::OpenWindow(const char* name, ShellRenderInterfaceExtensions *_shell_
 	SetWindowLong(window_handle, GWL_EXSTYLE, extended_style);
 	SetWindowLong(window_handle, GWL_STYLE, style);
 
-	// Resize the window.
-	SetWindowPos(window_handle, HWND_TOP, 0, 0, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, SWP_NOACTIVATE);
-
-	// Display the new window
-	ShowWindow(window_handle, SW_SHOW);
-	SetForegroundWindow(window_handle);
-	SetFocus(window_handle);
-
 	if (_shell_renderer != NULL)
 	{
 		shell_renderer = _shell_renderer;
@@ -155,6 +147,14 @@ bool Shell::OpenWindow(const char* name, ShellRenderInterfaceExtensions *_shell_
 		}
 	}
 
+	// Resize the window.
+	SetWindowPos(window_handle, HWND_TOP, 0, 0, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, SWP_NOACTIVATE);
+
+	// Display the new window
+	ShowWindow(window_handle, SW_SHOW);
+	SetForegroundWindow(window_handle);
+	SetFocus(window_handle);
+
     return true;
 }