Improve error message when daemonizing failed

PR #19959.
This commit is contained in:
Chocobo1
2023-11-21 14:05:32 +08:00
committed by GitHub
parent 137df132e8
commit 6f7f418ec1
4 changed files with 26 additions and 21 deletions

View File

@@ -31,8 +31,6 @@
#include "os.h"
#ifdef Q_OS_WIN
#include <memory>
#include <windows.h>
#include <powrprof.h>
#include <shlobj.h>
@@ -87,11 +85,9 @@ void Utils::OS::shutdownComputer([[maybe_unused]] const ShutdownDialogAction &ac
}
else
{
const QString msg = QCoreApplication::translate("misc"
, "qBittorrent will shutdown the computer now because all downloads are complete.");
auto msgWchar = std::make_unique<wchar_t[]>(msg.length() + 1);
msg.toWCharArray(msgWchar.get());
::InitiateSystemShutdownW(nullptr, msgWchar.get(), 10, TRUE, FALSE);
std::wstring msg = QCoreApplication::translate("misc"
, "qBittorrent will shutdown the computer now because all downloads are complete.").toStdWString();
::InitiateSystemShutdownW(nullptr, msg.data(), 10, TRUE, FALSE);
}
// Disable shutdown privilege.