From 19874ebc3a7bac09a092e5ffabd9174aadcf7045 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Mar 2021 23:19:56 +0100 Subject: [PATCH] [finished] Document doRestart() better - move all the 'really want restart' logic to restartNowWanted() --- src/modules/finished/Config.cpp | 2 +- src/modules/finished/Config.h | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/modules/finished/Config.cpp b/src/modules/finished/Config.cpp index be2c729b1..bf156303d 100644 --- a/src/modules/finished/Config.cpp +++ b/src/modules/finished/Config.cpp @@ -112,7 +112,7 @@ void Config::doRestart() { cDebug() << "Restart requested, mode=" << restartModes().find( restartNowMode() ) << " want?" << restartNowWanted(); - if ( restartNowMode() != RestartMode::Never && restartNowWanted() ) + if ( restartNowWanted() ) { cDebug() << "Running restart command" << m_restartNowCommand; QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } ); diff --git a/src/modules/finished/Config.h b/src/modules/finished/Config.h index a5676990d..cf1d8eb73 100644 --- a/src/modules/finished/Config.h +++ b/src/modules/finished/Config.h @@ -46,7 +46,14 @@ public Q_SLOTS: RestartMode restartNowMode() const { return m_restartNowMode; } void setRestartNowMode( RestartMode m ); - bool restartNowWanted() const { return m_userWantsRestart; } + bool restartNowWanted() const + { + if ( restartNowMode() == RestartMode::Never ) + { + return false; + } + return ( restartNowMode() == RestartMode::Always ) || m_userWantsRestart; + } void setRestartNowWanted( bool w ); QString restartNowCommand() const { return m_restartNowCommand; } @@ -62,6 +69,10 @@ public Q_SLOTS: * This should generally not be called somewhere during the * application's execution, but only in response to QApplication::quit() * or something like that when the user expects the system to restart. + * + * The "if desired" part is: only if the restart mode allows it, + * **and** the user has checked the box (or done whatever to + * turn on restartNowWanted()). */ void doRestart();