diff options
| author | Tannin <devnull@localhost> | 2013-05-25 12:26:13 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-05-25 12:26:13 +0200 |
| commit | 3c21d1884a499066785e70dc44a869cb8b2d589d (patch) | |
| tree | f722d7ca296ddbefe2fbd4e32fbfce624794db5b /src/profile.cpp | |
| parent | 16bda49e0667f77f4ebe1d8fa2682abf57aa6765 (diff) | |
| parent | 2c4ba2c62cc7acce44d89948e7fb669d5a59b968 (diff) | |
Merge
Diffstat (limited to 'src/profile.cpp')
| -rw-r--r-- | src/profile.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/profile.cpp b/src/profile.cpp index 5f98d4be..eb2eff87 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -547,6 +547,9 @@ bool Profile::invalidationActive(bool *supported) const *supported = true; wchar_t buffer[1024]; std::wstring iniFileName = ToWString(QDir::toNativeSeparators(getIniFileName())); + // epic ms fail: GetPrivateProfileString uses errno (for whatever reason) to signal a fail since the return value + // has a different meaning (number of bytes copied). HOWEVER, it will not set errno to 0 if NO error occured + errno = 0; if (::GetPrivateProfileStringW(L"Archive", GameInfo::instance().archiveListKey().c_str(), L"", buffer, 1024, iniFileName.c_str()) == 0) { if (errno != 0x02) { @@ -555,8 +558,7 @@ bool Profile::invalidationActive(bool *supported) const } return false; } else { - qCritical("failed to parse \"%ls\"", iniFileName.c_str()); - QString errorMessage = tr("failed to parse ini file (%1): %2").arg(QDir::toNativeSeparators(getIniFileName())).arg(::GetLastError()); + QString errorMessage = tr("failed to parse ini file (%1)").arg(ToQString(iniFileName)); throw windows_error(errorMessage.toUtf8().constData()); } } @@ -580,6 +582,7 @@ void Profile::deactivateInvalidation() const if (GameInfo::instance().requiresBSAInvalidation()) { wchar_t buffer[1024]; std::wstring iniFileName = ToWString(QDir::toNativeSeparators(getIniFileName())); + errno = 0; if (::GetPrivateProfileStringW(L"Archive", GameInfo::instance().archiveListKey().c_str(), L"", buffer, 1024, iniFileName.c_str()) == 0) { if (errno == 0x02) { @@ -619,9 +622,15 @@ void Profile::activateInvalidation(const QString& dataDirectory) const if (GameInfo::instance().requiresBSAInvalidation()) { wchar_t buffer[1024]; std::wstring iniFileName = ToWString(QDir::toNativeSeparators(getIniFileName())); + errno = 0; if (::GetPrivateProfileStringW(L"Archive", GameInfo::instance().archiveListKey().c_str(), L"", buffer, 1024, iniFileName.c_str()) == 0) { - throw windows_error("failed to parse ini file"); + if (errno == 0x02) { + throw windows_error("failed to parse ini file"); + } else { + // ignore. shouldn't have gotten here anyway + return; + } } QStringList archives = ToQString(buffer).split(", "); |
