From 03269fff01d034579e907d2c950ecd2760844134 Mon Sep 17 00:00:00 2001 From: sguionni Date: Fri, 12 Jul 2024 13:46:43 +0200 Subject: [PATCH] Stop app correctly --- lib/app/include/app/vtx_app.hpp | 1 - lib/app/src/app/vtx_app.cpp | 35 +++++++++++++++----------------- lib/ui/qt/src/qt/application.cpp | 3 +++ lib/ui/qt/src/qt/main_window.cpp | 2 ++ 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/app/include/app/vtx_app.hpp b/lib/app/include/app/vtx_app.hpp index 92fd3ef4d..81c053647 100644 --- a/lib/app/include/app/vtx_app.hpp +++ b/lib/app/include/app/vtx_app.hpp @@ -69,7 +69,6 @@ namespace VTX::App void _handleArgs( const Args & p_args ); void _update( const float p_elapsedTime ); - void _stop(); }; // Convenient accessors diff --git a/lib/app/src/app/vtx_app.cpp b/lib/app/src/app/vtx_app.cpp index 6caf77435..00cf918cc 100644 --- a/lib/app/src/app/vtx_app.cpp +++ b/lib/app/src/app/vtx_app.cpp @@ -37,6 +37,8 @@ namespace VTX::App void VTXApp::init() { + VTX_INFO( "Init application" ); + //_systemHandler = std::make_unique(); Internal::Application::Settings::initSettings( SETTINGS() ); @@ -61,8 +63,7 @@ namespace VTX::App void VTXApp::start( const Args & p_args ) { - VTX_INFO( "Starting application: {}", Filesystem::EXECUTABLE_ABSOLUTE_PATH.string() ); - VTX_INFO( "Arguments: {}", p_args.toString() ); + VTX_INFO( "Starting application: {}", p_args.toString() ); // Regsiter loop events onUpdate += []( const float p_elapsedTime ) { SCENE().update( p_elapsedTime ); }; @@ -148,7 +149,19 @@ namespace VTX::App void VTXApp::stop() { - _stop(); + SCENE().reset(); + + //// Prevent events throw for nothing when quitting app + // Old::Manager::EventManager::get().freezeEvent( true ); + // Manager::WorkerManager::get().stopAll(); + + //_setting.backup(); + + // VTX::MVC_MANAGER().deleteModel( _representationLibrary ); + // VTX::MVC_MANAGER().deleteModel( _renderEffectLibrary ); + + // Old::Application::Selection::SelectionManager::get().deleteModel(); + onStop(); } @@ -201,22 +214,6 @@ namespace VTX::App // #endif // } - void VTXApp::_stop() - { - //_timer.stop(); - - //// Prevent events throw for nothing when quitting app - // Old::Manager::EventManager::get().freezeEvent( true ); - // Manager::WorkerManager::get().stopAll(); - - //_setting.backup(); - - // VTX::MVC_MANAGER().deleteModel( _representationLibrary ); - // VTX::MVC_MANAGER().deleteModel( _renderEffectLibrary ); - - // Old::Application::Selection::SelectionManager::get().deleteModel(); - } - Application::Scene & VTXApp::getScene() { return _systemHandler->get( SCENE_KEY ); } const Application::Scene & VTXApp::getScene() const { return _systemHandler->get( SCENE_KEY ); } diff --git a/lib/ui/qt/src/qt/application.cpp b/lib/ui/qt/src/qt/application.cpp index a0a217717..1f3e4a899 100644 --- a/lib/ui/qt/src/qt/application.cpp +++ b/lib/ui/qt/src/qt/application.cpp @@ -28,6 +28,7 @@ namespace VTX::UI::QT using namespace Resources; using namespace VTX::App::Info; + VTX_INFO( "Show splashscreen" ); _qSplashScreen = new QSplashScreen( QPixmap( SPRITE_SPLASH ) ); _qSplashScreen->show(); _qSplashScreen->showMessage( "Loading..." ); @@ -70,6 +71,7 @@ namespace VTX::UI::QT _qSplashScreen->finish( _mainWindow.get() ); _mainWindow->show(); + // On quit. onStop += [ this ] { _timer.stop(); @@ -88,6 +90,7 @@ namespace VTX::UI::QT _elapsedTimer.start(); // Then block. + VTX_INFO( "Show user interface" ); exec(); } diff --git a/lib/ui/qt/src/qt/main_window.cpp b/lib/ui/qt/src/qt/main_window.cpp index 81f118d4e..ee4d19c0e 100644 --- a/lib/ui/qt/src/qt/main_window.cpp +++ b/lib/ui/qt/src/qt/main_window.cpp @@ -28,6 +28,8 @@ namespace VTX::UI::QT void MainWindow::build() { + VTX_INFO( "Build main window" ); + // Main menu. createMenu(); createMenu();