Skip to content

Commit e9423b0

Browse files
committed
Terminate handler.
1 parent 08a8563 commit e9423b0

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

‎include/cinder/app/AppBase.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ class CI_API AppBase {
450450
//! \endcond
451451

452452
private:
453+
static void onTerminate();
453454

454455
Timer mTimer;
455456
uint32_t mFrameCount;

‎src/cinder/app/AppBase.cpp‎

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,29 @@ void AppBase::initialize( Settings *settings, const RendererRef &defaultRenderer
184184
sSettingsFromMain = settings;
185185
}
186186

187-
void AppBase::executeLaunch()
187+
void AppBase::onTerminate()
188188
{
189-
try {
190-
// a quit() was called from the app constructor; don't launch
191-
if( mQuitRequested )
192-
return;
193-
mLaunchCalled = true;
194-
launch();
195-
}
196-
catch( std::exception &exc ) {
197-
CI_LOG_F( "Uncaught exception, type: " << System::demangleTypeName( typeid( exc ).name() ) << ", what: " << exc.what() );
198-
throw;
189+
if( auto excptr = std::current_exception() ) {
190+
try {
191+
std::rethrow_exception( excptr );
192+
}
193+
catch( const std::exception & exc ) {
194+
CI_LOG_F( "Uncaught exception, type: " << System::demangleTypeName( typeid( exc ).name() ) << ", what: " << exc.what() );
195+
}
199196
}
197+
std::exit( EXIT_FAILURE );
198+
}
199+
200+
void AppBase::executeLaunch()
201+
{
202+
std::set_terminate( onTerminate );
203+
204+
// a quit() was called from the app constructor; don't launch
205+
if( mQuitRequested )
206+
return;
207+
208+
mLaunchCalled = true;
209+
launch();
200210
}
201211

202212
// static

0 commit comments

Comments
 (0)