Fix dependency: Crash.cpp should not depend on GraphicsWindow.
This commit is contained in:
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#include "arch/Threads/Threads_Win32.h"
|
#include "arch/Threads/Threads_Win32.h"
|
||||||
#include "archutils/Win32/WindowsResources.h"
|
#include "archutils/Win32/WindowsResources.h"
|
||||||
#include "archutils/Win32/GraphicsWindow.h" /* for GraphicsWindow::GetHwnd */
|
|
||||||
#include "crash.h"
|
#include "crash.h"
|
||||||
#include "ProductInfo.h"
|
#include "ProductInfo.h"
|
||||||
|
|
||||||
@@ -163,6 +162,11 @@ bool VDDebugInfoInitFromMemory(VDDebugInfoContext *pctx, const void *_src);
|
|||||||
bool VDDebugInfoInitFromFile( VDDebugInfoContext *pctx );
|
bool VDDebugInfoInitFromFile( VDDebugInfoContext *pctx );
|
||||||
void VDDebugInfoDeinit( VDDebugInfoContext *pctx );
|
void VDDebugInfoDeinit( VDDebugInfoContext *pctx );
|
||||||
|
|
||||||
|
static HWND g_hForegroundWnd = NULL;
|
||||||
|
void CrashHandler::SetForegroundWindow( HWND hWnd )
|
||||||
|
{
|
||||||
|
g_hForegroundWnd = hWnd;
|
||||||
|
}
|
||||||
|
|
||||||
long __stdcall CrashHandler::ExceptionHandler( EXCEPTION_POINTERS *pExc )
|
long __stdcall CrashHandler::ExceptionHandler( EXCEPTION_POINTERS *pExc )
|
||||||
{
|
{
|
||||||
@@ -255,11 +259,11 @@ long __stdcall CrashHandler::ExceptionHandler( EXCEPTION_POINTERS *pExc )
|
|||||||
/* Now things get more risky. If we're fullscreen, the window will obscure the
|
/* Now things get more risky. If we're fullscreen, the window will obscure the
|
||||||
* crash dialog. Try to hide the window. Things might blow up here; do this
|
* crash dialog. Try to hide the window. Things might blow up here; do this
|
||||||
* after DoSave, so we always write a crash dump. */
|
* after DoSave, so we always write a crash dump. */
|
||||||
if( GetWindowThreadProcessId( GraphicsWindow::GetHwnd(), NULL ) == GetCurrentThreadId() )
|
if( GetWindowThreadProcessId( g_hForegroundWnd, NULL ) == GetCurrentThreadId() )
|
||||||
{
|
{
|
||||||
/* The thread that crashed was the thread that created the main window. Hide
|
/* The thread that crashed was the thread that created the main window. Hide
|
||||||
* the window. This will also restore the video mode, if necessary. */
|
* the window. This will also restore the video mode, if necessary. */
|
||||||
ShowWindow( GraphicsWindow::GetHwnd(), SW_HIDE );
|
ShowWindow( g_hForegroundWnd, SW_HIDE );
|
||||||
} else {
|
} else {
|
||||||
/* A different thread crashed. Simply kill all other windows. We can't safely
|
/* A different thread crashed. Simply kill all other windows. We can't safely
|
||||||
* call ShowWindow; the main thread might be deadlocked. */
|
* call ShowWindow; the main thread might be deadlocked. */
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ namespace CrashHandler
|
|||||||
void SymLookup( const void *ptr, char *buf );
|
void SymLookup( const void *ptr, char *buf );
|
||||||
void ForceCrash( const char *reason );
|
void ForceCrash( const char *reason );
|
||||||
void ForceDeadlock( CString reason, uint64_t iID );
|
void ForceDeadlock( CString reason, uint64_t iID );
|
||||||
|
|
||||||
|
/* Inform the crash handler of a foreground window that may be fullscreen. If
|
||||||
|
* set, the crash handler will attempt to hide the window or reset the video
|
||||||
|
* mode. */
|
||||||
|
void SetForegroundWindow( HWND hWnd );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "DisplayResolutions.h"
|
#include "DisplayResolutions.h"
|
||||||
#include "arch/ArchHooks/ArchHooks.h"
|
#include "arch/ArchHooks/ArchHooks.h"
|
||||||
#include "archutils/Win32/AppInstance.h"
|
#include "archutils/Win32/AppInstance.h"
|
||||||
|
#include "archutils/Win32/Crash.h"
|
||||||
#include "archutils/Win32/WindowIcon.h"
|
#include "archutils/Win32/WindowIcon.h"
|
||||||
#include "archutils/Win32/GetFileInformation.h"
|
#include "archutils/Win32/GetFileInformation.h"
|
||||||
|
|
||||||
@@ -241,6 +242,7 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p )
|
|||||||
if( g_hWndMain == NULL )
|
if( g_hWndMain == NULL )
|
||||||
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "CreateWindow" ).c_str() );
|
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "CreateWindow" ).c_str() );
|
||||||
|
|
||||||
|
CrashHandler::SetForegroundWindow( g_hWndMain );
|
||||||
//SetForegroundWindow( g_hWndMain );
|
//SetForegroundWindow( g_hWndMain );
|
||||||
|
|
||||||
g_HDC = GetDC( g_hWndMain );
|
g_HDC = GetDC( g_hWndMain );
|
||||||
@@ -266,6 +268,7 @@ void GraphicsWindow::RecreateGraphicsWindow( const VideoModeParams &p )
|
|||||||
DestroyGraphicsWindow();
|
DestroyGraphicsWindow();
|
||||||
|
|
||||||
g_hWndMain = hWnd;
|
g_hWndMain = hWnd;
|
||||||
|
CrashHandler::SetForegroundWindow( g_hWndMain );
|
||||||
g_HDC = GetDC( g_hWndMain );
|
g_HDC = GetDC( g_hWndMain );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,6 +356,7 @@ void GraphicsWindow::DestroyGraphicsWindow()
|
|||||||
{
|
{
|
||||||
DestroyWindow( g_hWndMain );
|
DestroyWindow( g_hWndMain );
|
||||||
g_hWndMain = NULL;
|
g_hWndMain = NULL;
|
||||||
|
CrashHandler::SetForegroundWindow( g_hWndMain );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( g_hIcon != NULL )
|
if( g_hIcon != NULL )
|
||||||
|
|||||||
Reference in New Issue
Block a user