exceptions
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
class LoadingWindow
|
class LoadingWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual CString Init() { return ""; }
|
||||||
virtual ~LoadingWindow() { }
|
virtual ~LoadingWindow() { }
|
||||||
|
|
||||||
virtual void Paint() = 0;
|
virtual void Paint() = 0;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "StepMania.h"
|
#include "StepMania.h"
|
||||||
#include "RageFileManager.h"
|
#include "RageFileManager.h"
|
||||||
|
#include "RageUtil.h"
|
||||||
#include "LoadingWindow_Gtk.h"
|
#include "LoadingWindow_Gtk.h"
|
||||||
#include "LoadingWindow_GtkModule.h"
|
#include "LoadingWindow_GtkModule.h"
|
||||||
|
|
||||||
@@ -14,38 +15,39 @@ static SETTEXT Module_SetText;
|
|||||||
|
|
||||||
LoadingWindow_Gtk::LoadingWindow_Gtk()
|
LoadingWindow_Gtk::LoadingWindow_Gtk()
|
||||||
{
|
{
|
||||||
try {
|
}
|
||||||
|
|
||||||
|
CString LoadingWindow_Gtk::Init()
|
||||||
|
{
|
||||||
ASSERT( Handle == NULL );
|
ASSERT( Handle == NULL );
|
||||||
|
|
||||||
Handle = dlopen( DirOfExecutable + "/" + "GtkModule.so", RTLD_NOW );
|
Handle = dlopen( DirOfExecutable + "/" + "GtkModule.so", RTLD_NOW );
|
||||||
if( Handle == NULL )
|
if( Handle == NULL )
|
||||||
RageException::ThrowNonfatal("dlopen(): %s", dlerror());
|
return ssprintf( "dlopen(): %s", dlerror() );
|
||||||
|
|
||||||
Module_Init = (INIT) dlsym(Handle, "Init");
|
Module_Init = (INIT) dlsym(Handle, "Init");
|
||||||
if( !Module_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");
|
Module_Shutdown = (SHUTDOWN) dlsym(Handle, "Shutdown");
|
||||||
if( !Module_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");
|
Module_SetText = (SETTEXT) dlsym(Handle, "SetText");
|
||||||
if( !Module_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 );
|
const char *ret = Module_Init( &g_argc, &g_argv );
|
||||||
if( ret != NULL )
|
if( ret != NULL )
|
||||||
RageException::ThrowNonfatal( ret );
|
return ret;
|
||||||
} catch(...) {
|
return "";
|
||||||
if( Handle )
|
|
||||||
dlclose( Handle );
|
|
||||||
Handle = NULL;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadingWindow_Gtk::~LoadingWindow_Gtk()
|
LoadingWindow_Gtk::~LoadingWindow_Gtk()
|
||||||
{
|
{
|
||||||
|
if( Module_Shutdown != NULL )
|
||||||
Module_Shutdown();
|
Module_Shutdown();
|
||||||
|
Module_Shutdown = NULL;
|
||||||
|
|
||||||
|
if( Handle )
|
||||||
dlclose( Handle );
|
dlclose( Handle );
|
||||||
Handle = NULL;
|
Handle = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class LoadingWindow_Gtk: public LoadingWindow
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LoadingWindow_Gtk();
|
LoadingWindow_Gtk();
|
||||||
|
CString Init();
|
||||||
~LoadingWindow_Gtk();
|
~LoadingWindow_Gtk();
|
||||||
|
|
||||||
void SetText(CString str);
|
void SetText(CString str);
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ LoadingWindow *MakeLoadingWindow()
|
|||||||
|
|
||||||
for(unsigned i = 0; ret == NULL && i < DriversToTry.size(); ++i)
|
for(unsigned i = 0; ret == NULL && i < DriversToTry.size(); ++i)
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
Driver = DriversToTry[i];
|
Driver = DriversToTry[i];
|
||||||
|
|
||||||
#ifdef HAVE_LOADING_WINDOW_WIN32
|
#ifdef HAVE_LOADING_WINDOW_WIN32
|
||||||
@@ -50,8 +49,15 @@ LoadingWindow *MakeLoadingWindow()
|
|||||||
#ifdef HAVE_LOADING_WINDOW_NULL
|
#ifdef HAVE_LOADING_WINDOW_NULL
|
||||||
if(!DriversToTry[i].CompareNoCase("Null")) ret = new LoadingWindow_Null;
|
if(!DriversToTry[i].CompareNoCase("Null")) ret = new LoadingWindow_Null;
|
||||||
#endif
|
#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