From db80a34aca14fdb710588a6cc1ccb3c4d5aad2d6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 5 Feb 2020 16:09:35 +0100 Subject: [PATCH] [calamares] Remove intermediate debug-settings - There's a multi-stage setup for debug-mode, where the application object also knows that debugging is set. Remove it. - Break debug mode (because now the settings don't get debug-mode set). - Refactor so that parameter handing is only done if this Calamares is the unique (first) Calamares. --- src/calamares/CalamaresApplication.cpp | 21 ++++++--------------- src/calamares/CalamaresApplication.h | 12 ------------ src/calamares/main.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index a1daa4df2..1ce8f5eaa 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -42,12 +42,17 @@ #include #include +/// @brief Convenience for "are the settings in debug mode" +static bool +isDebug() +{ + return Calamares::Settings::instance() && Calamares::Settings::instance()->debugMode(); +} CalamaresApplication::CalamaresApplication( int& argc, char* argv[] ) : QApplication( argc, argv ) , m_mainwindow( nullptr ) , m_moduleManager( nullptr ) - , m_debugMode( false ) { // Setting the organization name makes the default cache // directory -- where Calamares stores logs, for instance -- @@ -102,20 +107,6 @@ CalamaresApplication::instance() } -void -CalamaresApplication::setDebug( bool enabled ) -{ - m_debugMode = enabled; -} - - -bool -CalamaresApplication::isDebug() -{ - return m_debugMode; -} - - CalamaresWindow* CalamaresApplication::mainWindow() { diff --git a/src/calamares/CalamaresApplication.h b/src/calamares/CalamaresApplication.h index 634f4cdb2..091361602 100644 --- a/src/calamares/CalamaresApplication.h +++ b/src/calamares/CalamaresApplication.h @@ -49,16 +49,6 @@ public: void init(); static CalamaresApplication* instance(); - /** - * @brief setDebug controls whether debug mode is enabled - */ - void setDebug( bool enabled ); - - /** - * @brief isDebug returns true if running in debug mode, otherwise false. - */ - bool isDebug(); - /** * @brief mainWindow returns the Calamares application main window. */ @@ -78,8 +68,6 @@ private: CalamaresWindow* m_mainwindow; Calamares::ModuleManager* m_moduleManager; - - bool m_debugMode; }; #endif // CALAMARESAPPLICATION_H diff --git a/src/calamares/main.cpp b/src/calamares/main.cpp index e451cf8cc..e2f5c0fd9 100644 --- a/src/calamares/main.cpp +++ b/src/calamares/main.cpp @@ -73,8 +73,7 @@ handle_args( CalamaresApplication& a ) parser.process( a ); - a.setDebug( parser.isSet( debugOption ) ); - Logger::setupLogLevel( a.isDebug() ? Logger::LOGVERBOSE : debug_level( parser, debugLevelOption ) ); + Logger::setupLogLevel( parser.isSet( debugOption ) ? Logger::LOGVERBOSE : debug_level( parser, debugLevelOption ) ); if ( parser.isSet( configOption ) ) { CalamaresUtils::setAppDataDir( QDir( parser.value( configOption ) ) ); @@ -83,6 +82,8 @@ handle_args( CalamaresApplication& a ) { CalamaresUtils::setXdgDirs(); } + + a.init(); } int @@ -110,11 +111,10 @@ main( int argc, char* argv[] ) // TODO: umount anything in /tmp/calamares-... as an emergency save function #endif - handle_args( a ); KDSingleApplicationGuard guard( KDSingleApplicationGuard::AutoKillOtherInstances ); if ( guard.isPrimaryInstance() ) { - a.init(); + handle_args( a ); return a.exec(); } else