| 365 | } |
| 366 | |
| 367 | int launchDefaultViewer( const Viewer::LaunchParams& params, const ViewerSetup& setup ) |
| 368 | { |
| 369 | static bool firstLaunch = true; |
| 370 | if ( !firstLaunch ) |
| 371 | { |
| 372 | spdlog::error( "Viewer can be launched only once" ); |
| 373 | return 1; |
| 374 | } |
| 375 | else |
| 376 | { |
| 377 | firstLaunch = false; |
| 378 | } |
| 379 | |
| 380 | CommandLoop::setMainThreadId( std::this_thread::get_id() ); |
| 381 | |
| 382 | auto& viewer = MR::Viewer::instanceRef(); |
| 383 | |
| 384 | MR::setupLoggerByDefault( setup.setupCustomLogSink ); |
| 385 | |
| 386 | setup.setupBasePlugins( &viewer ); |
| 387 | setup.setupCommonModifiers( &viewer ); |
| 388 | setup.setupCommonPlugins( &viewer ); |
| 389 | setup.setupSettingsManager( &viewer, params.name, params.resetConfig ); |
| 390 | setup.setupConfiguration( &viewer ); |
| 391 | CommandLoop::appendCommand( [&] () |
| 392 | { |
| 393 | setup.setupExtendedLibraries(); |
| 394 | setup.setupMcp(); |
| 395 | }, CommandLoop::StartPosition::AfterSplashAppear ); |
| 396 | |
| 397 | int res = 0; |
| 398 | #if defined(__EMSCRIPTEN__) || !defined(NDEBUG) |
| 399 | res = viewer.launch( params ); |
| 400 | #else |
| 401 | try |
| 402 | { |
| 403 | res = viewer.launch( params ); |
| 404 | } |
| 405 | catch ( ... ) |
| 406 | { |
| 407 | spdlog::critical( boost::current_exception_diagnostic_information() ); |
| 408 | spdlog::info( "Exception stacktrace:\n{}", getCurrentStacktrace() ); |
| 409 | printCurrentTimerBranch(); |
| 410 | res = 1; |
| 411 | } |
| 412 | #endif |
| 413 | setup.shutdownMcp(); |
| 414 | if ( params.unloadPluginsAtEnd ) |
| 415 | setup.unloadExtendedLibraries(); |
| 416 | if ( setup.shutdownCustomLogSink ) |
| 417 | setup.shutdownCustomLogSink(); |
| 418 | return res; |
| 419 | } |
| 420 | |
| 421 | void filterReservedCmdArgs( std::vector<std::string>& args ) |
| 422 | { |
no test coverage detected