summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2010-12-15 14:34:35 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2010-12-15 14:34:35 (GMT)
commitc50ef702872ee7adf8860bf164be6d092d8bde0f (patch)
tree0359d427ef4d67323bae485f5d3118e5b4564469 /src/corelib/kernel
parent4d86bacafad3b12ca01c20988bf578cde7bf3dae (diff)
parent567bcd38dd7a749ac0bc3cdd2432798ab1af74fe (diff)
downloadQt-c50ef702872ee7adf8860bf164be6d092d8bde0f.zip
Qt-c50ef702872ee7adf8860bf164be6d092d8bde0f.tar.gz
Qt-c50ef702872ee7adf8860bf164be6d092d8bde0f.tar.bz2
Merge remote branch 'qt/master' into symbian-socket-engine
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/kernel.pri118
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp7
-rw-r--r--src/corelib/kernel/qcoreevent.cpp2
-rw-r--r--src/corelib/kernel/qcoreevent.h3
-rw-r--r--src/corelib/kernel/qobject.cpp2
-rw-r--r--src/corelib/kernel/qsystemerror.cpp220
-rw-r--r--src/corelib/kernel/qsystemerror_p.h107
7 files changed, 401 insertions, 58 deletions
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 1e27c31..93818d1 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -1,81 +1,83 @@
# Qt core object module
HEADERS += \
- kernel/qabstracteventdispatcher.h \
+ kernel/qabstracteventdispatcher.h \
kernel/qabstractitemmodel.h \
kernel/qabstractitemmodel_p.h \
- kernel/qbasictimer.h \
- kernel/qeventloop.h\
- kernel/qpointer.h \
+ kernel/qbasictimer.h \
+ kernel/qeventloop.h\
+ kernel/qpointer.h \
kernel/qcorecmdlineargs_p.h \
- kernel/qcoreapplication.h \
- kernel/qcoreevent.h \
- kernel/qmetaobject.h \
- kernel/qmetatype.h \
- kernel/qmimedata.h \
- kernel/qobject.h \
- kernel/qobjectdefs.h \
- kernel/qsignalmapper.h \
- kernel/qsocketnotifier.h \
- kernel/qtimer.h \
- kernel/qtranslator.h \
+ kernel/qcoreapplication.h \
+ kernel/qcoreevent.h \
+ kernel/qmetaobject.h \
+ kernel/qmetatype.h \
+ kernel/qmimedata.h \
+ kernel/qobject.h \
+ kernel/qobjectdefs.h \
+ kernel/qsignalmapper.h \
+ kernel/qsocketnotifier.h \
+ kernel/qtimer.h \
+ kernel/qtranslator.h \
kernel/qtranslator_p.h \
kernel/qvariant.h \
- kernel/qabstracteventdispatcher_p.h \
- kernel/qcoreapplication_p.h \
- kernel/qobjectcleanuphandler.h \
+ kernel/qabstracteventdispatcher_p.h \
+ kernel/qcoreapplication_p.h \
+ kernel/qobjectcleanuphandler.h \
kernel/qvariant_p.h \
kernel/qmetaobject_p.h \
kernel/qobject_p.h \
- kernel/qcoreglobaldata_p.h \
- kernel/qsharedmemory.h \
+ kernel/qcoreglobaldata_p.h \
+ kernel/qsharedmemory.h \
kernel/qsharedmemory_p.h \
kernel/qsystemsemaphore.h \
kernel/qsystemsemaphore_p.h \
kernel/qfunctions_p.h \
- kernel/qmath.h
+ kernel/qmath.h \
+ kernel/qsystemerror_p.h
SOURCES += \
- kernel/qabstracteventdispatcher.cpp \
+ kernel/qabstracteventdispatcher.cpp \
kernel/qabstractitemmodel.cpp \
- kernel/qbasictimer.cpp \
- kernel/qeventloop.cpp \
- kernel/qcoreapplication.cpp \
- kernel/qcoreevent.cpp \
- kernel/qmetaobject.cpp \
- kernel/qmetatype.cpp \
- kernel/qmimedata.cpp \
- kernel/qobject.cpp \
- kernel/qobjectcleanuphandler.cpp \
- kernel/qsignalmapper.cpp \
- kernel/qsocketnotifier.cpp \
- kernel/qtimer.cpp \
- kernel/qtranslator.cpp \
- kernel/qvariant.cpp \
+ kernel/qbasictimer.cpp \
+ kernel/qeventloop.cpp \
+ kernel/qcoreapplication.cpp \
+ kernel/qcoreevent.cpp \
+ kernel/qmetaobject.cpp \
+ kernel/qmetatype.cpp \
+ kernel/qmimedata.cpp \
+ kernel/qobject.cpp \
+ kernel/qobjectcleanuphandler.cpp \
+ kernel/qsignalmapper.cpp \
+ kernel/qsocketnotifier.cpp \
+ kernel/qtimer.cpp \
+ kernel/qtranslator.cpp \
+ kernel/qvariant.cpp \
kernel/qcoreglobaldata.cpp \
kernel/qsharedmemory.cpp \
kernel/qsystemsemaphore.cpp \
kernel/qpointer.cpp \
- kernel/qmath.cpp
+ kernel/qmath.cpp \
+ kernel/qsystemerror.cpp
win32 {
- SOURCES += \
- kernel/qeventdispatcher_win.cpp \
- kernel/qcoreapplication_win.cpp \
- kernel/qwineventnotifier_p.cpp \
+ SOURCES += \
+ kernel/qeventdispatcher_win.cpp \
+ kernel/qcoreapplication_win.cpp \
+ kernel/qwineventnotifier_p.cpp \
kernel/qsharedmemory_win.cpp \
kernel/qsystemsemaphore_win.cpp
- HEADERS += \
- kernel/qeventdispatcher_win_p.h \
- kernel/qwineventnotifier_p.h
+ HEADERS += \
+ kernel/qeventdispatcher_win_p.h \
+ kernel/qwineventnotifier_p.h
}
wince*: {
- SOURCES += \
- kernel/qfunctions_wince.cpp
- HEADERS += \
- kernel/qfunctions_wince.h
+ SOURCES += \
+ kernel/qfunctions_wince.cpp
+ HEADERS += \
+ kernel/qfunctions_wince.h
}
mac:!embedded:!qpa{
@@ -85,18 +87,18 @@ mac:!embedded:!qpa{
mac:!nacl {
SOURCES += \
- kernel/qcore_mac.cpp
+ kernel/qcore_mac.cpp
}
unix:!symbian {
- SOURCES += \
+ SOURCES += \
kernel/qcore_unix.cpp \
kernel/qcrashhandler.cpp \
kernel/qsharedmemory_unix.cpp \
kernel/qsystemsemaphore_unix.cpp
- HEADERS += \
+ HEADERS += \
kernel/qcore_unix_p.h \
- kernel/qcrashhandler_p.h
+ kernel/qcrashhandler_p.h
contains(QT_CONFIG, glib) {
SOURCES += \
@@ -115,7 +117,7 @@ unix:!symbian {
}
symbian {
- SOURCES += \
+ SOURCES += \
kernel/qcore_unix.cpp \
kernel/qcrashhandler.cpp \
kernel/qeventdispatcher_symbian.cpp \
@@ -123,7 +125,7 @@ symbian {
kernel/qsharedmemory_symbian.cpp \
kernel/qsystemsemaphore_symbian.cpp
- HEADERS += \
+ HEADERS += \
kernel/qcore_unix_p.h \
kernel/qcrashhandler_p.h \
kernel/qeventdispatcher_symbian_p.h \
@@ -131,9 +133,9 @@ symbian {
}
vxworks {
- SOURCES += \
- kernel/qfunctions_vxworks.cpp
- HEADERS += \
- kernel/qfunctions_vxworks.h
+ SOURCES += \
+ kernel/qfunctions_vxworks.cpp
+ HEADERS += \
+ kernel/qfunctions_vxworks.h
}
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index a8dc491..0f95ee0 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -71,6 +71,7 @@
# include <e32ldr.h>
# include "qeventdispatcher_symbian_p.h"
# include "private/qcore_symbian_p.h"
+# include "private/qfilesystemengine_p.h"
#elif defined(Q_OS_UNIX)
# if !defined(QT_NO_GLIB)
# include "qeventdispatcher_glib_p.h"
@@ -567,6 +568,12 @@ void QCoreApplication::init()
Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object");
QCoreApplication::self = this;
+#ifdef Q_OS_SYMBIAN
+ //ensure temp and working directories exist
+ QFileSystemEngine::createDirectory(QFileSystemEntry(QFileSystemEngine::tempPath()), true);
+ QFileSystemEngine::createDirectory(QFileSystemEntry(QFileSystemEngine::currentPath()), true);
+#endif
+
#ifndef QT_NO_THREAD
QThread::initialize();
#endif
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index d23ea4c..4da5fa9 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -231,6 +231,8 @@ QT_BEGIN_NAMESPACE
\value WinIdChange The window system identifer for this native widget has changed
\value Gesture A gesture was triggered (QGestureEvent)
\value GestureOverride A gesture override was triggered (QGestureEvent)
+ \value ScrollPrepare The object needs to fill in its geometry information (QScrollPrepareEvent)
+ \value Scroll The object needs to scroll to the supplied position (QScrollEvent)
User events should have values between \c User and \c{MaxUser}:
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index 4c91aaf..08b751c 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -288,6 +288,9 @@ public:
Gesture = 198,
GestureOverride = 202,
#endif
+ ScrollPrepare = 204,
+ Scroll = 205,
+
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 7fe9c52..c3102ea 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -408,6 +408,8 @@ void QMetaObject::removeGuard(QObject **ptr)
if (!hash || hash->isEmpty())
return;
QMutexLocker locker(guardHashLock());
+ if (!*ptr) //check again, under the lock
+ return;
GuardHash::iterator it = hash->find(*ptr);
const GuardHash::iterator end = hash->end();
bool more = false; //if the QObject has more pointer attached to it.
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
new file mode 100644
index 0000000..953ed95
--- /dev/null
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qglobal.h>
+#include "qsystemerror_p.h"
+#if !defined(Q_OS_WINCE)
+# include <errno.h>
+# if defined(Q_CC_MSVC)
+# include <crtdbg.h>
+# endif
+#endif
+#ifdef Q_OS_WIN
+#include <windows.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \
+ defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
+namespace {
+ // There are two incompatible versions of strerror_r:
+ // a) the XSI/POSIX.1 version, which returns an int,
+ // indicating success or not
+ // b) the GNU version, which returns a char*, which may or may not
+ // be the beginning of the buffer we used
+ // The GNU libc manpage for strerror_r says you should use the the XSI
+ // version in portable code. However, it's impossible to do that if
+ // _GNU_SOURCE is defined so we use C++ overloading to decide what to do
+ // depending on the return type
+ static inline QString fromstrerror_helper(int, const QByteArray &buf)
+ {
+ return QString::fromLocal8Bit(buf);
+ }
+ static inline QString fromstrerror_helper(const char *str, const QByteArray &)
+ {
+ return QString::fromLocal8Bit(str);
+ }
+}
+#endif
+
+static QString standardLibraryErrorString(int errorCode)
+{
+ const char *s = 0;
+ QString ret;
+ switch (errorCode) {
+ case 0:
+ break;
+ case EACCES:
+ s = QT_TRANSLATE_NOOP("QIODevice", "Permission denied");
+ break;
+ case EMFILE:
+ s = QT_TRANSLATE_NOOP("QIODevice", "Too many open files");
+ break;
+ case ENOENT:
+ s = QT_TRANSLATE_NOOP("QIODevice", "No such file or directory");
+ break;
+ case ENOSPC:
+ 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);
+ #else
+ ret = QString::fromLocal8Bit(strerror(errorCode));
+ #endif
+ break; }
+ }
+ if (s) {
+ // ######## this breaks moc build currently
+ // ret = QCoreApplication::translate("QIODevice", s);
+ ret = QString::fromLatin1(s);
+ }
+ 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)
+{
+ switch (errorCode) {
+ case KErrNotFound:
+ return QLatin1String("not found");
+ case KErrCancel:
+ return QLatin1String("cancelled");
+ case KErrNoMemory:
+ return QLatin1String("out of memory");
+ case KErrNotSupported:
+ return QLatin1String("not supported");
+ case KErrBadHandle:
+ return QLatin1String("bad handle"); //KERN-EXEC 0 panic is more likely
+ case KErrAlreadyExists:
+ return QLatin1String("already exists");
+ case KErrPathNotFound:
+ return QLatin1String("path not found");
+ case KErrInUse:
+ return QLatin1String("in use");
+ case KErrNotReady:
+ return QLatin1String("not ready (e.g. FS dismounted, no memory card)");
+ case KErrCorrupt:
+ return QLatin1String("corrupt");
+ case KErrAccessDenied:
+ return QLatin1String("access denied");
+ case KErrLocked:
+ return QLatin1String("locked");
+ case KErrWrite:
+ return QLatin1String("incomplete write error");
+ case KErrDisMounted:
+ return QLatin1String("file system dismounted during operation"); //i.e. a forcible dismount was done while we had files open
+ case KErrEof:
+ return QLatin1String("end of file");
+ case KErrDiskFull:
+ return QLatin1String("no space in file system");
+ case KErrBadName:
+ return QLatin1String("invalid filename");
+ case KErrTimedOut:
+ return QLatin1String("timed out");
+ case KErrBadDescriptor:
+ return QLatin1String("bad descriptor (passed address on stack to async call?)");
+ case KErrAbort:
+ return QLatin1String("aborted");
+ case KErrTooBig:
+ return QLatin1String("too big"); //e.g. trying to open a >2GB file with 32 bit API
+ case KErrBadPower:
+ return QLatin1String("insufficient power");
+ case KErrDirFull:
+ return QLatin1String("no space in directory table");
+ case KErrHardwareNotAvailable:
+ return QLatin1String("hardware not available");
+ case KErrSessionClosed:
+ return QLatin1String("session closed");
+ case KErrPermissionDenied:
+ return QLatin1String("permission denied");
+ default:
+ return QString(QLatin1String("symbian error %d")).arg(errorCode);
+ }
+}
+#endif
+
+QString QSystemError::toString()
+{
+ switch(errorScope) {
+ case NativeError:
+#if defined (Q_OS_WIN)
+ return windowsErrorString(errorCode);
+#elif defined (Q_OS_SYMBIAN)
+ return symbianErrorString(errorCode);
+#else
+ //unix: fall through as native and standard library are the same
+#endif
+ case StandardLibraryError:
+ return standardLibraryErrorString(errorCode);
+ default:
+ qWarning("invalid error scope");
+ //fall through
+ case NoError:
+ return QLatin1String("No error");
+ }
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h
new file mode 100644
index 0000000..c2a13a8
--- /dev/null
+++ b/src/corelib/kernel/qsystemerror_p.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSYSTEMERROR_P_H
+#define QSYSTEMERROR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qstring.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_CORE_EXPORT QSystemError
+{
+public:
+ enum ErrorScope
+ {
+ NoError,
+ StandardLibraryError,
+ NativeError
+ };
+
+ inline QSystemError(int error, ErrorScope scope);
+ inline QSystemError();
+
+ QString toString();
+ inline ErrorScope scope();
+ inline int error();
+
+ //data members
+ int errorCode;
+ ErrorScope errorScope;
+};
+
+QSystemError::QSystemError(int error, QSystemError::ErrorScope scope)
+: errorCode(error), errorScope(scope)
+{
+
+}
+
+QSystemError::QSystemError()
+: errorCode(0), errorScope(NoError)
+{
+
+}
+
+QSystemError::ErrorScope QSystemError::scope()
+{
+ return errorScope;
+}
+
+int QSystemError::error()
+{
+ return errorCode;
+}
+
+
+QT_END_NAMESPACE
+
+#endif // QSYSTEMERROR_P_H