Fix flawed logic in QSystemLocalePrivate::getLocaleInfo()
If the first call to GetLocaleInfo() returned non-zero, then GetLastError()'s return has nothing to do with GetLocaleInfo(), since it didn't fail. The check for ERROR_INSUFFICIENT_BUFFER as last error needs to happen in the branch where GetLocaleInfo() failed, returning zero. Change-Id: Idb6eaad1515a003133c787998aff0c265ef98251 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
495db2cd2b
commit
3041393d2e
@ -214,9 +214,9 @@ inline int QSystemLocalePrivate::getLocaleInfo(LCTYPE type, LPWSTR data, int siz
|
||||
QString QSystemLocalePrivate::getLocaleInfo(LCTYPE type, int maxlen)
|
||||
{
|
||||
QVarLengthArray<wchar_t, 64> buf(maxlen ? maxlen : 64);
|
||||
if (!getLocaleInfo(type, buf.data(), buf.size()))
|
||||
return QString();
|
||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
|
||||
if (!getLocaleInfo(type, buf.data(), buf.size())) {
|
||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
return QString();
|
||||
int cnt = getLocaleInfo(type, 0, 0);
|
||||
if (cnt == 0)
|
||||
return QString();
|
||||
|
Loading…
Reference in New Issue
Block a user