Fix a crash when closing DirectX's window, also apply a fix from j4ck.fr0st/BhaaL @ issue 1277 to prevent two possibles hang on stop.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4756 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
151ff28ab7
commit
18e951f97a
|
@ -21,7 +21,7 @@ typedef void (*TRequestWindowSize)(int _iWidth, int _iHeight, bool _bFullscree
|
||||||
typedef void (*TCopiedToXFB)(bool video_update);
|
typedef void (*TCopiedToXFB)(bool video_update);
|
||||||
typedef unsigned int (*TPeekMessages)(void);
|
typedef unsigned int (*TPeekMessages)(void);
|
||||||
typedef void (*TUpdateFPSDisplay)(const char* text); // sets the window title
|
typedef void (*TUpdateFPSDisplay)(const char* text); // sets the window title
|
||||||
typedef void (*TKeyPressed)(int keycode, bool shift, bool control); // sets the window title
|
typedef void (*TKeyPressed)(int keycode, bool shift, bool control); // passes keys to the hotkey function
|
||||||
|
|
||||||
enum FieldType
|
enum FieldType
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,13 +84,14 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Tell the hotkey function that this key was pressed
|
||||||
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
|
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
switch( LOWORD( wParam ))
|
switch( LOWORD( wParam ))
|
||||||
{
|
{
|
||||||
case VK_RETURN: // Pressing Esc switch FullScreen/Windowed
|
case VK_RETURN: // Pressing Alt+Enter switch FullScreen/Windowed
|
||||||
if (g_ActiveConfig.bFullscreen)
|
if (g_ActiveConfig.bFullscreen)
|
||||||
{
|
{
|
||||||
DestroyWindow(hWnd);
|
DestroyWindow(hWnd);
|
||||||
|
@ -112,26 +113,15 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
Fifo_ExitLoopNonBlocking();
|
// When the user closes the window, we post an event to the main window to call Stop()
|
||||||
//Shutdown();
|
// Which then handles all the necessary steps to Shutdown the core + the plugins
|
||||||
// Simple hack to easily exit without stopping. Hope to fix the stopping errors soon.
|
PostMessage( m_hMain, WM_USER, WM_USER_STOP, 0 );
|
||||||
//ExitProcess(0);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_DESTROY:
|
|
||||||
//Shutdown();
|
|
||||||
//PostQuitMessage( 0 );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_USER:
|
case WM_USER:
|
||||||
// if (wParam == TOGGLE_FULLSCREEN)
|
// if (wParam == TOGGLE_FULLSCREEN)
|
||||||
// TODO : Insert some toggle fullscreen code here, kthx :d
|
// TODO : Insert some toggle fullscreen code here, kthx :d
|
||||||
break;
|
// see TODO ^ upper
|
||||||
|
|
||||||
case WM_SIZE:
|
|
||||||
// Reset the D3D Device here
|
|
||||||
// Also make damn sure that this is not called from inside rendering a frame :P
|
|
||||||
// Renderer::ReinitView();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
|
|
|
@ -451,7 +451,7 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y)
|
||||||
|
|
||||||
if (g_VideoInitialize.bOnThread)
|
if (g_VideoInitialize.bOnThread)
|
||||||
{
|
{
|
||||||
while (Common::AtomicLoadAcquire(s_efbAccessRequested))
|
while (Common::AtomicLoadAcquire(s_efbAccessRequested) && s_initialized)
|
||||||
Common::YieldCPU();
|
Common::YieldCPU();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -342,7 +342,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||||
OnKeyDown(lParam);
|
OnKeyDown(lParam);
|
||||||
FreeLookInput(wParam, lParam);
|
FreeLookInput(wParam, lParam);
|
||||||
}
|
}
|
||||||
if (wParam == TOGGLE_FULLSCREEN)
|
if (wParam == TOGGLE_FULLSCREEN && !g_Config.RenderToMainframe)
|
||||||
ToggleFullscreen(m_hWnd);
|
ToggleFullscreen(m_hWnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ void ToggleFullscreen(HWND hParent)
|
||||||
SetWindowPos(hParent, NULL, X, Y, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
|
SetWindowPos(hParent, NULL, X, Y, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
|
||||||
|
|
||||||
// Set new window style FS -> Windowed
|
// Set new window style FS -> Windowed
|
||||||
SetWindowLong(hParent, GWL_STYLE, WS_OVERLAPPEDWINDOW);
|
SetWindowLongPtr(hParent, GWL_STYLE, WS_OVERLAPPEDWINDOW);
|
||||||
|
|
||||||
// Eventually show the window!
|
// Eventually show the window!
|
||||||
EmuWindow::Show();
|
EmuWindow::Show();
|
||||||
|
@ -497,18 +497,18 @@ void ToggleFullscreen(HWND hParent)
|
||||||
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
||||||
dmScreenSettings.dmPelsWidth = w_fs;
|
dmScreenSettings.dmPelsWidth = w_fs;
|
||||||
dmScreenSettings.dmPelsHeight = h_fs;
|
dmScreenSettings.dmPelsHeight = h_fs;
|
||||||
dmScreenSettings.dmBitsPerPel = 32;
|
dmScreenSettings.dmFields = DM_PELSWIDTH|DM_PELSHEIGHT;
|
||||||
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
|
if (ChangeDisplaySettings(&dmScreenSettings, 0) != DISP_CHANGE_SUCCESSFUL)
|
||||||
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set new window style -> PopUp
|
// Set new window style -> PopUp
|
||||||
SetWindowLong(hParent, GWL_STYLE, WS_POPUP);
|
SetWindowLongPtr(hParent, GWL_STYLE, WS_POPUP);
|
||||||
g_Config.bFullscreen = true;
|
|
||||||
ShowCursor(FALSE);
|
|
||||||
|
|
||||||
// SetWindowPos to the upper-left corner of the screen
|
// SetWindowPos to the upper-left corner of the screen
|
||||||
SetWindowPos(hParent, NULL, 0, 0, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
|
SetWindowPos(hParent, HWND_TOP, 0, 0, w_fs, h_fs, SWP_NOREPOSITION);
|
||||||
|
|
||||||
|
g_Config.bFullscreen = true;
|
||||||
|
ShowCursor(FALSE);
|
||||||
|
|
||||||
// Eventually show the window!
|
// Eventually show the window!
|
||||||
EmuWindow::Show();
|
EmuWindow::Show();
|
||||||
|
|
|
@ -410,6 +410,7 @@ void Video_Prepare(void)
|
||||||
void Shutdown(void)
|
void Shutdown(void)
|
||||||
{
|
{
|
||||||
s_PluginInitialized = false;
|
s_PluginInitialized = false;
|
||||||
|
ForceSwap = true;
|
||||||
|
|
||||||
s_efbAccessRequested = FALSE;
|
s_efbAccessRequested = FALSE;
|
||||||
s_swapRequested = FALSE;
|
s_swapRequested = FALSE;
|
||||||
|
@ -516,7 +517,7 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||||
// Make sure previous swap request has made it to the screen
|
// Make sure previous swap request has made it to the screen
|
||||||
if (g_VideoInitialize.bOnThread)
|
if (g_VideoInitialize.bOnThread)
|
||||||
{
|
{
|
||||||
while (Common::AtomicLoadAcquire(s_swapRequested))
|
while (Common::AtomicLoadAcquire(s_swapRequested) && s_PluginInitialized)
|
||||||
Common::YieldCPU();
|
Common::YieldCPU();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -569,7 +570,7 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y)
|
||||||
|
|
||||||
if (g_VideoInitialize.bOnThread)
|
if (g_VideoInitialize.bOnThread)
|
||||||
{
|
{
|
||||||
while (Common::AtomicLoadAcquire(s_efbAccessRequested))
|
while (Common::AtomicLoadAcquire(s_efbAccessRequested) && s_PluginInitialized)
|
||||||
Common::YieldCPU();
|
Common::YieldCPU();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue