namespace Msp {
+Application *Application::app_ = 0;
+Application::Starter *Application::starter_ = 0;
+void *Application::data_ = 0;
+
Application::Application():
exit_code(0)
{ }
*/
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_)
{
return 126;
}
- data_=data;
+ data_ = data;
try
{
try
{
- app_=starter_->create_app(argc, argv);
+ app_ = starter_->create_app(argc, argv);
}
catch(const UsageError &e)
{
return 1;
}
- int result=app_->main();
- delete app_;
+ int result = app_->main();
+ Application *a = app_;
+ app_ = 0;
+ delete a;
return result;
}
catch(const exception &e)
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: "<<Debug::demangle(typeid(e).name())<<'\n';
cerr<<" what(): "<<e.what()<<'\n';
- const Exception *exc=dynamic_cast<const Exception *>(&e);
+ const Exception *exc = dynamic_cast<const Exception *>(&e);
if(exc && !exc->get_backtrace().get_frames().empty())
{
cerr<<" backtrace:\n";
- const list<Debug::Backtrace::StackFrame> &frames=exc->get_backtrace().get_frames();
+ const list<Debug::Backtrace::StackFrame> &frames = exc->get_backtrace().get_frames();
for(list<Debug::Backtrace::StackFrame>::const_iterator i=frames.begin(); i!=frames.end(); ++i)
cerr<<" "<<*i<<'\n';
}
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