mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 22:14:32 +00:00
Fix Coverity Scan 143909.
Also, the setting "Confirmation on auto-exit when downloads finish" wasn't working before.
This commit is contained in:
parent
2d0b9e6538
commit
a1e0fa5509
@ -285,49 +285,43 @@ void Application::allTorrentsFinished()
|
|||||||
{
|
{
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
Preferences *const pref = Preferences::instance();
|
Preferences *const pref = Preferences::instance();
|
||||||
|
bool isExit = pref->shutdownqBTWhenDownloadsComplete();
|
||||||
|
bool isShutdown = pref->shutdownWhenDownloadsComplete();
|
||||||
|
bool isSuspend = pref->suspendWhenDownloadsComplete();
|
||||||
|
bool isHibernate = pref->hibernateWhenDownloadsComplete();
|
||||||
|
|
||||||
bool will_shutdown = (pref->shutdownWhenDownloadsComplete()
|
bool haveAction = isExit || isShutdown || isSuspend || isHibernate;
|
||||||
|| pref->shutdownqBTWhenDownloadsComplete()
|
if (!haveAction) return;
|
||||||
|| pref->suspendWhenDownloadsComplete()
|
|
||||||
|| pref->hibernateWhenDownloadsComplete());
|
|
||||||
|
|
||||||
// Auto-Shutdown
|
ShutdownDialogAction action = ShutdownDialogAction::Exit;
|
||||||
if (will_shutdown) {
|
if (isSuspend)
|
||||||
bool suspend = pref->suspendWhenDownloadsComplete();
|
action = ShutdownDialogAction::Suspend;
|
||||||
bool hibernate = pref->hibernateWhenDownloadsComplete();
|
else if (isHibernate)
|
||||||
bool shutdown = pref->shutdownWhenDownloadsComplete();
|
action = ShutdownDialogAction::Hibernate;
|
||||||
|
else if (isShutdown)
|
||||||
|
action = ShutdownDialogAction::Shutdown;
|
||||||
|
|
||||||
// Confirm shutdown
|
// ask confirm
|
||||||
ShutdownDialogAction action = ShutdownDialogAction::Exit;
|
if ((action == ShutdownDialogAction::Exit) && (pref->dontConfirmAutoExit())) {
|
||||||
if (suspend)
|
// do nothing & skip confirm
|
||||||
action = ShutdownDialogAction::Suspend;
|
|
||||||
else if (hibernate)
|
|
||||||
action = ShutdownDialogAction::Hibernate;
|
|
||||||
else if (shutdown)
|
|
||||||
action = ShutdownDialogAction::Shutdown;
|
|
||||||
|
|
||||||
if ((action == ShutdownDialogAction::Exit) && (!pref->dontConfirmAutoExit())) {
|
|
||||||
if (!ShutdownConfirmDlg::askForConfirmation(action))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else { //exit and shutdown
|
|
||||||
if (!ShutdownConfirmDlg::askForConfirmation(action))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actually shut down
|
|
||||||
if (suspend || hibernate || shutdown) {
|
|
||||||
qDebug("Preparing for auto-shutdown because all downloads are complete!");
|
|
||||||
// Disabling it for next time
|
|
||||||
pref->setShutdownWhenDownloadsComplete(false);
|
|
||||||
pref->setSuspendWhenDownloadsComplete(false);
|
|
||||||
pref->setHibernateWhenDownloadsComplete(false);
|
|
||||||
// Make sure preferences are synced before exiting
|
|
||||||
m_shutdownAct = action;
|
|
||||||
}
|
|
||||||
qDebug("Exiting the application");
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (!ShutdownConfirmDlg::askForConfirmation(action)) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actually shut down
|
||||||
|
if (action != ShutdownDialogAction::Exit) {
|
||||||
|
qDebug("Preparing for auto-shutdown because all downloads are complete!");
|
||||||
|
// Disabling it for next time
|
||||||
|
pref->setShutdownWhenDownloadsComplete(false);
|
||||||
|
pref->setSuspendWhenDownloadsComplete(false);
|
||||||
|
pref->setHibernateWhenDownloadsComplete(false);
|
||||||
|
// Make sure preferences are synced before exiting
|
||||||
|
m_shutdownAct = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Exiting the application");
|
||||||
|
exit();
|
||||||
#endif // DISABLE_GUI
|
#endif // DISABLE_GUI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user