RageException is a very low-level helper (usable by any code). Eliminate

StepMania.cpp dependency.
This commit is contained in:
Glenn Maynard
2005-12-30 08:23:56 +00:00
parent 79c00ae191
commit 0062b24e2f
4 changed files with 15 additions and 10 deletions
+10 -2
View File
@@ -2,7 +2,6 @@
#include "RageException.h"
#include "RageUtil.h"
#include "RageLog.h"
#include "StepMania.h"
#include <cstdarg>
@@ -10,6 +9,12 @@
#include <windows.h>
#endif
static void (*g_CleanupHandler)( const RString &sError ) = NULL;
void RageException::SetCleanupHandler( void (*pHandler)(const RString &sError) )
{
g_CleanupHandler = pHandler;
}
/* This is no longer actually implemented by throwing an exception, but it acts
* the same way to code in practice. */
void RageException::Throw(const char *fmt, ...)
@@ -42,7 +47,10 @@ void RageException::Throw(const char *fmt, ...)
DebugBreak();
#endif
StepMania::HandleException( error );
if( g_CleanupHandler != NULL )
g_CleanupHandler( error );
exit(1);
}
/*
+2 -1
View File
@@ -1,4 +1,4 @@
/* RageException - Class for thowing fatal errors. */
/* RageException - Class for throwing fatal errors. */
#ifndef RAGE_EXCEPTION_H
#define RAGE_EXCEPTION_H
@@ -6,6 +6,7 @@
namespace RageException
{
void NORETURN Throw(const char *fmt, ...);
void SetCleanupHandler( void (*pHandler)(const RString &sError) );
};
#endif
+3 -6
View File
@@ -270,9 +270,7 @@ void ShutdownGame()
SAFE_DELETE( HOOKS );
}
/* Cleanly shut down, show a dialog and exit the game. We don't go back
* up the call stack, to avoid having to use exceptions. */
void NORETURN StepMania::HandleException( RString error )
static void HandleException( const RString &sError )
{
if( g_bAutoRestart )
HOOKS->RestartProgram();
@@ -281,9 +279,7 @@ void NORETURN StepMania::HandleException( RString error )
ShutdownGame();
/* Throw up a pretty error dialog. */
Dialog::Error( error );
exit(1);
Dialog::Error( sError );
}
void StepMania::ResetGame()
@@ -896,6 +892,7 @@ int main(int argc, char* argv[])
#endif
RageThreadRegister thread( "Main thread" );
RageException::SetCleanupHandler( HandleException );
SetCommandlineArguments( argc, argv );
-1
View File
@@ -14,7 +14,6 @@ int main( int argc, char* argv[] );
namespace StepMania
{
void ApplyGraphicOptions();
void NORETURN HandleException( CString error );
void ResetGame();
void ChangeCurrentGame( const Game* g );