summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-07-19 04:54:47 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-07-22 07:39:52 -0400
commitf49efd6d448dccd4100fa46e2ebf1690d97033cc (patch)
tree700e4be020963a2cdd7ff13c4003c59efa064201
parentb3d0ddb0b75da4abd59cae1508d983945c8e235d (diff)
replaced formatSystemMessageQ() with formatSystemMessage()
replaced windowsErrorString() with formatSystemMessage()
-rw-r--r--src/envmetrics.cpp6
-rw-r--r--src/envmodule.cpp14
-rw-r--r--src/envsecurity.cpp20
-rw-r--r--src/envshortcut.cpp4
-rw-r--r--src/envwindows.cpp4
-rw-r--r--src/main.cpp2
-rw-r--r--src/mainwindow.cpp25
-rw-r--r--src/organizercore.cpp6
-rw-r--r--src/profile.cpp7
-rw-r--r--src/settings.cpp6
10 files changed, 55 insertions, 39 deletions
diff --git a/src/envmetrics.cpp b/src/envmetrics.cpp
index 784e4baf..b1b9bd2e 100644
--- a/src/envmetrics.cpp
+++ b/src/envmetrics.cpp
@@ -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;
}
diff --git a/src/envmodule.cpp b/src/envmodule.cpp
index aae4e0b1..8cea414a 100644
--- a/src/envmodule.cpp
+++ b/src/envmodule.cpp
@@ -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;
diff --git a/src/envsecurity.cpp b/src/envsecurity.cpp
index 015e4000..376be4df 100644
--- a/src/envsecurity.cpp
+++ b/src/envsecurity.cpp
@@ -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 {};
}
}
diff --git a/src/envshortcut.cpp b/src/envshortcut.cpp
index 1deb9dad..99495c39 100644
--- a/src/envshortcut.cpp
+++ b/src/envshortcut.cpp
@@ -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;
}
diff --git a/src/envwindows.cpp b/src/envwindows.cpp
index 8a98036a..3932a9b5 100644
--- a/src/envwindows.cpp
+++ b/src/envwindows.cpp
@@ -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 {};
}
diff --git a/src/main.cpp b/src/main.cpp
index 5c5ce945..f53a574e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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));
}
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index e502bdb1..8a8a99ef 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -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));
}
}
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index f6802673..b61ebde8 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -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;
}
}
diff --git a/src/profile.cpp b/src/profile.cpp
index 27616986..6de1b097 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -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));
diff --git a/src/settings.cpp b/src/settings.cpp
index ff5b9976..5ad066b2 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -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));
}
}