exceptions
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
class LoadingWindow
|
||||
{
|
||||
public:
|
||||
virtual CString Init() { return ""; }
|
||||
virtual ~LoadingWindow() { }
|
||||
|
||||
virtual void Paint() = 0;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "RageLog.h"
|
||||
#include "StepMania.h"
|
||||
#include "RageFileManager.h"
|
||||
#include "RageUtil.h"
|
||||
#include "LoadingWindow_Gtk.h"
|
||||
#include "LoadingWindow_GtkModule.h"
|
||||
|
||||
@@ -14,39 +15,40 @@ static SETTEXT Module_SetText;
|
||||
|
||||
LoadingWindow_Gtk::LoadingWindow_Gtk()
|
||||
{
|
||||
try {
|
||||
}
|
||||
|
||||
CString LoadingWindow_Gtk::Init()
|
||||
{
|
||||
ASSERT( Handle == NULL );
|
||||
|
||||
Handle = dlopen( DirOfExecutable + "/" + "GtkModule.so", RTLD_NOW );
|
||||
if( Handle == NULL )
|
||||
RageException::ThrowNonfatal("dlopen(): %s", dlerror());
|
||||
return ssprintf( "dlopen(): %s", dlerror() );
|
||||
|
||||
Module_Init = (INIT) dlsym(Handle, "Init");
|
||||
if( !Module_Init )
|
||||
RageException::ThrowNonfatal( "Couldn't load symbol Module_Init" );
|
||||
return "Couldn't load symbol Module_Init";
|
||||
Module_Shutdown = (SHUTDOWN) dlsym(Handle, "Shutdown");
|
||||
if( !Module_Shutdown )
|
||||
RageException::ThrowNonfatal( "Couldn't load symbol Module_Shutdown" );
|
||||
return "Couldn't load symbol Module_Shutdown";
|
||||
Module_SetText = (SETTEXT) dlsym(Handle, "SetText");
|
||||
if( !Module_SetText )
|
||||
RageException::ThrowNonfatal( "Couldn't load symbol Module_SetText" );
|
||||
return "Couldn't load symbol Module_SetText";
|
||||
|
||||
const char *ret = Module_Init( &g_argc, &g_argv );
|
||||
if( ret != NULL )
|
||||
RageException::ThrowNonfatal( ret );
|
||||
} catch(...) {
|
||||
if( Handle )
|
||||
dlclose( Handle );
|
||||
Handle = NULL;
|
||||
throw;
|
||||
}
|
||||
return ret;
|
||||
return "";
|
||||
}
|
||||
|
||||
LoadingWindow_Gtk::~LoadingWindow_Gtk()
|
||||
{
|
||||
Module_Shutdown();
|
||||
if( Module_Shutdown != NULL )
|
||||
Module_Shutdown();
|
||||
Module_Shutdown = NULL;
|
||||
|
||||
dlclose( Handle );
|
||||
if( Handle )
|
||||
dlclose( Handle );
|
||||
Handle = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ class LoadingWindow_Gtk: public LoadingWindow
|
||||
{
|
||||
public:
|
||||
LoadingWindow_Gtk();
|
||||
CString Init();
|
||||
~LoadingWindow_Gtk();
|
||||
|
||||
void SetText(CString str);
|
||||
|
||||
@@ -32,26 +32,32 @@ LoadingWindow *MakeLoadingWindow()
|
||||
|
||||
for(unsigned i = 0; ret == NULL && i < DriversToTry.size(); ++i)
|
||||
{
|
||||
try {
|
||||
Driver = DriversToTry[i];
|
||||
Driver = DriversToTry[i];
|
||||
|
||||
#ifdef HAVE_LOADING_WINDOW_WIN32
|
||||
if(!DriversToTry[i].CompareNoCase("Win32")) ret = new LoadingWindow_Win32;
|
||||
if(!DriversToTry[i].CompareNoCase("Win32")) ret = new LoadingWindow_Win32;
|
||||
#endif
|
||||
#ifdef HAVE_LOADING_WINDOW_GTK
|
||||
if(!DriversToTry[i].CompareNoCase("Gtk")) ret = new LoadingWindow_Gtk;
|
||||
if(!DriversToTry[i].CompareNoCase("Gtk")) ret = new LoadingWindow_Gtk;
|
||||
#endif
|
||||
#ifdef HAVE_LOADING_WINDOW_COCOA
|
||||
if(!DriversToTry[i].CompareNoCase("Cocoa")) ret = new LoadingWindow_Cocoa;
|
||||
if(!DriversToTry[i].CompareNoCase("Cocoa")) ret = new LoadingWindow_Cocoa;
|
||||
#endif
|
||||
#ifdef HAVE_LOADING_WINDOW_SDL
|
||||
if(!DriversToTry[i].CompareNoCase("SDL")) ret = new LoadingWindow_SDL;
|
||||
if(!DriversToTry[i].CompareNoCase("SDL")) ret = new LoadingWindow_SDL;
|
||||
#endif
|
||||
#ifdef HAVE_LOADING_WINDOW_NULL
|
||||
if(!DriversToTry[i].CompareNoCase("Null")) ret = new LoadingWindow_Null;
|
||||
if(!DriversToTry[i].CompareNoCase("Null")) ret = new LoadingWindow_Null;
|
||||
#endif
|
||||
} catch(const RageException &e) {
|
||||
LOG->Info("Couldn't load driver %s: %s", DriversToTry[i].c_str(), e.what());
|
||||
|
||||
if( ret == NULL )
|
||||
continue;
|
||||
|
||||
CString sError = ret->Init();
|
||||
if( sError != "" )
|
||||
{
|
||||
LOG->Info("Couldn't load driver %s: %s", DriversToTry[i].c_str(), sError.c_str());
|
||||
SAFE_DELETE( ret );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user