diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-10-24 14:07:27 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-10-24 16:26:55 +0000 |
commit | 0d9cd98c073d1766b1d81017b48f6cc13a8cda21 (patch) | |
tree | 2897caee4b4921fb99a934f3df5ccad3fdd5067d /src/corelib | |
parent | c12b6075d18280dc0405f3d19be4492ed1ebe560 (diff) |
qsettings_win.cpp: Use qt_error_string()
Remove the errorCodeToString() which is duplicating
the functionality and does apparently not work.
Change-Id: Ib1ca2dfed630b10d01c0acf278c42eb851405b46
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qsettings_win.cpp | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp index 1c10548cbc..edcae16776 100644 --- a/src/corelib/io/qsettings_win.cpp +++ b/src/corelib/io/qsettings_win.cpp @@ -138,21 +138,6 @@ static void mergeKeySets(NameSet *dest, const QStringList &src) ** Wrappers for the insane windows registry API */ -static QString errorCodeToString(DWORD errorCode) -{ - wchar_t *data = 0; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, errorCode, 0, data, 0, 0); - QString result = QString::fromWCharArray(data); - - if (data != 0) - LocalFree(data); - - if (result.endsWith(QLatin1Char('\n'))) - result.truncate(result.length() - 1); - - return result; -} - // Open a key with the specified "perms". // "access" is to explicitly use the 32- or 64-bit branch. static HKEY openKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey, REGSAM access = 0) @@ -184,7 +169,7 @@ static HKEY createOrOpenKey(HKEY parentHandle, REGSAM perms, const QString &rSub return resultHandle; //qWarning("QSettings: Failed to create subkey \"%s\": %s", - // rSubKey.toLatin1().data(), errorCodeToString(res).toLatin1().data()); + // qPrintable(rSubKey), qPrintable(qt_error_string(int(res)))); return 0; } @@ -224,7 +209,7 @@ static QStringList childKeysOrGroups(HKEY parentHandle, QSettingsPrivate::ChildS &numKeys, &maxKeySize, 0, 0, 0); if (res != ERROR_SUCCESS) { - qWarning("QSettings: RegQueryInfoKey() failed: %s", errorCodeToString(res).toLatin1().data()); + qWarning("QSettings: RegQueryInfoKey() failed: %s", qPrintable(qt_error_string(int(res)))); return result; } @@ -258,7 +243,7 @@ static QStringList childKeysOrGroups(HKEY parentHandle, QSettingsPrivate::ChildS item = QString::fromWCharArray((const wchar_t *)buff.constData(), l); if (res != ERROR_SUCCESS) { - qWarning("QSettings: RegEnumValue failed: %s", errorCodeToString(res).toLatin1().data()); + qWarning("QSettings: RegEnumValue failed: %s", qPrintable(qt_error_string(int(res)))); continue; } if (item.isEmpty()) @@ -313,7 +298,7 @@ static void deleteChildGroups(HKEY parentHandle, REGSAM access = 0) LONG res = RegDeleteKey(parentHandle, reinterpret_cast<const wchar_t *>(group.utf16())); if (res != ERROR_SUCCESS) { qWarning("QSettings: RegDeleteKey failed on subkey \"%s\": %s", - group.toLatin1().data(), errorCodeToString(res).toLatin1().data()); + qPrintable(group), qPrintable(qt_error_string(int(res)))); return; } } @@ -613,7 +598,7 @@ QWinSettingsPrivate::~QWinSettingsPrivate() DWORD res = RegDeleteKey(writeHandle(), reinterpret_cast<const wchar_t *>(emptyKey.utf16())); if (res != ERROR_SUCCESS) { qWarning("QSettings: Failed to delete key \"%s\": %s", - regList.at(0).key().toLatin1().data(), errorCodeToString(res).toLatin1().data()); + qPrintable(regList.at(0).key()), qPrintable(qt_error_string(int(res)))); } } @@ -652,7 +637,7 @@ void QWinSettingsPrivate::remove(const QString &uKey) LONG res = RegDeleteValue(handle, reinterpret_cast<const wchar_t *>(group.utf16())); if (res != ERROR_SUCCESS) { qWarning("QSettings: RegDeleteValue failed on subkey \"%s\": %s", - group.toLatin1().data(), errorCodeToString(res).toLatin1().data()); + qPrintable(group), qPrintable(qt_error_string(int(res)))); } } } else { @@ -660,7 +645,7 @@ void QWinSettingsPrivate::remove(const QString &uKey) if (res != ERROR_SUCCESS) { qWarning("QSettings: RegDeleteKey failed on key \"%s\": %s", - rKey.toLatin1().data(), errorCodeToString(res).toLatin1().data()); + qPrintable(rKey), qPrintable(qt_error_string(int(res)))); } } RegCloseKey(handle); @@ -758,7 +743,7 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value) deleteWriteHandleOnExit = false; } else { qWarning("QSettings: failed to set subkey \"%s\": %s", - rKey.toLatin1().data(), errorCodeToString(res).toLatin1().data()); + qPrintable(rKey), qPrintable(qt_error_string(int(res)))); setStatus(QSettings::AccessError); } |