mirror of
https://github.com/ModOrganizer2/modorganizer.git
synced 2026-07-27 13:58:24 -07:00
replaced formatSystemMessageQ() with formatSystemMessage()
replaced windowsErrorString() with formatSystemMessage()
This commit is contained in:
+3
-3
@@ -19,7 +19,7 @@ int getDesktopDpi()
|
||||
|
||||
if (!dc) {
|
||||
const auto e = GetLastError();
|
||||
log::error("can't get desktop DC, {}", formatSystemMessageQ(e));
|
||||
log::error("can't get desktop DC, {}", formatSystemMessage(e));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ HMONITOR findMonitor(const QString& name)
|
||||
const auto e = GetLastError();
|
||||
log::error(
|
||||
"GetMonitorInfo() failed for '{}', {}",
|
||||
data.name, formatSystemMessageQ(e));
|
||||
data.name, formatSystemMessage(e));
|
||||
|
||||
// error for this monitor, but continue
|
||||
return TRUE;
|
||||
@@ -121,7 +121,7 @@ int getDpi(const QString& monitorDevice)
|
||||
if (FAILED(r)) {
|
||||
log::error(
|
||||
"GetDpiForMonitor() failed for '{}', {}",
|
||||
monitorDevice, formatSystemMessageQ(r));
|
||||
monitorDevice, formatSystemMessage(r));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+7
-7
@@ -117,7 +117,7 @@ Module::FileInfo Module::getFileInfo() const
|
||||
|
||||
log::error(
|
||||
"GetFileVersionInfoSizeW() failed on '{}', {}",
|
||||
m_path, formatSystemMessageQ(e));
|
||||
m_path, formatSystemMessage(e));
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -130,7 +130,7 @@ Module::FileInfo Module::getFileInfo() const
|
||||
|
||||
log::error(
|
||||
"GetFileVersionInfoW() failed on '{}', {}",
|
||||
m_path, formatSystemMessageQ(e));
|
||||
m_path, formatSystemMessage(e));
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -255,7 +255,7 @@ QDateTime Module::getTimestamp(const VS_FIXEDFILEINFO& fi) const
|
||||
|
||||
log::error(
|
||||
"can't open file '{}' for timestamp, {}",
|
||||
m_path, formatSystemMessageQ(e));
|
||||
m_path, formatSystemMessage(e));
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -266,7 +266,7 @@ QDateTime Module::getTimestamp(const VS_FIXEDFILEINFO& fi) const
|
||||
|
||||
log::error(
|
||||
"can't get file time for '{}', {}",
|
||||
m_path, formatSystemMessageQ(e));
|
||||
m_path, formatSystemMessage(e));
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -328,7 +328,7 @@ std::vector<Module> getLoadedModules()
|
||||
if (snapshot.get() == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
const auto e = GetLastError();
|
||||
log::error("CreateToolhelp32Snapshot() failed, {}", formatSystemMessageQ(e));
|
||||
log::error("CreateToolhelp32Snapshot() failed, {}", formatSystemMessage(e));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ std::vector<Module> getLoadedModules()
|
||||
if (!Module32First(snapshot.get(), &me))
|
||||
{
|
||||
const auto e = GetLastError();
|
||||
log::error("Module32First() failed, {}", formatSystemMessageQ(e));
|
||||
log::error("Module32First() failed, {}", formatSystemMessage(e));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ std::vector<Module> getLoadedModules()
|
||||
|
||||
// no more modules is not an error
|
||||
if (e != ERROR_NO_MORE_FILES) {
|
||||
log::error("Module32Next() failed, {}", formatSystemMessageQ(e));
|
||||
log::error("Module32Next() failed, {}", formatSystemMessage(e));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
+10
-10
@@ -58,7 +58,7 @@ public:
|
||||
}
|
||||
|
||||
if (FAILED(ret)) {
|
||||
log::error("enum->next() failed, {}", formatSystemMessageQ(ret));
|
||||
log::error("enum->next() failed, {}", formatSystemMessage(ret));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ private:
|
||||
if (FAILED(ret) || !rawLocator) {
|
||||
log::error(
|
||||
"CoCreateInstance for WbemLocator failed, {}",
|
||||
formatSystemMessageQ(ret));
|
||||
formatSystemMessage(ret));
|
||||
|
||||
throw failed();
|
||||
}
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
if (FAILED(res) || !rawService) {
|
||||
log::error(
|
||||
"locator->ConnectServer() failed for namespace '{}', {}",
|
||||
ns, formatSystemMessageQ(res));
|
||||
ns, formatSystemMessage(res));
|
||||
|
||||
throw failed();
|
||||
}
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
|
||||
if (FAILED(ret))
|
||||
{
|
||||
log::error("CoSetProxyBlanket() failed, {}", formatSystemMessageQ(ret));
|
||||
log::error("CoSetProxyBlanket() failed, {}", formatSystemMessage(ret));
|
||||
throw failed();
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ private:
|
||||
|
||||
if (FAILED(ret) || !rawEnumerator)
|
||||
{
|
||||
log::error("query '{}' failed, {}", query, formatSystemMessageQ(ret));
|
||||
log::error("query '{}' failed, {}", query, formatSystemMessage(ret));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ std::vector<SecurityProduct> getSecurityProductsFromWMI()
|
||||
// display name
|
||||
auto ret = o->Get(L"displayName", 0, &prop, 0, 0);
|
||||
if (FAILED(ret)) {
|
||||
log::error("failed to get displayName, {}", formatSystemMessageQ(ret));
|
||||
log::error("failed to get displayName, {}", formatSystemMessage(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ std::vector<SecurityProduct> getSecurityProductsFromWMI()
|
||||
// product state
|
||||
ret = o->Get(L"productState", 0, &prop, 0, 0);
|
||||
if (FAILED(ret)) {
|
||||
log::error("failed to get productState, {}", formatSystemMessageQ(ret));
|
||||
log::error("failed to get productState, {}", formatSystemMessage(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ std::vector<SecurityProduct> getSecurityProductsFromWMI()
|
||||
// guid
|
||||
ret = o->Get(L"instanceGuid", 0, &prop, 0, 0);
|
||||
if (FAILED(ret)) {
|
||||
log::error("failed to get instanceGuid, {}", formatSystemMessageQ(ret));
|
||||
log::error("failed to get instanceGuid, {}", formatSystemMessage(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ std::optional<SecurityProduct> getWindowsFirewall()
|
||||
if (FAILED(hr) || !rawPolicy) {
|
||||
log::error(
|
||||
"CoCreateInstance for NetFwPolicy2 failed, {}",
|
||||
formatSystemMessageQ(hr));
|
||||
formatSystemMessage(hr));
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -363,7 +363,7 @@ std::optional<SecurityProduct> getWindowsFirewall()
|
||||
hr = policy->get_FirewallEnabled(NET_FW_PROFILE2_PUBLIC, &enabledVariant);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
log::error("get_FirewallEnabled failed, {}", formatSystemMessageQ(hr));
|
||||
log::error("get_FirewallEnabled failed, {}", formatSystemMessage(hr));
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -100,7 +100,7 @@ private:
|
||||
if (FAILED(r)) {
|
||||
throw ShellLinkException(QString("%1, %2")
|
||||
.arg(s)
|
||||
.arg(formatSystemMessageQ(r)));
|
||||
.arg(formatSystemMessage(r)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ bool Shortcut::remove(Locations loc)
|
||||
|
||||
log::error(
|
||||
"failed to remove shortcut '{}', {}",
|
||||
path, formatSystemMessageQ(e));
|
||||
path, formatSystemMessage(e));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
+2
-2
@@ -210,7 +210,7 @@ std::optional<bool> WindowsInfo::getElevated() const
|
||||
|
||||
log::error(
|
||||
"while trying to check if process is elevated, "
|
||||
"OpenProcessToken() failed: {}", formatSystemMessageQ(e));
|
||||
"OpenProcessToken() failed: {}", formatSystemMessage(e));
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -226,7 +226,7 @@ std::optional<bool> WindowsInfo::getElevated() const
|
||||
|
||||
log::error(
|
||||
"while trying to check if process is elevated, "
|
||||
"GetTokenInformation() failed: {}", formatSystemMessageQ(e));
|
||||
"GetTokenInformation() failed: {}", formatSystemMessage(e));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
+1
-1
@@ -464,7 +464,7 @@ void preloadDll(const QString& filename)
|
||||
|
||||
if (!LoadLibraryW(dllPath.toStdWString().c_str())) {
|
||||
const auto e = GetLastError();
|
||||
log::warn("failed to load {}: {}", dllPath, formatSystemMessageQ(e));
|
||||
log::warn("failed to load {}: {}", dllPath, formatSystemMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-7
@@ -4029,7 +4029,8 @@ void MainWindow::doMoveOverwriteContentToMod(const QString &modAbsolutePath)
|
||||
MessageDialog::showMessage(tr("Move successful."), this);
|
||||
}
|
||||
else {
|
||||
log::error("Move operation failed: {}", windowsErrorString(::GetLastError()));
|
||||
const auto e = GetLastError();
|
||||
log::error("Move operation failed: {}", formatSystemMessage(e));
|
||||
}
|
||||
|
||||
m_OrganizerCore.refreshModList();
|
||||
@@ -4058,7 +4059,8 @@ void MainWindow::clearOverwrite()
|
||||
updateProblemsButton();
|
||||
m_OrganizerCore.refreshModList();
|
||||
} else {
|
||||
log::error("Delete operation failed: {}", windowsErrorString(::GetLastError()));
|
||||
const auto e = GetLastError();
|
||||
log::error("Delete operation failed: {}", formatSystemMessage(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6819,8 +6821,13 @@ void MainWindow::on_restoreButton_clicked()
|
||||
if (!shellCopy(pluginName + "." + choice, pluginName, true, this) ||
|
||||
!shellCopy(loadOrderName + "." + choice, loadOrderName, true, this) ||
|
||||
!shellCopy(lockedName + "." + choice, lockedName, true, this)) {
|
||||
QMessageBox::critical(this, tr("Restore failed"),
|
||||
tr("Failed to restore the backup. Errorcode: %1").arg(windowsErrorString(::GetLastError())));
|
||||
|
||||
const auto e = GetLastError();
|
||||
|
||||
QMessageBox::critical(
|
||||
this, tr("Restore failed"),
|
||||
tr("Failed to restore the backup. Errorcode: %1")
|
||||
.arg(QString::fromStdWString(formatSystemMessage(e))));
|
||||
}
|
||||
m_OrganizerCore.refreshESPList(true);
|
||||
}
|
||||
@@ -6841,8 +6848,11 @@ void MainWindow::on_restoreModsButton_clicked()
|
||||
QString choice = queryRestore(modlistName);
|
||||
if (!choice.isEmpty()) {
|
||||
if (!shellCopy(modlistName + "." + choice, modlistName, true, this)) {
|
||||
QMessageBox::critical(this, tr("Restore failed"),
|
||||
tr("Failed to restore the backup. Errorcode: %1").arg(windowsErrorString(::GetLastError())));
|
||||
const auto e = GetLastError();
|
||||
QMessageBox::critical(
|
||||
this, tr("Restore failed"),
|
||||
tr("Failed to restore the backup. Errorcode: %1")
|
||||
.arg(formatSystemMessage(e)));
|
||||
}
|
||||
m_OrganizerCore.refreshModList(false);
|
||||
}
|
||||
@@ -6956,7 +6966,8 @@ void MainWindow::dropLocalFile(const QUrl &url, const QString &outputDir, bool m
|
||||
success = shellCopy(file.absoluteFilePath(), target, true, this);
|
||||
}
|
||||
if (!success) {
|
||||
log::error("file operation failed: {}", windowsErrorString(::GetLastError()));
|
||||
const auto e = GetLastError();
|
||||
log::error("file operation failed: {}", formatSystemMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ QString OrganizerCore::commitSettings(const QString &iniFile)
|
||||
// make a second attempt using qt functions but if that fails print the
|
||||
// error from the first attempt
|
||||
if (!renameFile(iniFile + ".new", iniFile)) {
|
||||
return windowsErrorString(err);
|
||||
return QString::fromStdWString(formatSystemMessage(err));
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
@@ -387,10 +387,12 @@ void OrganizerCore::storeSettings()
|
||||
+ QString::fromStdWString(AppConfig::iniFileName());
|
||||
if (QFileInfo(iniFile).exists()) {
|
||||
if (!shellCopy(iniFile, iniFile + ".new", true, qApp->activeWindow())) {
|
||||
const auto e = GetLastError();
|
||||
QMessageBox::critical(
|
||||
qApp->activeWindow(), tr("Failed to write settings"),
|
||||
tr("An error occurred trying to update MO settings to %1: %2")
|
||||
.arg(iniFile, windowsErrorString(::GetLastError())));
|
||||
.arg(iniFile)
|
||||
.arg(QString::fromStdWString(formatSystemMessage(e))));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -265,7 +265,10 @@ void Profile::createTweakedIniFile()
|
||||
QString tweakedIni = m_Directory.absoluteFilePath("initweaks.ini");
|
||||
|
||||
if (QFile::exists(tweakedIni) && !shellDeleteQuiet(tweakedIni)) {
|
||||
reportError(tr("failed to update tweaked ini file, wrong settings may be used: %1").arg(windowsErrorString(::GetLastError())));
|
||||
const auto e = GetLastError();
|
||||
reportError(
|
||||
tr("failed to update tweaked ini file, wrong settings may be used: %1")
|
||||
.arg(QString::fromStdWString(formatSystemMessage(e))));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -287,7 +290,7 @@ void Profile::createTweakedIniFile()
|
||||
if (error) {
|
||||
const auto e = ::GetLastError();
|
||||
reportError(tr("failed to create tweaked ini: %1")
|
||||
.arg(formatSystemMessageQ(e)));
|
||||
.arg(QString::fromStdWString(formatSystemMessage(e))));
|
||||
}
|
||||
|
||||
log::debug("{} saved", QDir::toNativeSeparators(tweakedIni));
|
||||
|
||||
+3
-3
@@ -220,7 +220,7 @@ QString Settings::deObfuscate(const QString key)
|
||||
} else {
|
||||
const auto e = GetLastError();
|
||||
if (e != ERROR_NOT_FOUND) {
|
||||
log::error("Retrieving encrypted data failed: {}", formatSystemMessageQ(e));
|
||||
log::error("Retrieving encrypted data failed: {}", formatSystemMessage(e));
|
||||
}
|
||||
}
|
||||
delete[] keyData;
|
||||
@@ -365,7 +365,7 @@ bool Settings::setNexusApiKey(const QString& apiKey)
|
||||
{
|
||||
if (!obfuscate("APIKEY", apiKey)) {
|
||||
const auto e = GetLastError();
|
||||
log::error("Storing API key failed: {}", formatSystemMessageQ(e));
|
||||
log::error("Storing API key failed: {}", formatSystemMessage(e));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ void Settings::setSteamLogin(QString username, QString password)
|
||||
}
|
||||
if (!obfuscate("steam_password", password)) {
|
||||
const auto e = GetLastError();
|
||||
log::error("Storing or deleting password failed: {}", formatSystemMessageQ(e));
|
||||
log::error("Storing or deleting password failed: {}", formatSystemMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user