summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2011-08-24 09:03:02 +0300
committerQt by Nokia <qt-info@nokia.com>2012-01-14 03:55:03 +0100
commit106bab644a5d55f136d223fadc1440e07cd41872 (patch)
tree9102104c3de64cb20ece73b853abbd85b636717e /src/corelib
parentf0841fe4cfc31c32a311aeb724ac5ae9c8462af0 (diff)
Fix qsystemerror for WinCE
Windows CE does not have strerror(_r), so lets use string formatting provided by windowsErrorString function. In order to use windowsErrorString it was moved before standardLibraryErrorString function. Task-number: QTBUG-22498 Change-Id: Ifa20c4ac314ac8a26de6b0c5b67ced96b262c2b4 Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com> Reviewed-by: Shane Kearns <ext-shane.2.kearns@nokia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qsystemerror.cpp58
1 files changed, 33 insertions, 25 deletions
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index eabb20001c..708eba89a6 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -46,6 +46,10 @@
# if defined(Q_CC_MSVC)
# include <crtdbg.h>
# endif
+#else
+# if (_WIN32_WCE >= 0x700)
+# include <errno.h>
+# endif
#endif
#ifdef Q_OS_WIN
#include <windows.h>
@@ -76,6 +80,27 @@ namespace {
}
#endif
+#ifdef Q_OS_WIN
+static QString windowsErrorString(int errorCode)
+{
+ QString ret;
+ wchar_t *string = 0;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ errorCode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPWSTR)&string,
+ 0,
+ NULL);
+ ret = QString::fromWCharArray(string);
+ LocalFree((HLOCAL)string);
+
+ if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
+ ret = QString::fromLatin1("The specified module could not be found.");
+ return ret;
+}
+#endif
+
static QString standardLibraryErrorString(int errorCode)
{
const char *s = 0;
@@ -96,11 +121,15 @@ static QString standardLibraryErrorString(int errorCode)
s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
break;
default: {
- #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
- QByteArray buf(1024, '\0');
- ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
+ #ifdef Q_OS_WINCE
+ ret = windowsErrorString(errorCode);
#else
- ret = QString::fromLocal8Bit(strerror(errorCode));
+ #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
+ QByteArray buf(1024, '\0');
+ ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
+ #else
+ ret = QString::fromLocal8Bit(strerror(errorCode));
+ #endif
#endif
break; }
}
@@ -112,27 +141,6 @@ static QString standardLibraryErrorString(int errorCode)
return ret.trimmed();
}
-#ifdef Q_OS_WIN
-static QString windowsErrorString(int errorCode)
-{
- QString ret;
- wchar_t *string = 0;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- errorCode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&string,
- 0,
- NULL);
- ret = QString::fromWCharArray(string);
- LocalFree((HLOCAL)string);
-
- if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
- ret = QString::fromLatin1("The specified module could not be found.");
- return ret;
-}
-#endif
-
#ifdef Q_OS_SYMBIAN
static QString symbianErrorString(int errorCode)
{