X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fapplication.cpp;h=139f94f2d88054d745ad9119b562dd7ec174d596;hb=d5dd704b2576f878809e87dbb8ff8591b9bdbce4;hp=badc52304ab4df6dc8c563aa9708109e5c387959;hpb=5ad225535ae12d53fd79c8f9fa764bd586211b8f;p=libs%2Fcore.git diff --git a/source/core/application.cpp b/source/core/application.cpp index badc523..139f94f 100644 --- a/source/core/application.cpp +++ b/source/core/application.cpp @@ -19,6 +19,10 @@ using namespace std; namespace Msp { +Application *Application::app_ = 0; +Application::Starter *Application::starter_ = 0; +void *Application::data_ = 0; + Application::Application(): exit_code(0) { } @@ -32,13 +36,13 @@ the library normally does it automatically at program startup. */ int Application::run(int argc, char **argv, void *data) { - static bool called=false; + static bool called = false; if(called) { cerr<<"Trying to call Application::run_app twice!\n"; return 125; } - called=true; + called = true; if(!starter_) { @@ -46,13 +50,13 @@ int Application::run(int argc, char **argv, void *data) return 126; } - data_=data; + data_ = data; try { try { - app_=starter_->create_app(argc, argv); + app_ = starter_->create_app(argc, argv); } catch(const UsageError &e) { @@ -60,9 +64,9 @@ int Application::run(int argc, char **argv, void *data) return 1; } - int result=app_->main(); - Application *a=app_; - app_=0; + int result = app_->main(); + Application *a = app_; + app_ = 0; delete a; return result; } @@ -71,18 +75,18 @@ int Application::run(int argc, char **argv, void *data) delete app_; #ifdef WIN32 - string msg=Debug::demangle(typeid(e).name())+":\n"+e.what(); + string msg = Debug::demangle(typeid(e).name())+":\n"+e.what(); MessageBoxA(0, msg.c_str(), "Uncaught exception", MB_OK|MB_ICONERROR); #else cerr<<"An uncaught exception occurred.\n"; cerr<<" type: "<(&e); + const Exception *exc = dynamic_cast(&e); if(exc && !exc->get_backtrace().get_frames().empty()) { cerr<<" backtrace:\n"; - const list &frames=exc->get_backtrace().get_frames(); + const list &frames = exc->get_backtrace().get_frames(); for(list::const_iterator i=frames.begin(); i!=frames.end(); ++i) cerr<<" "<<*i<<'\n'; } @@ -151,11 +155,7 @@ Application::Starter::Starter() if(starter_) throw InvalidState("Can't create more than one Starter instance"); - starter_=this; + starter_ = this; } -Application *Application::app_=0; -Application::RegBase *Application::reg_app_=0; -void *Application::data_=0; - } // namespace Msp