summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/kernel.pri1
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp24
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp150
-rw-r--r--src/corelib/kernel/qcore_unix.cpp65
-rw-r--r--src/corelib/kernel/qcore_unix_p.h4
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp38
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h7
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp65
-rw-r--r--src/corelib/kernel/qcoreevent.cpp3
-rw-r--r--src/corelib/kernel/qcoreevent.h9
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp3
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp22
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian_p.h4
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp9
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp43
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h6
-rw-r--r--src/corelib/kernel/qeventloop.cpp4
-rw-r--r--src/corelib/kernel/qguard_p.h157
-rw-r--r--src/corelib/kernel/qmetaobject.cpp154
-rw-r--r--src/corelib/kernel/qmetaobject_p.h32
-rw-r--r--src/corelib/kernel/qmetatype.cpp351
-rw-r--r--src/corelib/kernel/qmetatype.h55
-rw-r--r--src/corelib/kernel/qobject.cpp143
-rw-r--r--src/corelib/kernel/qobject_p.h61
-rw-r--r--src/corelib/kernel/qobjectdefs.h8
-rw-r--r--src/corelib/kernel/qsystemsemaphore_symbian.cpp2
-rw-r--r--src/corelib/kernel/qtimer.cpp14
-rw-r--r--src/corelib/kernel/qtranslator.cpp6
-rw-r--r--src/corelib/kernel/qvariant.cpp59
-rw-r--r--src/corelib/kernel/qvariant.h15
30 files changed, 861 insertions, 653 deletions
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index d0dad49..1851e04 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -33,7 +33,6 @@ HEADERS += \
kernel/qsystemsemaphore.h \
kernel/qsystemsemaphore_p.h \
kernel/qfunctions_p.h \
- kernel/qguard_p.h \
kernel/qmath.h
SOURCES += \
diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp
index ee3c4f2..bcf4477 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.cpp
+++ b/src/corelib/kernel/qabstracteventdispatcher.cpp
@@ -393,6 +393,27 @@ void QAbstractEventDispatcher::closingDown()
\snippet doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp 0
+ Note that the type of the \a message is platform dependent. The
+ following table shows the \a {message}'s type on Windows, Mac, and
+ X11. You can do a static cast to these types.
+
+ \table
+ \header
+ \o Platform
+ \o type
+ \row
+ \o Windows
+ \o MSG
+ \row
+ \o X11
+ \o XEvent
+ \row
+ \o Mac
+ \o NSEvent
+ \endtable
+
+
+
\sa setEventFilter(), filterEvent()
*/
@@ -434,6 +455,9 @@ QAbstractEventDispatcher::EventFilter QAbstractEventDispatcher::setEventFilter(E
compatibility with any extensions that may be used in the
application.
+ Note that the type of \a message is platform dependent. See
+ QAbstractEventDispatcher::EventFilter for details.
+
\sa setEventFilter()
*/
bool QAbstractEventDispatcher::filterEvent(void *message)
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index 36e4af9..8415259 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -1248,7 +1248,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
/*!
\fn QModelIndex QAbstractItemModel::parent(const QModelIndex &index) const = 0
- Returns the parent of the model item with the given \a index. If the model
+ Returns the parent of the model item with the given \a index. If the item
has no parent, an invalid QModelIndex is returned.
A common convention used in models that expose tree data structures is that
@@ -2501,38 +2501,96 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star
}
/*!
+ \since 4.6
+
Begins a row move operation.
When reimplementing a subclass, this method simplifies moving
entities in your model. This method is responsible for moving
persistent indexes in the model, which you would otherwise be
- required to do yourself.
-
- Using beginMoveRows and endMoveRows is an alternative to emitting
- layoutAboutToBeChanged and layoutChanged directly along with
- changePersistentIndexes. layoutAboutToBeChanged is emitted by
- this method for compatibility reasons.
+ required to do yourself. Using beginMoveRows and endMoveRows
+ is an alternative to emitting layoutAboutToBeChanged and
+ layoutChanged directly along with changePersistentIndexes.
+ layoutAboutToBeChanged is emitted by this method for compatibility
+ reasons.
The \a sourceParent index corresponds to the parent from which the
- rows are moved; \a sourceFirst and \a sourceLast are the row
- numbers of the rows to be moved. The \a destinationParent index
- corresponds to the parent into which the rows are moved. The \a
+ rows are moved; \a sourceFirst and \a sourceLast are the first and last
+ row numbers of the rows to be moved. The \a destinationParent index
+ corresponds to the parent into which those rows are moved. The \a
destinationChild is the row to which the rows will be moved. That
is, the index at row \a sourceFirst in \a sourceParent will become
- row \a destinationChild in \a destinationParent. Its siblings will
- be moved correspondingly.
+ row \a destinationChild in \a destinationParent, followed by all other
+ rows up to \a sourceLast.
+
+ However, when moving rows down in the same parent (\a sourceParent
+ and \a destinationParent are equal), the rows will be placed before the
+ \a destinationChild index. That is, if you wish to move rows 0 and 1 so
+ they will become rows 1 and 2, \a destinationChild should be 3. In this
+ case, the new index for the source row \c i (which is between
+ \a sourceFirst and \a sourceLast) is equal to
+ \c {(destinationChild-sourceLast-1+i)}.
+
+ Note that if \a sourceParent and \a destinationParent are the same,
+ you must ensure that the \a destinationChild is not within the range
+ of \a sourceFirst and \a sourceLast + 1. You must also ensure that you
+ do not attempt to move a row to one of its own children or ancestors.
+ This method returns false if either condition is true, in which case you
+ should abort your move operation.
- Note that \a sourceParent and \a destinationParent may be the
- same, in which case you must ensure that the \a destinationChild is
- not within the range of \a sourceFirst and \a sourceLast. You
- must also ensure that you do not attempt to move a row to one of
- its own chilren or ancestors. This method returns false if either
- condition is true, in which case you should abort your move
- operation.
+ \table 80%
+ \row
+ \o \inlineimage modelview-move-rows-1.png Moving rows to another parent
+ \o Specify the first and last row numbers for the span of rows in
+ the source parent you want to move in the model. Also specify
+ the row in the destination parent to move the span to.
- \sa endMoveRows()
+ For example, as shown in the diagram, we move three rows from
+ row 2 to 4 in the source, so \a sourceFirst is 2 and \a sourceLast is 4.
+ We move those items to above row 2 in the destination, so \a destinationRow is 2.
- \since 4.6
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 6
+
+ This moves the three rows rows 2, 3, and 4 in the source to become 2, 3 and 4 in
+ the destination. Other affected siblings are displaced accordingly.
+ \row
+ \o \inlineimage modelview-move-rows-2.png Moving rows to append to another parent
+ \o To append rows to another parent, move them to after the last row.
+
+ For example, as shown in the diagram, we move three rows to a
+ collection of 6 existing rows (ending in row 5), so \a destinationStart is 6:
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 7
+
+ This moves the target rows to the end of the target parent as 6, 7 and 8.
+ \row
+ \o \inlineimage modelview-move-rows-3.png Moving rows in the same parent up
+ \o To move rows within the same parent, specify the row to move them to.
+
+ For example, as shown in the diagram, we move one item from row 2 to row 0,
+ so \a sourceFirst and \a sourceLast are 2 and \a destinationChild is 0.
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 8
+
+ Note that other rows may be displaced accordingly. Note also that when moving
+ items within the same parent you should not attempt invalid or no-op moves. In
+ the above example, item 2 is at row 2 before the move, so it can not be moved
+ to row 2 (where it is already) or row 3 (no-op as row 3 means above row 3, where
+ it is already)
+
+ \row
+ \o \inlineimage modelview-move-rows-4.png Moving rows in the same parent down
+ \o To move rows within the same parent, specify the row to move them to.
+
+ For example, as shown in the diagram, we move one item from row 2 to row 4,
+ so \a sourceFirst and \a sourceLast are 2 and \a destinationChild is 4.
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 9
+
+ Note that other rows may be displaced accordingly.
+ \endtable
+
+ \sa endMoveRows()
*/
bool QAbstractItemModel::beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
{
@@ -2709,29 +2767,35 @@ void QAbstractItemModel::endRemoveColumns()
When reimplementing a subclass, this method simplifies moving
entities in your model. This method is responsible for moving
persistent indexes in the model, which you would otherwise be
- required to do yourself.
-
- Using beginMoveColumns and endMoveColumns is an alternative to
- emitting layoutAboutToBeChanged and layoutChanged directly along
- with changePersistentIndexes. layoutAboutToBeChanged is emitted
- by this method for compatibility reasons.
+ required to do yourself. Using beginMoveRows and endMoveRows
+ is an alternative to emitting layoutAboutToBeChanged and
+ layoutChanged directly along with changePersistentIndexes.
+ layoutAboutToBeChanged is emitted by this method for compatibility
+ reasons.
The \a sourceParent index corresponds to the parent from which the
- columns are moved; \a sourceFirst and \a sourceLast are the column
- numbers of the columns to be moved. The \a destinationParent index
- corresponds to the parent into which the columns are moved. The \a
- destinationChild is the column to which the columns will be
- moved. That is, the index at column \a sourceFirst in \a
- sourceParent will become column \a destinationChild in \a
- destinationParent. Its siblings will be moved correspondingly.
-
- Note that \a sourceParent and \a destinationParent may be the
- same, in which case you must ensure that the \a destinationChild
- is not within the range of \a sourceFirst and \a sourceLast. You
- must also ensure that you do not attempt to move a row to one of
- its own chilren or ancestors. This method returns false if either
- condition is true, in which case you should abort your move
- operation.
+ columns are moved; \a sourceFirst and \a sourceLast are the first and last
+ column numbers of the columns to be moved. The \a destinationParent index
+ corresponds to the parent into which those columns are moved. The \a
+ destinationChild is the column to which the columns will be moved. That
+ is, the index at column \a sourceFirst in \a sourceParent will become
+ column \a destinationChild in \a destinationParent, followed by all other
+ columns up to \a sourceLast.
+
+ However, when moving columns down in the same parent (\a sourceParent
+ and \a destinationParent are equal), the columnss will be placed before the
+ \a destinationChild index. That is, if you wish to move columns 0 and 1 so
+ they will become columns 1 and 2, \a destinationChild should be 3. In this
+ case, the new index for the source column \c i (which is between
+ \a sourceFirst and \a sourceLast) is equal to
+ \c {(destinationChild-sourceLast-1+i)}.
+
+ Note that if \a sourceParent and \a destinationParent are the same,
+ you must ensure that the \a destinationChild is not within the range
+ of \a sourceFirst and \a sourceLast + 1. You must also ensure that you
+ do not attempt to move a column to one of its own children or ancestors.
+ This method returns false if either condition is true, in which case you
+ should abort your move operation.
\sa endMoveColumns()
@@ -2790,7 +2854,7 @@ void QAbstractItemModel::endMoveColumns()
\note Use beginResetModel() and endResetModel() instead whenever possible.
Use this method only if there is no way to call beginResetModel() before invalidating the model.
- Otherwise it could lead to unexcpected behaviour, especially when used with proxy models.
+ Otherwise it could lead to unexpected behaviour, especially when used with proxy models.
*/
void QAbstractItemModel::reset()
{
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp
index 0fd965b..e0d92c0 100644
--- a/src/corelib/kernel/qcore_unix.cpp
+++ b/src/corelib/kernel/qcore_unix.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qcore_unix_p.h"
+#include "qelapsedtimer.h"
#ifndef Q_OS_VXWORKS
# if !defined(Q_OS_HPUX) || defined(__ia64)
@@ -56,74 +57,12 @@
#include <mach/mach_time.h>
#endif
-#if !defined(QT_NO_CLOCK_MONOTONIC)
-# if defined(QT_BOOTSTRAPPED)
-# define QT_NO_CLOCK_MONOTONIC
-# endif
-#endif
-
QT_BEGIN_NAMESPACE
-bool qt_gettime_is_monotonic()
-{
-#if (_POSIX_MONOTONIC_CLOCK-0 > 0) || defined(Q_OS_MAC)
- return true;
-#else
- static int returnValue = 0;
-
- if (returnValue == 0) {
-# if (_POSIX_MONOTONIC_CLOCK-0 < 0)
- returnValue = -1;
-# elif (_POSIX_MONOTONIC_CLOCK == 0)
- // detect if the system support monotonic timers
- long x = sysconf(_SC_MONOTONIC_CLOCK);
- returnValue = (x >= 200112L) ? 1 : -1;
-# endif
- }
-
- return returnValue != -1;
-#endif
-}
-
-timeval qt_gettime()
-{
- timeval tv;
-#if defined(Q_OS_MAC)
- static mach_timebase_info_data_t info = {0,0};
- if (info.denom == 0)
- mach_timebase_info(&info);
-
- uint64_t cpu_time = mach_absolute_time();
- uint64_t nsecs = cpu_time * (info.numer / info.denom);
- tv.tv_sec = nsecs / 1000000000ull;
- tv.tv_usec = (nsecs / 1000) - (tv.tv_sec * 1000000);
- return tv;
-#elif (_POSIX_MONOTONIC_CLOCK-0 > 0)
- timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- tv.tv_sec = ts.tv_sec;
- tv.tv_usec = ts.tv_nsec / 1000;
- return tv;
-#else
-# if !defined(QT_NO_CLOCK_MONOTONIC) && !defined(QT_BOOTSTRAPPED)
- if (qt_gettime_is_monotonic()) {
- timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- tv.tv_sec = ts.tv_sec;
- tv.tv_usec = ts.tv_nsec / 1000;
- return tv;
- }
-# endif
- // use gettimeofday
- ::gettimeofday(&tv, 0);
- return tv;
-#endif
-}
-
static inline bool time_update(struct timeval *tv, const struct timeval &start,
const struct timeval &timeout)
{
- if (!qt_gettime_is_monotonic()) {
+ if (!QElapsedTimer::isMonotonic()) {
// we cannot recalculate the timeout without a monotonic clock as the time may have changed
return false;
}
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index 297b25d..439ca5a 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -314,8 +314,8 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options)
# define _POSIX_MONOTONIC_CLOCK -1
#endif
-bool qt_gettime_is_monotonic();
-timeval qt_gettime();
+timeval qt_gettime(); // in qelapsedtimer_mac.cpp or qtimestamp_unix.cpp
+
Q_CORE_EXPORT int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
const struct timeval *tv);
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 102c41e..0a5e06e 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -47,7 +47,6 @@
#include "qeventloop.h"
#include "qcorecmdlineargs_p.h"
#include <qdatastream.h>
-#include <qdatetime.h>
#include <qdebug.h>
#include <qdir.h>
#include <qfile.h>
@@ -59,10 +58,12 @@
#include <qthreadpool.h>
#include <qthreadstorage.h>
#include <private/qthread_p.h>
+#include <qelapsedtimer.h>
#include <qlibraryinfo.h>
#include <qvarlengtharray.h>
#include <private/qfactoryloader_p.h>
#include <private/qfunctions_p.h>
+#include <private/qlocale_p.h>
#ifdef Q_OS_SYMBIAN
# include <exception>
@@ -514,17 +515,18 @@ QCoreApplication::QCoreApplication(int &argc, char **argv)
{
init();
QCoreApplicationPrivate::eventDispatcher->startingUp();
-#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_LIBRARY)
// Refresh factoryloader, as text codecs are requested during lib path
// resolving process and won't be therefore properly loaded.
// Unknown if this is symbian specific issue.
QFactoryLoader::refreshAll();
#endif
+#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
+ d_func()->symbianInit();
+#endif
}
-extern void set_winapp_name();
-
// ### move to QCoreApplicationPrivate constructor?
void QCoreApplication::init()
{
@@ -535,11 +537,6 @@ void QCoreApplication::init()
qt_locale_initialized = true;
#endif
-#ifdef Q_WS_WIN
- // Get the application name/instance if qWinMain() was not invoked
- set_winapp_name();
-#endif
-
Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object");
QCoreApplication::self = this;
@@ -604,6 +601,15 @@ void QCoreApplication::init()
qt_startup_hook();
}
+#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
+void QCoreApplicationPrivate::symbianInit()
+{
+ if (!environmentChangeNotifier)
+ environmentChangeNotifier.reset(new QEnvironmentChangeNotifier);
+}
+#endif
+
+
/*!
Destroys the QCoreApplication object.
*/
@@ -939,7 +945,7 @@ void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int m
QThreadData *data = QThreadData::current();
if (!data->eventDispatcher)
return;
- QTime start;
+ QElapsedTimer start;
start.start();
if (flags & QEventLoop::DeferredDeletion)
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
@@ -1067,7 +1073,7 @@ void QCoreApplication::exit(int returnCode)
The event must be allocated on the heap since the post event queue
will take ownership of the event and delete it once it has been
- posted. It is \e {not safe} to modify or delete the event after
+ posted. It is \e {not safe} to access the event after
it has been posted.
When control returns to the main event loop, all events that are
@@ -1098,7 +1104,7 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event)
The event must be allocated on the heap since the post event queue
will take ownership of the event and delete it once it has been
- posted. It is \e {not safe} to modify or delete the event after
+ posted. It is \e {not safe} to access the event after
it has been posted.
When control returns to the main event loop, all events that are
@@ -2196,7 +2202,7 @@ QString QCoreApplication::applicationVersion()
return coreappdata()->applicationVersion;
}
-#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QMutex, libraryPathMutex, (QMutex::Recursive))
@@ -2298,13 +2304,11 @@ QStringList QCoreApplication::libraryPaths()
*/
void QCoreApplication::setLibraryPaths(const QStringList &paths)
{
-#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
QMutexLocker locker(libraryPathMutex());
if (!coreappdata()->app_libpaths)
coreappdata()->app_libpaths = new QStringList;
*(coreappdata()->app_libpaths) = paths;
QFactoryLoader::refreshAll();
-#endif
}
/*!
@@ -2325,7 +2329,6 @@ void QCoreApplication::setLibraryPaths(const QStringList &paths)
*/
void QCoreApplication::addLibraryPath(const QString &path)
{
-#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
if (path.isEmpty())
return;
@@ -2340,7 +2343,6 @@ void QCoreApplication::addLibraryPath(const QString &path)
coreappdata()->app_libpaths->prepend(canonicalPath);
QFactoryLoader::refreshAll();
}
-#endif
}
/*!
@@ -2351,7 +2353,6 @@ void QCoreApplication::addLibraryPath(const QString &path)
*/
void QCoreApplication::removeLibraryPath(const QString &path)
{
-#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
if (path.isEmpty())
return;
@@ -2363,7 +2364,6 @@ void QCoreApplication::removeLibraryPath(const QString &path)
QString canonicalPath = QDir(path).canonicalPath();
coreappdata()->app_libpaths->removeAll(canonicalPath);
QFactoryLoader::refreshAll();
-#endif
}
#endif //QT_NO_LIBRARY
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 77188d3..e066137 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -65,6 +65,9 @@ QT_BEGIN_NAMESPACE
typedef QList<QTranslator*> QTranslatorList;
+#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
+class QEnvironmentChangeNotifier;
+#endif
class QAbstractEventDispatcher;
class Q_CORE_EXPORT QCoreApplicationPrivate : public QObjectPrivate
@@ -113,6 +116,10 @@ public:
bool aboutToQuitEmitted;
QString cachedApplicationDirPath;
QString cachedApplicationFilePath;
+#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
+ QScopedPointer<QEnvironmentChangeNotifier> environmentChangeNotifier;
+ void symbianInit();
+#endif
static bool isTranslatorInstalled(QTranslator *translator);
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 5990f86..320f801 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -52,26 +52,31 @@
QT_BEGIN_NAMESPACE
-char appFileName[MAX_PATH]; // application file name
-char theAppName[MAX_PATH]; // application name
-HINSTANCE appInst = 0; // handle to app instance
-HINSTANCE appPrevInst = 0; // handle to prev app instance
-int appCmdShow = 0;
bool usingWinMain = false; // whether the qWinMain() is used or not
+int appCmdShow = 0;
Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle
{
- return appInst;
+ return GetModuleHandle(0);
}
Q_CORE_EXPORT HINSTANCE qWinAppPrevInst() // get Windows prev app handle
{
- return appPrevInst;
+ return 0;
}
Q_CORE_EXPORT int qWinAppCmdShow() // get main window show command
{
+#if defined(Q_OS_WINCE)
return appCmdShow;
+#else
+ STARTUPINFO startupInfo;
+ GetStartupInfo(&startupInfo);
+
+ return (startupInfo.dwFlags & STARTF_USESHOWWINDOW)
+ ? startupInfo.wShowWindow
+ : SW_SHOWDEFAULT;
+#endif
}
Q_CORE_EXPORT QString qAppFileName() // get application file name
@@ -115,25 +120,6 @@ Q_CORE_EXPORT QString qAppFileName() // get application file name
return res;
}
-void set_winapp_name()
-{
- static bool already_set = false;
- if (!already_set) {
- already_set = true;
-
- QString moduleName = qAppFileName();
-
- QByteArray filePath = moduleName.toLocal8Bit();
- QByteArray fileName = QFileInfo(moduleName).baseName().toLocal8Bit();
-
- memcpy(appFileName, filePath.constData(), filePath.length());
- memcpy(theAppName, fileName.constData(), fileName.length());
-
- if (appInst == 0)
- appInst = GetModuleHandle(0);
- }
-}
-
QString QCoreApplicationPrivate::appName() const
{
return QFileInfo(qAppFileName()).baseName();
@@ -198,20 +184,17 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
already_called = true;
usingWinMain = true;
- // Install default debug handler
-
+ // Install default debug handler
qInstallMsgHandler(qWinMsgHandler);
- // Create command line
-
+ // Create command line
argv = qWinCmdLine<char>(cmdParam, int(strlen(cmdParam)), argc);
- // Get Windows parameters
- appInst = instance;
- appPrevInst = prevInstance;
appCmdShow = cmdShow;
- set_winapp_name();
+ // Ignore Windows parameters
+ Q_UNUSED(instance);
+ Q_UNUSED(prevInstance);
}
/*!
@@ -1021,14 +1004,14 @@ QString decodeMSG(const MSG& msg)
LPWINDOWPOS winPos = (LPWINDOWPOS)lParam;
if (!winPos)
break;
- QString hwndAfter = valueCheck((uint)winPos->hwndInsertAfter,
- FLAG_STRING((uint)HWND_BOTTOM, "HWND_BOTTOM"),
- FLAG_STRING((int)HWND_NOTOPMOST, "HWND_NOTOPMOST"),
- FLAG_STRING((uint)HWND_TOP, "HWND_TOP"),
- FLAG_STRING((int)HWND_TOPMOST, "HWND_TOPMOST"),
+ QString hwndAfter = valueCheck(quint64(winPos->hwndInsertAfter),
+ FLAG_STRING((qptrdiff)HWND_BOTTOM, "HWND_BOTTOM"),
+ FLAG_STRING((qptrdiff)HWND_NOTOPMOST, "HWND_NOTOPMOST"),
+ FLAG_STRING((qptrdiff)HWND_TOP, "HWND_TOP"),
+ FLAG_STRING((qptrdiff)HWND_TOPMOST, "HWND_TOPMOST"),
FLAG_STRING());
- if (hwndAfter.size() == 0)
- hwndAfter = QString::number((uint)winPos->hwndInsertAfter, 16);
+ if (hwndAfter.isEmpty())
+ hwndAfter = QString::number((quintptr)winPos->hwndInsertAfter, 16);
QString flags = flagCheck(winPos->flags,
FLGSTR(SWP_DRAWFRAME),
FLGSTR(SWP_FRAMECHANGED),
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index 3500b63..d23ea4c 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -272,7 +272,6 @@ QT_BEGIN_NAMESPACE
\omitvalue MacGLClearDrawable
\omitvalue NetworkReplyUpdated
\omitvalue FutureCallOut
- \omitvalue CocoaRequestModal
\omitvalue UpdateSoftKeys
\omitvalue NativeGesture
*/
@@ -331,7 +330,7 @@ QEvent::~QEvent()
equivalent of calling setAccepted(false).
Clearing the accept parameter indicates that the event receiver
- does not want the event. Unwanted events might be propgated to the
+ does not want the event. Unwanted events might be propagated to the
parent widget.
\sa accept()
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index c76e81b..9d3513a 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -266,7 +266,6 @@ public:
UngrabMouse = 187,
GrabKeyboard = 188,
UngrabKeyboard = 189,
- CocoaRequestModal = 190, // Internal for requesting an application modal Cocoa Window
MacGLClearDrawable = 191, // Internal Cocoa, the window has changed, so we must clear
StateMachineSignal = 192,
@@ -276,17 +275,19 @@ public:
TouchUpdate = 195,
TouchEnd = 196,
+#ifndef QT_NO_GESTURES
NativeGesture = 197, // Internal for platform gesture support
-
+#endif
RequestSoftwareInputPanel = 199,
CloseSoftwareInputPanel = 200,
UpdateSoftKeys = 201, // Internal for compressing soft key updates
WinIdChange = 203,
+#ifndef QT_NO_GESTURES
Gesture = 198,
GestureOverride = 202,
-
+#endif
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
@@ -328,7 +329,9 @@ private:
friend class QGraphicsView;
friend class QGraphicsViewPrivate;
friend class QGraphicsScenePrivate;
+#ifndef QT_NO_GESTURES
friend class QGestureManager;
+#endif
};
class Q_CORE_EXPORT QTimerEvent : public QEvent
diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp
index fd36be4..9c1c827 100644
--- a/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ b/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -246,6 +246,7 @@ struct GPostEventSource
GSource source;
QAtomicInt serialNumber;
int lastSerialNumber;
+ QEventDispatcherGlibPrivate *d;
};
static gboolean postEventSourcePrepare(GSource *s, gint *timeout)
@@ -274,6 +275,7 @@ static gboolean postEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
source->lastSerialNumber = source->serialNumber;
QCoreApplication::sendPostedEvents();
+ source->d->runTimersOnceWithNormalPriority();
return true; // i dunno, george...
}
@@ -313,6 +315,7 @@ QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context)
postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs,
sizeof(GPostEventSource)));
postEventSource->serialNumber = 1;
+ postEventSource->d = this;
g_source_set_can_recurse(&postEventSource->source, true);
g_source_attach(&postEventSource->source, mainContext);
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 826caf2..e86efb2 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -711,6 +711,7 @@ const int baseDelay = 1000; // minimum delay time used when backing off to allow
QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent)
: QAbstractEventDispatcher(parent),
+ m_selectThread(0),
m_activeScheduler(0),
m_wakeUpAO(0),
m_completeDeferredAOs(0),
@@ -742,11 +743,19 @@ void QEventDispatcherSymbian::startingUp()
wakeUp();
}
+QSelectThread& QEventDispatcherSymbian::selectThread() {
+ if (!m_selectThread)
+ m_selectThread = new QSelectThread;
+ return *m_selectThread;
+}
+
void QEventDispatcherSymbian::closingDown()
{
- if (m_selectThread.isRunning()) {
- m_selectThread.stop();
+ if (m_selectThread && m_selectThread->isRunning()) {
+ m_selectThread->stop();
}
+ delete m_selectThread;
+ m_selectThread = 0;
delete m_completeDeferredAOs;
delete m_wakeUpAO;
@@ -1002,12 +1011,13 @@ void QEventDispatcherSymbian::registerSocketNotifier ( QSocketNotifier * notifie
{
QSocketActiveObject *socketAO = q_check_ptr(new QSocketActiveObject(this, notifier));
m_notifiers.insert(notifier, socketAO);
- m_selectThread.requestSocketEvents(notifier, &socketAO->iStatus);
+ selectThread().requestSocketEvents(notifier, &socketAO->iStatus);
}
void QEventDispatcherSymbian::unregisterSocketNotifier ( QSocketNotifier * notifier )
{
- m_selectThread.cancelSocketEvents(notifier);
+ if (m_selectThread)
+ m_selectThread->cancelSocketEvents(notifier);
if (m_notifiers.contains(notifier)) {
QSocketActiveObject *sockObj = *m_notifiers.find(notifier);
m_deferredSocketEvents.removeAll(sockObj);
@@ -1018,7 +1028,7 @@ void QEventDispatcherSymbian::unregisterSocketNotifier ( QSocketNotifier * notif
void QEventDispatcherSymbian::reactivateSocketNotifier(QSocketNotifier *notifier)
{
- m_selectThread.requestSocketEvents(notifier, &m_notifiers[notifier]->iStatus);
+ selectThread().requestSocketEvents(notifier, &m_notifiers[notifier]->iStatus);
}
void QEventDispatcherSymbian::registerTimer ( int timerId, int interval, QObject * object )
@@ -1101,3 +1111,5 @@ void CQtActiveScheduler::Error(TInt aError) const
}
QT_END_NAMESPACE
+
+#include "moc_qeventdispatcher_symbian_p.cpp"
diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h
index 8a9c9a0..bc42753 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian_p.h
+++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h
@@ -221,6 +221,7 @@ public: // from CActiveScheduler
class Q_CORE_EXPORT QEventDispatcherSymbian : public QAbstractEventDispatcher
{
+ Q_OBJECT
Q_DECLARE_PRIVATE(QAbstractEventDispatcher)
public:
@@ -260,8 +261,9 @@ private:
bool sendPostedEvents();
bool sendDeferredSocketEvents();
+ QSelectThread& selectThread();
private:
- QSelectThread m_selectThread;
+ QSelectThread *m_selectThread;
CQtActiveScheduler *m_activeScheduler;
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index a141887..f7d45ac 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -45,6 +45,7 @@
#include "qpair.h"
#include "qsocketnotifier.h"
#include "qthread.h"
+#include "qelapsedtimer.h"
#include "qeventdispatcher_unix_p.h"
#include <private/qthread_p.h>
@@ -311,12 +312,10 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
QTimerInfoList::QTimerInfoList()
{
- currentTime = qt_gettime();
-
#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)
- if (!qt_gettime_is_monotonic()) {
+ if (!QElapsedTimer::isMonotonic()) {
// not using monotonic timers, initialize the timeChanged() machinery
- previousTime = currentTime;
+ previousTime = qt_gettime();
tms unused;
previousTicks = times(&unused);
@@ -393,7 +392,7 @@ bool QTimerInfoList::timeChanged(timeval *delta)
void QTimerInfoList::repairTimersIfNeeded()
{
- if (qt_gettime_is_monotonic())
+ if (QElapsedTimer::isMonotonic())
return;
timeval delta;
if (timeChanged(&delta))
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 8010a76..e3f537f 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -71,10 +71,12 @@ extern uint qGlobalPostedEventsCount();
#ifndef WM_TOUCH
# define WM_TOUCH 0x0240
#endif
+#ifndef QT_NO_GESTURES
#ifndef WM_GESTURE
# define WM_GESTURE 0x0119
# define WM_GESTURENOTIFY 0x011A
#endif
+#endif // QT_NO_GESTURES
enum {
WM_QT_SOCKETNOTIFIER = WM_USER,
@@ -308,7 +310,7 @@ typedef MMRESULT(WINAPI *ptimeKillEvent)(UINT);
static ptimeSetEvent qtimeSetEvent = 0;
static ptimeKillEvent qtimeKillEvent = 0;
-LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
+LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
static void resolveTimerAPI()
{
@@ -349,6 +351,9 @@ public:
// for controlling when to send posted events
QAtomicInt serialNumber;
int lastSerialNumber;
+#ifndef Q_OS_WINCE
+ int lastMessageTime;
+#endif
QAtomicInt wakeUps;
// timers
@@ -372,7 +377,12 @@ public:
};
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
- : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0), getMessageHook(0), serialNumber(0), lastSerialNumber(0), wakeUps(0)
+ : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0), getMessageHook(0),
+ serialNumber(0), lastSerialNumber(0),
+#ifndef Q_OS_WINCE
+ lastMessageTime(0),
+#endif
+ wakeUps(0)
{
resolveTimerAPI();
}
@@ -412,7 +422,7 @@ Q_CORE_EXPORT bool winGetMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin,
}
// This function is called by a workerthread
-void WINAPI CALLBACK qt_fast_timer_proc(uint timerId, uint /*reserved*/, DWORD_PTR user, DWORD_PTR /*reserved*/, DWORD_PTR /*reserved*/)
+void WINAPI QT_WIN_CALLBACK qt_fast_timer_proc(uint timerId, uint /*reserved*/, DWORD_PTR user, DWORD_PTR /*reserved*/, DWORD_PTR /*reserved*/)
{
if (!timerId) // sanity check
return;
@@ -421,7 +431,7 @@ void WINAPI CALLBACK qt_fast_timer_proc(uint timerId, uint /*reserved*/, DWORD_P
QCoreApplication::postEvent(t->dispatcher, new QTimerEvent(t->timerId));
}
-LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
+LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
{
if (message == WM_NCCREATE)
return true;
@@ -487,6 +497,9 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
int localSerialNumber = d->serialNumber;
if (localSerialNumber != d->lastSerialNumber) {
d->lastSerialNumber = localSerialNumber;
+#ifndef Q_OS_WINCE
+ d->lastMessageTime = GetMessageTime();
+#endif
QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
}
return 0;
@@ -495,7 +508,7 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
return DefWindowProc(hwnd, message, wp, lp);
}
-LRESULT CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
+LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
{
if (wp == PM_REMOVE) {
QEventDispatcherWin32 *q = qobject_cast<QEventDispatcherWin32 *>(QAbstractEventDispatcher::instance());
@@ -503,9 +516,17 @@ LRESULT CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
if (q) {
QEventDispatcherWin32Private *d = q->d_func();
int localSerialNumber = d->serialNumber;
- if (HIWORD(GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER)) == 0) {
- // no more input or timer events in the message queue, we can allow posted events to be
- // sent now
+#ifdef Q_OS_WINCE
+ MSG dummyMsg;
+ if (HIWORD(GetQueueStatus(QS_INPUT)) == 0
+ && PeekMessage(&dummyMsg, 0, WM_TIMER, WM_TIMER, PM_NOREMOVE) == 0
+#else
+ if (HIWORD(GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER)) == 0
+ || GetMessageTime() - d->lastMessageTime >= 10
+#endif
+ ) {
+ // no more input or timer events in the message queue or more than 10ms has elapsed since
+ // we send posted events, we can allow posted events to be sent now
(void) d->wakeUps.fetchAndStoreRelease(0);
MSG *msg = (MSG *) lp;
if (localSerialNumber != d->lastSerialNumber
@@ -580,7 +601,7 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t)
} else {
ok = t->fastTimerId = qtimeSetEvent(t->interval, 1, qt_fast_timer_proc, (DWORD_PTR)t,
TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
- if (ok == 0) { // fall back to normal timer if no more multimedia timers avaiable
+ if (ok == 0) { // fall back to normal timer if no more multimedia timers available
ok = SetTimer(internalHwnd, t->timerId, (uint) t->interval, 0);
}
}
@@ -723,8 +744,10 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
|| msg.message == WM_MOUSEWHEEL
|| msg.message == WM_MOUSEHWHEEL
|| msg.message == WM_TOUCH
+#ifndef QT_NO_GESTURES
|| msg.message == WM_GESTURE
|| msg.message == WM_GESTURENOTIFY
+#endif
|| msg.message == WM_CLOSE)) {
// queue user input events for later processing
haveMessage = false;
@@ -755,6 +778,8 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) {
if (seenWM_QT_SENDPOSTEDEVENTS) {
+ // when calling processEvents() "manually", we only want to send posted
+ // events once
needWM_QT_SENDPOSTEDEVENTS = true;
continue;
}
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index ed94c49..788cc44 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -62,7 +62,7 @@ class QWinEventNotifier;
class QEventDispatcherWin32Private;
// forward declaration
-LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
+LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher
{
@@ -101,8 +101,8 @@ public:
bool event(QEvent *e);
private:
- friend LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
- friend LRESULT CALLBACK qt_GetMessageHook(int, WPARAM, LPARAM);
+ friend LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
+ friend LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int, WPARAM, LPARAM);
};
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp
index 628afa7..c19f718 100644
--- a/src/corelib/kernel/qeventloop.cpp
+++ b/src/corelib/kernel/qeventloop.cpp
@@ -43,7 +43,7 @@
#include "qabstracteventdispatcher.h"
#include "qcoreapplication.h"
-#include "qdatetime.h"
+#include "qelapsedtimer.h"
#include "qobject_p.h"
#include <private/qthread_p.h>
@@ -247,7 +247,7 @@ void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
if (!d->threadData->eventDispatcher)
return;
- QTime start;
+ QElapsedTimer start;
start.start();
if (flags & DeferredDeletion)
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
diff --git a/src/corelib/kernel/qguard_p.h b/src/corelib/kernel/qguard_p.h
deleted file mode 100644
index 0f7fd94..0000000
--- a/src/corelib/kernel/qguard_p.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** 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 QGUARD_P_H
-#define QGUARD_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
-// file may change from version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtCore/qglobal.h"
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-template<class T>
-class QGuard
-{
- QObject *o;
- QGuard<QObject> *next;
- QGuard<QObject> **prev;
- friend void q_guard_addGuard(QGuard<QObject> *);
- friend void q_guard_removeGuard(QGuard<QObject> *);
- friend class QObjectPrivate;
-public:
- inline QGuard();
- inline QGuard(T *);
- inline QGuard(const QGuard<T> &);
- inline virtual ~QGuard();
-
- inline QGuard<T> &operator=(const QGuard<T> &o);
- inline QGuard<T> &operator=(T *);
-
- inline bool isNull() const
- { return !o; }
-
- inline T* operator->() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
- inline T& operator*() const
- { return *static_cast<T*>(const_cast<QObject*>(o)); }
- inline operator T*() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
- inline T* data() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
-
-protected:
- virtual void objectDestroyed(T *) {}
-};
-
-QT_END_NAMESPACE
-
-#include "private/qobject_p.h"
-
-QT_BEGIN_NAMESPACE
-
-inline void q_guard_addGuard(QGuard<QObject> *);
-inline void q_guard_removeGuard(QGuard<QObject> *);
-
-template<class T>
-QGuard<T>::QGuard()
-: o(0), next(0), prev(0)
-{
-}
-
-template<class T>
-QGuard<T>::QGuard(T *g)
-: o(g), next(0), prev(0)
-{
- if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this));
-}
-
-template<class T>
-QGuard<T>::QGuard(const QGuard<T> &g)
-: o(g.o), next(0), prev(0)
-{
- if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this));
-}
-
-template<class T>
-QGuard<T>::~QGuard()
-{
- if (prev) q_guard_removeGuard(reinterpret_cast<QGuard<QObject> *>(this));
- o = 0;
-}
-
-template<class T>
-QGuard<T> &QGuard<T>::operator=(const QGuard<T> &g)
-{
- if (g.o != o) {
- if (prev)
- q_guard_removeGuard(reinterpret_cast<QGuard<QObject> *>(this));
- o = g.o;
- if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this));
- }
- return *this;
-}
-
-template<class T>
-inline QGuard<T> &QGuard<T>::operator=(T *g)
-{
- if (g != o) {
- if (prev)
- q_guard_removeGuard(reinterpret_cast<QGuard<QObject> *>(this));
- o = g;
- if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this));
- }
- return *this;
-}
-
-QT_END_NAMESPACE
-
-#endif // QGUARD_P_H
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index b151040..79a38cd 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -482,6 +482,45 @@ int QMetaObject::classInfoCount() const
return n;
}
+/** \internal
+* helper function for indexOf{Method,Slot,Signal}, returns the relative index of the method within
+* the baseObject
+* \a MethodType might be MethodSignal or MethodSlot, or 0 to match everything.
+* \a normalizeStringData set to true if we should do a second pass for old moc generated files normalizing all the symbols.
+*/
+template<int MethodType>
+static inline int indexOfMethodRelative(const QMetaObject **baseObject,
+ const char *method,
+ bool normalizeStringData)
+{
+ for (const QMetaObject *m = *baseObject; m; m = m->d.superdata) {
+ int i = (MethodType == MethodSignal && priv(m->d.data)->revision >= 4)
+ ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1);
+ const int end = (MethodType == MethodSlot && priv(m->d.data)->revision >= 4)
+ ? (priv(m->d.data)->signalCount) : 0;
+ if (!normalizeStringData) {
+ for (; i >= end; --i) {
+ const char *stringdata = m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5*i];
+ if (method[0] == stringdata[0] && strcmp(method + 1, stringdata + 1) == 0) {
+ *baseObject = m;
+ return i;
+ }
+ }
+ } else if (priv(m->d.data)->revision < 5) {
+ for (; i >= end; --i) {
+ const char *stringdata = (m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5 * i]);
+ const QByteArray normalizedSignature = QMetaObject::normalizedSignature(stringdata);
+ if (normalizedSignature == method) {
+ *baseObject = m;
+ return i;
+ }
+ }
+ }
+ }
+ return -1;
+}
+
+
/*!
\since 4.5
@@ -497,8 +536,8 @@ int QMetaObject::indexOfConstructor(const char *constructor) const
if (priv(d.data)->revision < 2)
return -1;
for (int i = priv(d.data)->constructorCount-1; i >= 0; --i) {
- if (strcmp(constructor, d.stringdata
- + d.data[priv(d.data)->constructorData + 5*i]) == 0) {
+ const char *data = d.stringdata + d.data[priv(d.data)->constructorData + 5*i];
+ if (data[0] == constructor[0] && strcmp(constructor + 1, data + 1) == 0) {
return i;
}
}
@@ -515,17 +554,14 @@ int QMetaObject::indexOfConstructor(const char *constructor) const
*/
int QMetaObject::indexOfMethod(const char *method) const
{
- int i = -1;
const QMetaObject *m = this;
- while (m && i < 0) {
- for (i = priv(m->d.data)->methodCount-1; i >= 0; --i)
- if (strcmp(method, m->d.stringdata
- + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) {
- i += m->methodOffset();
- break;
- }
- m = m->d.superdata;
+ int i = indexOfMethodRelative<0>(&m, method, false);
+ if (i < 0) {
+ m = this;
+ i = indexOfMethodRelative<0>(&m, method, true);
}
+ if (i >= 0)
+ i += m->methodOffset();
return i;
}
@@ -543,7 +579,11 @@ int QMetaObject::indexOfMethod(const char *method) const
int QMetaObject::indexOfSignal(const char *signal) const
{
const QMetaObject *m = this;
- int i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal);
+ int i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal, false);
+ if (i < 0) {
+ m = this;
+ i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal, true);
+ }
if (i >= 0)
i += m->methodOffset();
return i;
@@ -554,21 +594,11 @@ int QMetaObject::indexOfSignal(const char *signal) const
\a baseObject will be adjusted to the enclosing QMetaObject, or 0 if the signal is not found
*/
-int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, const char *signal)
+int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject,
+ const char *signal,
+ bool normalizeStringData)
{
- int i = -1;
- while (*baseObject) {
- const QMetaObject *const m = *baseObject;
- for (i = priv(m->d.data)->methodCount-1; i >= 0; --i)
- if ((m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodSignal
- && strcmp(signal, m->d.stringdata
- + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) {
- break;
- }
- if (i >= 0)
- break;
- *baseObject = m->d.superdata;
- }
+ int i = indexOfMethodRelative<MethodSignal>(baseObject, signal, normalizeStringData);
#ifndef QT_NO_DEBUG
const QMetaObject *m = *baseObject;
if (i >= 0 && m && m->d.superdata) {
@@ -581,7 +611,6 @@ int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, co
return i;
}
-
/*!
Finds \a slot and returns its index; otherwise returns -1.
@@ -592,18 +621,19 @@ int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, co
*/
int QMetaObject::indexOfSlot(const char *slot) const
{
- int i = -1;
- const QMetaObject *m = this;
- while (m && i < 0) {
- for (i = priv(m->d.data)->methodCount-1; i >= 0; --i)
- if ((m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodSlot
- && strcmp(slot, m->d.stringdata
- + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) {
- i += m->methodOffset();
- break;
- }
- m = m->d.superdata;
- }
+ int i = QMetaObjectPrivate::indexOfSlot(this, slot, false);
+ if (i < 0)
+ i = QMetaObjectPrivate::indexOfSlot(this, slot, true);
+ return i;
+}
+
+int QMetaObjectPrivate::indexOfSlot(const QMetaObject *m,
+ const char *slot,
+ bool normalizeStringData)
+{
+ int i = indexOfMethodRelative<MethodSlot>(&m, slot, normalizeStringData);
+ if (i >= 0)
+ i += m->methodOffset();
return i;
}
@@ -651,18 +681,19 @@ static const QMetaObject *QMetaObject_findMetaObject(const QMetaObject *self, co
*/
int QMetaObject::indexOfEnumerator(const char *name) const
{
- int i = -1;
const QMetaObject *m = this;
- while (m && i < 0) {
- for (i = priv(m->d.data)->enumeratorCount-1; i >= 0; --i)
- if (strcmp(name, m->d.stringdata
- + m->d.data[priv(m->d.data)->enumeratorData + 4*i]) == 0) {
+ while (m) {
+ const QMetaObjectPrivate *d = priv(m->d.data);
+ for (int i = d->enumeratorCount - 1; i >= 0; --i) {
+ const char *prop = m->d.stringdata + m->d.data[d->enumeratorData + 4*i];
+ if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
i += m->enumeratorOffset();
- break;
+ return i;
}
+ }
m = m->d.superdata;
}
- return i;
+ return -1;
}
/*!
@@ -673,26 +704,27 @@ int QMetaObject::indexOfEnumerator(const char *name) const
*/
int QMetaObject::indexOfProperty(const char *name) const
{
- int i = -1;
const QMetaObject *m = this;
- while (m && i < 0) {
- for (i = priv(m->d.data)->propertyCount-1; i >= 0; --i)
- if (strcmp(name, m->d.stringdata
- + m->d.data[priv(m->d.data)->propertyData + 3*i]) == 0) {
+ while (m) {
+ const QMetaObjectPrivate *d = priv(m->d.data);
+ for (int i = d->propertyCount-1; i >= 0; --i) {
+ const char *prop = m->d.stringdata + m->d.data[d->propertyData + 3*i];
+ if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
i += m->propertyOffset();
- break;
+ return i;
}
+ }
m = m->d.superdata;
}
- if (i == -1 && priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)){
+ if (priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)) {
QAbstractDynamicMetaObject *me =
const_cast<QAbstractDynamicMetaObject *>(static_cast<const QAbstractDynamicMetaObject *>(this));
- i = me->createProperty(name, 0);
+ return me->createProperty(name, 0);
}
- return i;
+ return -1;
}
/*!
@@ -1106,8 +1138,11 @@ bool QMetaObject::invokeMethod(QObject *obj,
idx = obj->metaObject()->indexOfMethod(norm.constData());
}
- if (idx < 0 || idx >= obj->metaObject()->methodCount())
+ if (idx < 0 || idx >= obj->metaObject()->methodCount()) {
+ qWarning("QMetaObject::invokeMethod: No such method %s::%s",
+ obj->metaObject()->className(), sig.constData());
return false;
+ }
QMetaMethod method = obj->metaObject()->method(idx);
return method.invoke(obj, type, ret,
val0, val1, val2, val3, val4, val5, val6, val7, val8, val9);
@@ -1419,6 +1454,11 @@ QMetaMethod::MethodType QMetaMethod::methodType() const
If the "compute" slot does not take exactly one QString, one int
and one double in the specified order, the call will fail.
+ \warning this method will not test the validity of the arguments: \a object
+ must be an instance of the class of the QMetaObject of which this QMetaMethod
+ has been constructed with. The arguments must have the same type as the ones
+ expected by the method, else, the behaviour is undefined.
+
\sa Q_ARG(), Q_RETURN_ARG(), qRegisterMetaType(), QMetaObject::invokeMethod()
*/
bool QMetaMethod::invoke(QObject *object,
@@ -1438,6 +1478,8 @@ bool QMetaMethod::invoke(QObject *object,
if (!object || !mobj)
return false;
+ Q_ASSERT(mobj->cast(object));
+
// check return type
if (returnValue.data()) {
const char *retType = typeName();
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 3bbb050..b538787 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -115,11 +115,17 @@ struct QMetaObjectPrivate
int constructorCount, constructorData; //since revision 2
int flags; //since revision 3
int signalCount; //since revision 4
+ // revision 5 introduces changes in normalized signatures, no new members
static inline const QMetaObjectPrivate *get(const QMetaObject *metaobject)
{ return reinterpret_cast<const QMetaObjectPrivate*>(metaobject->d.data); }
- static int indexOfSignalRelative(const QMetaObject **baseObject, const char* name);
+ static int indexOfSignalRelative(const QMetaObject **baseObject,
+ const char* name,
+ bool normalizeStringData);
+ static int indexOfSlot(const QMetaObject *m,
+ const char *slot,
+ bool normalizeStringData);
static int originalClone(const QMetaObject *obj, int local_method_index);
#ifndef QT_NO_QOBJECT
@@ -190,7 +196,7 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc
if (*(e-1) == '&') { // treat const reference as value
t += 6;
--e;
- } else if (is_ident_char(*(e-1))) { // treat const value as value
+ } else if (is_ident_char(*(e-1)) || *(e-1) == '>') { // treat const value as value
t += 6;
}
}
@@ -247,6 +253,7 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc
} while (optional[++i].keyword != 0);
}
+ bool star = false;
while (t != e) {
char c = *t++;
if (fixScope && c == ':' && *t == ':' ) {
@@ -257,6 +264,7 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc
--i;
result.resize(i + 1);
}
+ star = star || c == '*';
result += c;
if (c == '<') {
//template recursion
@@ -277,6 +285,26 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc
}
}
}
+
+ // cv qualifers can appear after the type as well
+ if (!is_ident_char(c) && t != e && (e - t >= 5 && strncmp("const", t, 5) == 0)
+ && (e - t == 5 || !is_ident_char(t[5]))) {
+ t += 5;
+ while (t != e && is_space(*t))
+ ++t;
+ if (adjustConst && t != e && *t == '&') {
+ // treat const ref as value
+ ++t;
+ } else if (adjustConst && !star) {
+ // treat const as value
+ } else if (!star) {
+ // move const to the front (but not if const comes after a *)
+ result.prepend("const ");
+ } else {
+ // keep const after a *
+ result += "const";
+ }
+ }
}
return result;
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index e304290..6ebaaa3 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -48,6 +48,7 @@
#include "qstringlist.h"
#include "qvector.h"
#include "qlocale.h"
+#include "qeasingcurve.h"
#ifdef QT_BOOTSTRAPPED
# ifndef QT_NO_GEOM_VARIANT
@@ -132,6 +133,7 @@ QT_BEGIN_NAMESPACE
\value Float \c float
\value QObjectStar QObject *
\value QWidgetStar QWidget *
+ \value QVariant QVariant
\value QColorGroup QColorGroup
\value QCursor QCursor
@@ -176,6 +178,7 @@ QT_BEGIN_NAMESPACE
\value QVector3D QVector3D
\value QVector4D QVector4D
\value QQuaternion QQuaternion
+ \value QEasingCurve QEasingCurve
\value User Base value for user types
@@ -223,100 +226,105 @@ QT_BEGIN_NAMESPACE
\sa Q_DECLARE_METATYPE(), QVariant::setValue(), QVariant::value(), QVariant::fromValue()
*/
+#define QT_ADD_STATIC_METATYPE(STR, TP) \
+ { STR, sizeof(STR) - 1, TP }
+
/* Note: these MUST be in the order of the enums */
-static const struct { const char * typeName; int type; } types[] = {
+static const struct { const char * typeName; int typeNameLength; int type; } types[] = {
/* All Core types */
- {"void", QMetaType::Void},
- {"bool", QMetaType::Bool},
- {"int", QMetaType::Int},
- {"uint", QMetaType::UInt},
- {"qlonglong", QMetaType::LongLong},
- {"qulonglong", QMetaType::ULongLong},
- {"double", QMetaType::Double},
- {"QChar", QMetaType::QChar},
- {"QVariantMap", QMetaType::QVariantMap},
- {"QVariantList", QMetaType::QVariantList},
- {"QString", QMetaType::QString},
- {"QStringList", QMetaType::QStringList},
- {"QByteArray", QMetaType::QByteArray},
- {"QBitArray", QMetaType::QBitArray},
- {"QDate", QMetaType::QDate},
- {"QTime", QMetaType::QTime},
- {"QDateTime", QMetaType::QDateTime},
- {"QUrl", QMetaType::QUrl},
- {"QLocale", QMetaType::QLocale},
- {"QRect", QMetaType::QRect},
- {"QRectF", QMetaType::QRectF},
- {"QSize", QMetaType::QSize},
- {"QSizeF", QMetaType::QSizeF},
- {"QLine", QMetaType::QLine},
- {"QLineF", QMetaType::QLineF},
- {"QPoint", QMetaType::QPoint},
- {"QPointF", QMetaType::QPointF},
- {"QRegExp", QMetaType::QRegExp},
- {"QVariantHash", QMetaType::QVariantHash},
+ QT_ADD_STATIC_METATYPE("void", QMetaType::Void),
+ QT_ADD_STATIC_METATYPE("bool", QMetaType::Bool),
+ QT_ADD_STATIC_METATYPE("int", QMetaType::Int),
+ QT_ADD_STATIC_METATYPE("uint", QMetaType::UInt),
+ QT_ADD_STATIC_METATYPE("qlonglong", QMetaType::LongLong),
+ QT_ADD_STATIC_METATYPE("qulonglong", QMetaType::ULongLong),
+ QT_ADD_STATIC_METATYPE("double", QMetaType::Double),
+ QT_ADD_STATIC_METATYPE("QChar", QMetaType::QChar),
+ QT_ADD_STATIC_METATYPE("QVariantMap", QMetaType::QVariantMap),
+ QT_ADD_STATIC_METATYPE("QVariantList", QMetaType::QVariantList),
+ QT_ADD_STATIC_METATYPE("QString", QMetaType::QString),
+ QT_ADD_STATIC_METATYPE("QStringList", QMetaType::QStringList),
+ QT_ADD_STATIC_METATYPE("QByteArray", QMetaType::QByteArray),
+ QT_ADD_STATIC_METATYPE("QBitArray", QMetaType::QBitArray),
+ QT_ADD_STATIC_METATYPE("QDate", QMetaType::QDate),
+ QT_ADD_STATIC_METATYPE("QTime", QMetaType::QTime),
+ QT_ADD_STATIC_METATYPE("QDateTime", QMetaType::QDateTime),
+ QT_ADD_STATIC_METATYPE("QUrl", QMetaType::QUrl),
+ QT_ADD_STATIC_METATYPE("QLocale", QMetaType::QLocale),
+ QT_ADD_STATIC_METATYPE("QRect", QMetaType::QRect),
+ QT_ADD_STATIC_METATYPE("QRectF", QMetaType::QRectF),
+ QT_ADD_STATIC_METATYPE("QSize", QMetaType::QSize),
+ QT_ADD_STATIC_METATYPE("QSizeF", QMetaType::QSizeF),
+ QT_ADD_STATIC_METATYPE("QLine", QMetaType::QLine),
+ QT_ADD_STATIC_METATYPE("QLineF", QMetaType::QLineF),
+ QT_ADD_STATIC_METATYPE("QPoint", QMetaType::QPoint),
+ QT_ADD_STATIC_METATYPE("QPointF", QMetaType::QPointF),
+ QT_ADD_STATIC_METATYPE("QRegExp", QMetaType::QRegExp),
+ QT_ADD_STATIC_METATYPE("QVariantHash", QMetaType::QVariantHash),
+ QT_ADD_STATIC_METATYPE("QEasingCurve", QMetaType::QEasingCurve),
/* All GUI types */
- {"QColorGroup", 63},
- {"QFont", QMetaType::QFont},
- {"QPixmap", QMetaType::QPixmap},
- {"QBrush", QMetaType::QBrush},
- {"QColor", QMetaType::QColor},
- {"QPalette", QMetaType::QPalette},
- {"QIcon", QMetaType::QIcon},
- {"QImage", QMetaType::QImage},
- {"QPolygon", QMetaType::QPolygon},
- {"QRegion", QMetaType::QRegion},
- {"QBitmap", QMetaType::QBitmap},
- {"QCursor", QMetaType::QCursor},
- {"QSizePolicy", QMetaType::QSizePolicy},
- {"QKeySequence", QMetaType::QKeySequence},
- {"QPen", QMetaType::QPen},
- {"QTextLength", QMetaType::QTextLength},
- {"QTextFormat", QMetaType::QTextFormat},
- {"QMatrix", QMetaType::QMatrix},
- {"QTransform", QMetaType::QTransform},
- {"QMatrix4x4", QMetaType::QMatrix4x4},
- {"QVector2D", QMetaType::QVector2D},
- {"QVector3D", QMetaType::QVector3D},
- {"QVector4D", QMetaType::QVector4D},
- {"QQuaternion", QMetaType::QQuaternion},
+ QT_ADD_STATIC_METATYPE("QColorGroup", 63),
+ QT_ADD_STATIC_METATYPE("QFont", QMetaType::QFont),
+ QT_ADD_STATIC_METATYPE("QPixmap", QMetaType::QPixmap),
+ QT_ADD_STATIC_METATYPE("QBrush", QMetaType::QBrush),
+ QT_ADD_STATIC_METATYPE("QColor", QMetaType::QColor),
+ QT_ADD_STATIC_METATYPE("QPalette", QMetaType::QPalette),
+ QT_ADD_STATIC_METATYPE("QIcon", QMetaType::QIcon),
+ QT_ADD_STATIC_METATYPE("QImage", QMetaType::QImage),
+ QT_ADD_STATIC_METATYPE("QPolygon", QMetaType::QPolygon),
+ QT_ADD_STATIC_METATYPE("QRegion", QMetaType::QRegion),
+ QT_ADD_STATIC_METATYPE("QBitmap", QMetaType::QBitmap),
+ QT_ADD_STATIC_METATYPE("QCursor", QMetaType::QCursor),
+ QT_ADD_STATIC_METATYPE("QSizePolicy", QMetaType::QSizePolicy),
+ QT_ADD_STATIC_METATYPE("QKeySequence", QMetaType::QKeySequence),
+ QT_ADD_STATIC_METATYPE("QPen", QMetaType::QPen),
+ QT_ADD_STATIC_METATYPE("QTextLength", QMetaType::QTextLength),
+ QT_ADD_STATIC_METATYPE("QTextFormat", QMetaType::QTextFormat),
+ QT_ADD_STATIC_METATYPE("QMatrix", QMetaType::QMatrix),
+ QT_ADD_STATIC_METATYPE("QTransform", QMetaType::QTransform),
+ QT_ADD_STATIC_METATYPE("QMatrix4x4", QMetaType::QMatrix4x4),
+ QT_ADD_STATIC_METATYPE("QVector2D", QMetaType::QVector2D),
+ QT_ADD_STATIC_METATYPE("QVector3D", QMetaType::QVector3D),
+ QT_ADD_STATIC_METATYPE("QVector4D", QMetaType::QVector4D),
+ QT_ADD_STATIC_METATYPE("QQuaternion", QMetaType::QQuaternion),
/* All Metatype builtins */
- {"void*", QMetaType::VoidStar},
- {"long", QMetaType::Long},
- {"short", QMetaType::Short},
- {"char", QMetaType::Char},
- {"ulong", QMetaType::ULong},
- {"ushort", QMetaType::UShort},
- {"uchar", QMetaType::UChar},
- {"float", QMetaType::Float},
- {"QObject*", QMetaType::QObjectStar},
- {"QWidget*", QMetaType::QWidgetStar},
+ QT_ADD_STATIC_METATYPE("void*", QMetaType::VoidStar),
+ QT_ADD_STATIC_METATYPE("long", QMetaType::Long),
+ QT_ADD_STATIC_METATYPE("short", QMetaType::Short),
+ QT_ADD_STATIC_METATYPE("char", QMetaType::Char),
+ QT_ADD_STATIC_METATYPE("ulong", QMetaType::ULong),
+ QT_ADD_STATIC_METATYPE("ushort", QMetaType::UShort),
+ QT_ADD_STATIC_METATYPE("uchar", QMetaType::UChar),
+ QT_ADD_STATIC_METATYPE("float", QMetaType::Float),
+ QT_ADD_STATIC_METATYPE("QObject*", QMetaType::QObjectStar),
+ QT_ADD_STATIC_METATYPE("QWidget*", QMetaType::QWidgetStar),
+ QT_ADD_STATIC_METATYPE("QVariant", QMetaType::QVariant),
/* Type aliases - order doesn't matter */
- {"unsigned long", QMetaType::ULong},
- {"unsigned int", QMetaType::UInt},
- {"unsigned short", QMetaType::UShort},
- {"unsigned char", QMetaType::UChar},
- {"long long", QMetaType::LongLong},
- {"unsigned long long", QMetaType::ULongLong},
- {"qint8", QMetaType::Char},
- {"quint8", QMetaType::UChar},
- {"qint16", QMetaType::Short},
- {"quint16", QMetaType::UShort},
- {"qint32", QMetaType::Int},
- {"quint32", QMetaType::UInt},
- {"qint64", QMetaType::LongLong},
- {"quint64", QMetaType::ULongLong},
- {"QList<QVariant>", QMetaType::QVariantList},
- {"QMap<QString,QVariant>", QMetaType::QVariantMap},
- {"QHash<QString,QVariant>", QMetaType::QVariantHash},
+ QT_ADD_STATIC_METATYPE("unsigned long", QMetaType::ULong),
+ QT_ADD_STATIC_METATYPE("unsigned int", QMetaType::UInt),
+ QT_ADD_STATIC_METATYPE("unsigned short", QMetaType::UShort),
+ QT_ADD_STATIC_METATYPE("unsigned char", QMetaType::UChar),
+ QT_ADD_STATIC_METATYPE("long long", QMetaType::LongLong),
+ QT_ADD_STATIC_METATYPE("unsigned long long", QMetaType::ULongLong),
+ QT_ADD_STATIC_METATYPE("qint8", QMetaType::Char),
+ QT_ADD_STATIC_METATYPE("quint8", QMetaType::UChar),
+ QT_ADD_STATIC_METATYPE("qint16", QMetaType::Short),
+ QT_ADD_STATIC_METATYPE("quint16", QMetaType::UShort),
+ QT_ADD_STATIC_METATYPE("qint32", QMetaType::Int),
+ QT_ADD_STATIC_METATYPE("quint32", QMetaType::UInt),
+ QT_ADD_STATIC_METATYPE("qint64", QMetaType::LongLong),
+ QT_ADD_STATIC_METATYPE("quint64", QMetaType::ULongLong),
+ QT_ADD_STATIC_METATYPE("QList<QVariant>", QMetaType::QVariantList),
+ QT_ADD_STATIC_METATYPE("QMap<QString,QVariant>", QMetaType::QVariantMap),
+ QT_ADD_STATIC_METATYPE("QHash<QString,QVariant>", QMetaType::QVariantHash),
// let QMetaTypeId2 figure out the type at compile time
- {"qreal", QMetaTypeId2<qreal>::MetaType},
+ QT_ADD_STATIC_METATYPE("qreal", QMetaTypeId2<qreal>::MetaType),
- {0, QMetaType::Void}
+ {0, 0, QMetaType::Void}
};
struct QMetaTypeGuiHelper
@@ -346,6 +354,7 @@ public:
QMetaType::SaveOperator saveOp;
QMetaType::LoadOperator loadOp;
#endif
+ int alias;
};
Q_DECLARE_TYPEINFO(QCustomTypeInfo, Q_MOVABLE_TYPE);
@@ -361,7 +370,16 @@ void QMetaType::registerStreamOperators(const char *typeName, SaveOperator saveO
int idx = type(typeName);
if (!idx)
return;
+ registerStreamOperators(idx, saveOp, loadOp);
+}
+/*! \internal
+*/
+void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp,
+ LoadOperator loadOp)
+{
+ if (idx < User)
+ return; //builtin types should not be registered;
QVector<QCustomTypeInfo> *ct = customTypes();
if (!ct)
return;
@@ -400,24 +418,38 @@ const char *QMetaType::typeName(int type)
}
/*! \internal
- Same as QMetaType::type(), but doesn't lock the mutex.
+ Similar to QMetaType::type(), but only looks in the static set of types.
*/
-static int qMetaTypeType_unlocked(const QByteArray &typeName)
+static inline int qMetaTypeStaticType(const char *typeName, int length)
{
int i = 0;
- while (types[i].typeName && strcmp(typeName.constData(), types[i].typeName))
+ while (types[i].typeName && ((length != types[i].typeNameLength)
+ || strcmp(typeName, types[i].typeName))) {
++i;
- if (!types[i].type) {
- const QVector<QCustomTypeInfo> * const ct = customTypes();
- if (!ct)
- return 0;
+ }
+ return types[i].type;
+}
+
+/*! \internal
+ Similar to QMetaType::type(), but only looks in the custom set of
+ types, and doesn't lock the mutex.
+*/
+static int qMetaTypeCustomType_unlocked(const char *typeName, int length)
+{
+ const QVector<QCustomTypeInfo> * const ct = customTypes();
+ if (!ct)
+ return 0;
- for (int v = 0; v < ct->count(); ++v) {
- if (ct->at(v).typeName == typeName)
- return v + QMetaType::User;
+ for (int v = 0; v < ct->count(); ++v) {
+ const QCustomTypeInfo &customInfo = ct->at(v);
+ if ((length == customInfo.typeName.size())
+ && !strcmp(typeName, customInfo.typeName.constData())) {
+ if (customInfo.alias >= 0)
+ return customInfo.alias;
+ return v + QMetaType::User;
}
}
- return types[i].type;
+ return 0;
}
/*! \internal
@@ -439,20 +471,67 @@ int QMetaType::registerType(const char *typeName, Destructor destructor,
NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
#endif
- QWriteLocker locker(customTypesLock());
- int idx = qMetaTypeType_unlocked(normalizedTypeName);
+ int idx = qMetaTypeStaticType(normalizedTypeName.constData(),
+ normalizedTypeName.size());
if (!idx) {
- QCustomTypeInfo inf;
- inf.typeName = normalizedTypeName;
- inf.constr = constructor;
- inf.destr = destructor;
- idx = ct->size() + User;
- ct->append(inf);
+ QWriteLocker locker(customTypesLock());
+ idx = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(),
+ normalizedTypeName.size());
+ if (!idx) {
+ QCustomTypeInfo inf;
+ inf.typeName = normalizedTypeName;
+ inf.constr = constructor;
+ inf.destr = destructor;
+ inf.alias = -1;
+ idx = ct->size() + User;
+ ct->append(inf);
+ }
}
return idx;
}
+/*! \internal
+ \since 4.7
+
+ Registers a user type for marshalling, as an alias of another type (typedef)
+*/
+int QMetaType::registerTypedef(const char* typeName, int aliasId)
+{
+ QVector<QCustomTypeInfo> *ct = customTypes();
+ if (!ct || !typeName)
+ return -1;
+
+#ifdef QT_NO_QOBJECT
+ NS(QByteArray) normalizedTypeName = typeName;
+#else
+ NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
+#endif
+
+ int idx = qMetaTypeStaticType(normalizedTypeName.constData(),
+ normalizedTypeName.size());
+
+ if (idx) {
+ Q_ASSERT(idx == aliasId);
+ return idx;
+ }
+
+ QWriteLocker locker(customTypesLock());
+ idx = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(),
+ normalizedTypeName.size());
+
+ if (idx)
+ return idx;
+
+ QCustomTypeInfo inf;
+ inf.typeName = normalizedTypeName;
+ inf.alias = aliasId;
+ inf.constr = 0;
+ inf.destr = 0;
+ ct->append(inf);
+ return aliasId;
+}
+
/*!
\since 4.4
@@ -478,6 +557,7 @@ void QMetaType::unregisterType(const char *typeName)
inf.typeName.clear();
inf.constr = 0;
inf.destr = 0;
+ inf.alias = -1;
}
}
}
@@ -507,14 +587,26 @@ bool QMetaType::isRegistered(int type)
*/
int QMetaType::type(const char *typeName)
{
-#ifdef QT_NO_QOBJECT
- const NS(QByteArray) normalizedTypeName = typeName;
-#else
- const NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
+ int length = qstrlen(typeName);
+ if (!length)
+ return 0;
+ int type = qMetaTypeStaticType(typeName, length);
+ if (!type) {
+ QReadLocker locker(customTypesLock());
+ type = qMetaTypeCustomType_unlocked(typeName, length);
+#ifndef QT_NO_QOBJECT
+ if (!type) {
+ const NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
+ type = qMetaTypeStaticType(normalizedTypeName.constData(),
+ normalizedTypeName.size());
+ if (!type) {
+ type = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(),
+ normalizedTypeName.size());
+ }
+ }
#endif
-
- QReadLocker locker(customTypesLock());
- return qMetaTypeType_unlocked(normalizedTypeName);
+ }
+ return type;
}
#ifndef QT_NO_DATASTREAM
@@ -596,6 +688,9 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::QVariantList:
stream << *static_cast<const NS(QVariantList)*>(data);
break;
+ case QMetaType::QVariant:
+ stream << *static_cast<const NS(QVariant)*>(data);
+ break;
#endif
case QMetaType::QByteArray:
stream << *static_cast<const NS(QByteArray)*>(data);
@@ -659,6 +754,11 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
stream << *static_cast<const NS(QRegExp)*>(data);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ stream << *static_cast<const NS(QEasingCurve)*>(data);
+ break;
+#endif
#ifdef QT3_SUPPORT
case QMetaType::QColorGroup:
#endif
@@ -793,6 +893,9 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::QVariantList:
stream >> *static_cast< NS(QVariantList)*>(data);
break;
+ case QMetaType::QVariant:
+ stream >> *static_cast< NS(QVariant)*>(data);
+ break;
#endif
case QMetaType::QByteArray:
stream >> *static_cast< NS(QByteArray)*>(data);
@@ -856,6 +959,11 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
stream >> *static_cast< NS(QRegExp)*>(data);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ stream >> *static_cast< NS(QEasingCurve)*>(data);
+ break;
+#endif
#ifdef QT3_SUPPORT
case QMetaType::QColorGroup:
#endif
@@ -955,6 +1063,8 @@ void *QMetaType::construct(int type, const void *copy)
return new NS(QVariantHash)(*static_cast<const NS(QVariantHash)*>(copy));
case QMetaType::QVariantList:
return new NS(QVariantList)(*static_cast<const NS(QVariantList)*>(copy));
+ case QMetaType::QVariant:
+ return new NS(QVariant)(*static_cast<const NS(QVariant)*>(copy));
#endif
case QMetaType::QByteArray:
return new NS(QByteArray)(*static_cast<const NS(QByteArray)*>(copy));
@@ -1000,6 +1110,10 @@ void *QMetaType::construct(int type, const void *copy)
case QMetaType::QRegExp:
return new NS(QRegExp)(*static_cast<const NS(QRegExp)*>(copy));
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ return new NS(QEasingCurve)(*static_cast<const NS(QEasingCurve)*>(copy));
+#endif
case QMetaType::Void:
return 0;
default:
@@ -1046,6 +1160,8 @@ void *QMetaType::construct(int type, const void *copy)
return new NS(QVariantHash);
case QMetaType::QVariantList:
return new NS(QVariantList);
+ case QMetaType::QVariant:
+ return new NS(QVariant);
#endif
case QMetaType::QByteArray:
return new NS(QByteArray);
@@ -1091,6 +1207,10 @@ void *QMetaType::construct(int type, const void *copy)
case QMetaType::QRegExp:
return new NS(QRegExp);
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ return new NS(QEasingCurve);
+#endif
case QMetaType::Void:
return 0;
default:
@@ -1183,6 +1303,9 @@ void QMetaType::destroy(int type, void *data)
case QMetaType::QVariantList:
delete static_cast< NS(QVariantList)* >(data);
break;
+ case QMetaType::QVariant:
+ delete static_cast< NS(QVariant)* >(data);
+ break;
#endif
case QMetaType::QByteArray:
delete static_cast< NS(QByteArray)* >(data);
@@ -1246,6 +1369,11 @@ void QMetaType::destroy(int type, void *data)
delete static_cast< NS(QRegExp)* >(data);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ delete static_cast< NS(QEasingCurve)* >(data);
+ break;
+#endif
case QMetaType::Void:
break;
default: {
@@ -1287,6 +1415,11 @@ void QMetaType::destroy(int type, void *data)
\snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 4
+ This function is usefull to register typedefs so they can be used
+ by QMetaProperty, or in QueuedConnections
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 9
+
\sa qRegisterMetaTypeStreamOperators(), QMetaType::isRegistered(),
Q_DECLARE_METATYPE()
*/
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index c0dd288..2108b92 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -69,7 +69,7 @@ public:
QBitArray = 13, QDate = 14, QTime = 15, QDateTime = 16, QUrl = 17,
QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22,
QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27,
- QVariantHash = 28, LastCoreType = 28 /* QVariantHash */,
+ QVariantHash = 28, QEasingCurve = 29, LastCoreType = QEasingCurve,
FirstGuiType = 63 /* QColorGroup */,
#ifdef QT3_SUPPORT
@@ -81,12 +81,13 @@ public:
QTextLength = 78, QTextFormat = 79, QMatrix = 80, QTransform = 81,
QMatrix4x4 = 82, QVector2D = 83, QVector3D = 84, QVector4D = 85,
QQuaternion = 86,
- LastGuiType = 86 /* QQuaternion */,
+ LastGuiType = QQuaternion,
FirstCoreExtType = 128 /* VoidStar */,
VoidStar = 128, Long = 129, Short = 130, Char = 131, ULong = 132,
UShort = 133, UChar = 134, Float = 135, QObjectStar = 136, QWidgetStar = 137,
- LastCoreExtType = 137 /* QWidgetStar */,
+ QVariant = 138,
+ LastCoreExtType = QVariant,
// This logic must match the one in qglobal.h
#if defined(QT_COORD_TYPE)
@@ -108,9 +109,12 @@ public:
typedef void (*LoadOperator)(QDataStream &, void *);
static void registerStreamOperators(const char *typeName, SaveOperator saveOp,
LoadOperator loadOp);
+ static void registerStreamOperators(int type, SaveOperator saveOp,
+ LoadOperator loadOp);
#endif
static int registerType(const char *typeName, Destructor destructor,
Constructor constructor);
+ static int registerTypedef(const char *typeName, int aliasId);
static int type(const char *typeName);
static const char *typeName(int type);
static bool isRegistered(int type);
@@ -152,13 +156,31 @@ void qMetaTypeLoadHelper(QDataStream &stream, T *t)
}
#endif // QT_NO_DATASTREAM
+template <typename T> struct QMetaTypeId2;
+
+namespace QtPrivate {
+ template <typename T, bool Defined = QMetaTypeId2<T>::Defined>
+ struct QMetaTypeIdHelper {
+ static inline int qt_metatype_id()
+ { return QMetaTypeId2<T>::qt_metatype_id(); }
+ };
+ template <typename T> struct QMetaTypeIdHelper<T, false> {
+ static inline int qt_metatype_id()
+ { return -1; }
+ };
+}
+
template <typename T>
int qRegisterMetaType(const char *typeName
#ifndef qdoc
- , T * /* dummy */ = 0
+ , T * dummy = 0
#endif
)
{
+ const int typedefOf = dummy ? -1 : QtPrivate::QMetaTypeIdHelper<T>::qt_metatype_id();
+ if (typedefOf != -1)
+ return QMetaType::registerTypedef(typeName, typedefOf);
+
typedef void*(*ConstructPtr)(const T*);
ConstructPtr cptr = qMetaTypeConstructHelper<T>;
typedef void(*DeletePtr)(T*);
@@ -224,6 +246,24 @@ inline int qRegisterMetaType(
#endif
}
+#ifndef QT_NO_DATASTREAM
+template <typename T>
+inline int qRegisterMetaTypeStreamOperators()
+{
+ typedef void(*SavePtr)(QDataStream &, const T *);
+ typedef void(*LoadPtr)(QDataStream &, T *);
+ SavePtr sptr = qMetaTypeSaveHelper<T>;
+ LoadPtr lptr = qMetaTypeLoadHelper<T>;
+
+ register int id = qMetaTypeId<T>();
+ QMetaType::registerStreamOperators(id,
+ reinterpret_cast<QMetaType::SaveOperator>(sptr),
+ reinterpret_cast<QMetaType::LoadOperator>(lptr));
+
+ return id;
+}
+#endif
+
#define Q_DECLARE_METATYPE(TYPE) \
QT_BEGIN_NAMESPACE \
template <> \
@@ -234,7 +274,8 @@ inline int qRegisterMetaType(
{ \
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
if (!metatype_id) \
- metatype_id = qRegisterMetaType< TYPE >(#TYPE); \
+ metatype_id = qRegisterMetaType< TYPE >(#TYPE, \
+ reinterpret_cast< TYPE *>(quintptr(-1))); \
return metatype_id; \
} \
}; \
@@ -270,6 +311,7 @@ class QPointF;
#ifndef QT_NO_REGEXP
class QRegExp;
#endif
+class QEasingCurve;
class QWidget;
class QObject;
@@ -299,6 +341,7 @@ class QVector2D;
class QVector3D;
class QVector4D;
class QQuaternion;
+class QVariant;
QT_END_NAMESPACE
@@ -339,6 +382,7 @@ Q_DECLARE_BUILTIN_METATYPE(QPointF, QPointF)
#ifndef QT_NO_REGEXP
Q_DECLARE_BUILTIN_METATYPE(QRegExp, QRegExp)
#endif
+Q_DECLARE_BUILTIN_METATYPE(QEasingCurve, QEasingCurve)
#ifdef QT3_SUPPORT
Q_DECLARE_BUILTIN_METATYPE(QColorGroup, QColorGroup)
@@ -366,6 +410,7 @@ Q_DECLARE_BUILTIN_METATYPE(QVector2D, QVector2D)
Q_DECLARE_BUILTIN_METATYPE(QVector3D, QVector3D)
Q_DECLARE_BUILTIN_METATYPE(QVector4D, QVector4D)
Q_DECLARE_BUILTIN_METATYPE(QQuaternion, QQuaternion)
+Q_DECLARE_BUILTIN_METATYPE(QVariant, QVariant)
QT_END_HEADER
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 689e44c..8330e47 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -101,7 +101,7 @@ static QBasicAtomicInt objectCount = Q_BASIC_ATOMIC_INITIALIZER(0);
/** \internal
* mutex to be locked when accessing the connectionlists or the senders list
*/
-static QMutex *signalSlotLock(const QObject *o)
+static inline QMutex *signalSlotLock(const QObject *o)
{
if (!signalSlotMutexes) {
QMutexPool *mp = new QMutexPool;
@@ -125,14 +125,17 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *)
}
}
+void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0;
+void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0;
+
QObjectData::~QObjectData() {}
-QDeclarativeData::~QDeclarativeData() {}
QObjectPrivate::QObjectPrivate(int version)
: threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0)
{
if (version != QObjectPrivateVersion)
- qFatal("Cannot mix incompatible Qt libraries");
+ qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)",
+ version, QObjectPrivateVersion);
// QObjectData initialization
q_ptr = 0;
@@ -390,27 +393,6 @@ void QObjectPrivate::cleanConnectionLists()
}
}
-QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver,
- Sender *sender)
-{
- Sender *previousSender = receiver->d_func()->currentSender;
- receiver->d_func()->currentSender = sender;
- return previousSender;
-}
-
-void QObjectPrivate::resetCurrentSender(QObject *receiver,
- Sender *currentSender,
- Sender *previousSender)
-{
- // ref is set to zero when this object is deleted during the metacall
- if (currentSender->ref == 1)
- receiver->d_func()->currentSender = previousSender;
- // if we've recursed, we need to tell the caller about the objects deletion
- if (previousSender)
- previousSender->ref = currentSender->ref;
-}
-
-
typedef QMultiHash<QObject *, QObject **> GuardHash;
Q_GLOBAL_STATIC(GuardHash, guardHash)
Q_GLOBAL_STATIC(QMutex, guardHashLock)
@@ -495,15 +477,6 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o)
void QObjectPrivate::clearGuards(QObject *object)
{
QObjectPrivate *priv = QObjectPrivate::get(object);
- QGuard<QObject> *guard = priv->extraData ? priv->extraData->objectGuards : 0;
- while (guard) {
- QGuard<QObject> *g = guard;
- guard = guard->next;
- g->o = 0;
- g->prev = 0;
- g->next = 0;
- g->objectDestroyed(object);
- }
if (!priv->hasGuards)
return;
@@ -569,7 +542,7 @@ int QMetaCallEvent::placeMetaCall(QObject *object)
\reentrant
- QObject is the heart of the \l{Qt object model}. The central
+ QObject is the heart of the Qt \l{Object Model}. The central
feature in this model is a very powerful mechanism for seamless
object communication called \l{signals and slots}. You can
connect a signal to a slot with connect() and destroy the
@@ -578,13 +551,13 @@ int QMetaCallEvent::placeMetaCall(QObject *object)
protected functions connectNotify() and disconnectNotify() make
it possible to track connections.
- QObjects organize themselves in \l {Object Trees and Object
- Ownership} {object trees}. When you create a QObject with another
- object as parent, the object will automatically add itself to the
- parent's children() list. The parent takes ownership of the
- object; i.e., it will automatically delete its children in its
- destructor. You can look for an object by name and optionally type
- using findChild() or findChildren().
+ QObjects organize themselves in \l {Object Trees & Ownership}
+ {object trees}. When you create a QObject with another object as
+ parent, the object will automatically add itself to the parent's
+ children() list. The parent takes ownership of the object; i.e.,
+ it will automatically delete its children in its destructor. You
+ can look for an object by name and optionally type using
+ findChild() or findChildren().
Every object has an objectName() and its class name can be found
via the corresponding metaObject() (see QMetaObject::className()).
@@ -636,7 +609,7 @@ int QMetaCallEvent::placeMetaCall(QObject *object)
Qt classes derived from QObject (direct or indirect) use this
macro to declare their copy constructor and assignment operator to
be private. The reasoning is found in the discussion on
- \l{Identity vs Value} {Identity vs Value} on the \l{Qt Object
+ \l{Identity vs Value} {Identity vs Value} on the Qt \l{Object
Model} page.
The main consequence is that you should use pointers to QObject
@@ -683,7 +656,7 @@ int QMetaCallEvent::placeMetaCall(QObject *object)
\l{Writing Source Code for Translation} document.
\sa QMetaObject, QPointer, QObjectCleanupHandler, Q_DISABLE_COPY()
- \sa {Object Trees and Object Ownership}
+ \sa {Object Trees & Ownership}
*/
/*!
@@ -871,7 +844,7 @@ QObject::~QObject()
// all the signal/slots connections are still in place - if we don't
// quit now, we will crash pretty soon.
qWarning("Detected an unexpected exception in ~QObject while emitting destroyed().");
-#if defined(Q_AUTOTEST_EXPORT) && !defined(QT_NO_EXCEPTIONS)
+#if defined(Q_BUILD_INTERNAL) && !defined(QT_NO_EXCEPTIONS)
struct AutotestException : public std::exception
{
const char *what() const throw() { return "autotest swallow"; }
@@ -884,26 +857,22 @@ QObject::~QObject()
}
if (d->declarativeData)
- d->declarativeData->destroyed(this);
+ QAbstractDeclarativeData::destroyed(d->declarativeData, this);
- {
- QMutex *signalSlotMutex = 0;
- QT_TRY {
- signalSlotMutex = signalSlotLock(this);
- } QT_CATCH(const std::bad_alloc &) {
- // out of memory - swallow to prevent a crash
- }
- QMutexLocker locker(signalSlotMutex);
+ // set ref to zero to indicate that this object has been deleted
+ if (d->currentSender != 0)
+ d->currentSender->ref = 0;
+ d->currentSender = 0;
- // set ref to zero to indicate that this object has been deleted
- if (d->currentSender != 0)
- d->currentSender->ref = 0;
- d->currentSender = 0;
+ if (d->connectionLists || d->senders) {
+ QMutex *signalSlotMutex = signalSlotLock(this);
+ QMutexLocker locker(signalSlotMutex);
// disconnect all receivers
if (d->connectionLists) {
++d->connectionLists->inUse;
- for (int signal = -1; signal < d->connectionLists->count(); ++signal) {
+ int connectionListsCount = d->connectionLists->count();
+ for (int signal = -1; signal < connectionListsCount; ++signal) {
QObjectPrivate::ConnectionList &connectionList =
(*d->connectionLists)[signal];
@@ -915,7 +884,7 @@ QObject::~QObject()
}
QMutex *m = signalSlotLock(c->receiver);
- bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m);
+ bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m);
if (c->receiver) {
*c->prev = c->next;
@@ -940,16 +909,17 @@ QObject::~QObject()
// disconnect all senders
QObjectPrivate::Connection *node = d->senders;
while (node) {
- QMutex *m = signalSlotLock(node->sender);
+ QObject *sender = node->sender;
+ QMutex *m = signalSlotLock(sender);
node->prev = &node;
- bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m);
+ bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m);
//the node has maybe been removed while the mutex was unlocked in relock?
- if (!node || signalSlotLock(node->sender) != m) {
+ if (!node || node->sender != sender) {
m->unlock();
continue;
}
node->receiver = 0;
- QObjectConnectionListVector *senderLists = node->sender->d_func()->connectionLists;
+ QObjectConnectionListVector *senderLists = sender->d_func()->connectionLists;
if (senderLists)
senderLists->dirty = true;
@@ -976,7 +946,8 @@ QObject::~QObject()
qt_removeObject(this);
- QCoreApplication::removePostedEvents(this);
+ if (d->postedEvents)
+ QCoreApplication::removePostedEvents(this, 0);
if (d->parent) // remove it from parent object
d->setParent_helper(0);
@@ -1476,7 +1447,7 @@ void QObject::moveToThread(QThread *targetThread)
} else if (d->threadData != currentData) {
qWarning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n"
"Cannot move to target thread (%p)\n",
- d->threadData->thread, currentData->thread, targetData->thread);
+ currentData->thread, d->threadData->thread, targetData->thread);
#ifdef Q_WS_MAC
qWarning("On Mac OS X, you might be loading two sets of Qt binaries into the same process. "
@@ -2030,6 +2001,8 @@ void QObjectPrivate::setParent_helper(QObject *o)
}
}
}
+ if (!wasDeleted && declarativeData)
+ QAbstractDeclarativeData::parentChanged(declarativeData, q, o);
}
/*!
@@ -2510,20 +2483,25 @@ bool QObject::connect(const QObject *sender, const char *signal,
const QMetaObject *smeta = sender->metaObject();
const char *signal_arg = signal;
++signal; //skip code
- int signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal);
+ int signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal, false);
if (signal_index < 0) {
// check for normalized signatures
tmp_signal_name = QMetaObject::normalizedSignature(signal - 1);
signal = tmp_signal_name.constData() + 1;
smeta = sender->metaObject();
- signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal);
+ signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal, false);
+ }
+ if (signal_index < 0) {
+ // re-use tmp_signal_name and signal from above
- if (signal_index < 0) {
- err_method_notfound(sender, signal_arg, "connect");
- err_info_about_objects("connect", sender, receiver);
- return false;
- }
+ smeta = sender->metaObject();
+ signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal, true);
+ }
+ if (signal_index < 0) {
+ err_method_notfound(sender, signal_arg, "connect");
+ err_info_about_objects("connect", sender, receiver);
+ return false;
}
signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
int signalOffset, methodOffset;
@@ -2543,16 +2521,21 @@ bool QObject::connect(const QObject *sender, const char *signal,
int method_index = -1;
switch (membcode) {
case QSLOT_CODE:
- method_index = rmeta->indexOfSlot(method);
+ method_index = QMetaObjectPrivate::indexOfSlot(rmeta, method, false);
break;
case QSIGNAL_CODE:
- method_index = rmeta->indexOfSignal(method);
+ method_index = QMetaObjectPrivate::indexOfSignalRelative(&rmeta, method, false);
+ if (method_index >= 0)
+ method_index += rmeta->methodOffset();
break;
}
if (method_index < 0) {
// check for normalized methods
tmp_method_name = QMetaObject::normalizedSignature(method);
method = tmp_method_name.constData();
+
+ // rmeta may have been modified above
+ rmeta = receiver->metaObject();
switch (membcode) {
case QSLOT_CODE:
method_index = rmeta->indexOfSlot(method);
@@ -2740,7 +2723,9 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
do {
int signal_index = -1;
if (signal) {
- signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal);
+ signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal, false);
+ if (signal_index < 0)
+ signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal, true);
if (signal_index < 0)
break;
signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
@@ -3221,9 +3206,9 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
argv ? argv : empty_argv);
}
- QMutexLocker locker(signalSlotLock(sender));
QThreadData *currentThreadData = QThreadData::current();
+ QMutexLocker locker(signalSlotLock(sender));
QObjectConnectionListVector *connectionLists = sender->d_func()->connectionLists;
if (!connectionLists) {
locker.unlock();
@@ -3319,7 +3304,7 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
if (connectionLists->orphaned) {
if (!connectionLists->inUse)
delete connectionLists;
- } else {
+ } else if (connectionLists->dirty) {
sender->d_func()->cleanConnectionLists();
}
@@ -3363,7 +3348,9 @@ int QObjectPrivate::signalIndex(const char *signalName) const
{
Q_Q(const QObject);
const QMetaObject *base = q->metaObject();
- int relative_index = QMetaObjectPrivate::indexOfSignalRelative(&base, signalName);
+ int relative_index = QMetaObjectPrivate::indexOfSignalRelative(&base, signalName, false);
+ if (relative_index < 0)
+ relative_index = QMetaObjectPrivate::indexOfSignalRelative(&base, signalName, true);
if (relative_index < 0)
return relative_index;
relative_index = QMetaObjectPrivate::originalClone(base, relative_index);
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 27ab105..4800e6a 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -60,7 +60,6 @@
#include "QtCore/qvector.h"
#include "QtCore/qreadwritelock.h"
#include "QtCore/qvariant.h"
-#include "private/qguard_p.h"
QT_BEGIN_NAMESPACE
@@ -85,11 +84,11 @@ extern QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set;
enum { QObjectPrivateVersion = QT_VERSION };
-class Q_CORE_EXPORT QDeclarativeData
+class Q_CORE_EXPORT QAbstractDeclarativeData
{
public:
- virtual ~QDeclarativeData();
- virtual void destroyed(QObject *) = 0;
+ static void (*destroyed)(QAbstractDeclarativeData *, QObject *);
+ static void (*parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *);
};
class Q_CORE_EXPORT QObjectPrivate : public QObjectData
@@ -99,13 +98,12 @@ class Q_CORE_EXPORT QObjectPrivate : public QObjectData
public:
struct ExtraData
{
- ExtraData() : objectGuards(0) {}
+ ExtraData() {}
#ifndef QT_NO_USERDATA
QVector<QObjectUserData *> userData;
#endif
QList<QByteArray> propertyNames;
QList<QVariant> propertyValues;
- QGuard<QObject> *objectGuards; //linked list handle of QGuards
};
struct Connection
@@ -158,9 +156,9 @@ public:
void removePendingChildInsertedEvents(QObject *child);
#endif
- static Sender *setCurrentSender(QObject *receiver,
+ static inline Sender *setCurrentSender(QObject *receiver,
Sender *sender);
- static void resetCurrentSender(QObject *receiver,
+ static inline void resetCurrentSender(QObject *receiver,
Sender *currentSender,
Sender *previousSender);
static int *setDeleteWatch(QObjectPrivate *d, int *newWatch);
@@ -189,14 +187,14 @@ public:
QList<QObject *> pendingChildInsertedEvents;
#else
// preserve binary compatibility with code compiled without Qt 3 support
- // ### why?
- QList<QObject *> unused;
+ // keeping the binary layout stable helps the Qt Creator debugger
+ void *unused;
#endif
QList<QPointer<QObject> > eventFilters;
union {
QObject *currentChildBeingDeleted;
- QDeclarativeData *declarativeData; //extra data used by the DeclarativeUI project.
+ QAbstractDeclarativeData *declarativeData; //extra data used by the declarative module
};
// these objects are all used to indicate that a QObject was deleted
@@ -217,39 +215,32 @@ public:
inline bool QObjectPrivate::isSignalConnected(uint signal_index) const
{
return signal_index >= sizeof(connectedSignals) * 8
+ || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f))
|| qt_signal_spy_callback_set.signal_begin_callback
- || qt_signal_spy_callback_set.signal_end_callback
- || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f)));
+ || qt_signal_spy_callback_set.signal_end_callback);
}
-
-inline void q_guard_addGuard(QGuard<QObject> *g)
+inline QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver,
+ Sender *sender)
{
- QObjectPrivate *p = QObjectPrivate::get(g->o);
- if (p->wasDeleted) {
- qWarning("QGuard: cannot add guard to deleted object");
- g->o = 0;
- return;
- }
-
- if (!p->extraData)
- p->extraData = new QObjectPrivate::ExtraData;
-
- g->next = p->extraData->objectGuards;
- p->extraData->objectGuards = g;
- g->prev = &p->extraData->objectGuards;
- if (g->next)
- g->next->prev = &g->next;
+ Sender *previousSender = receiver->d_func()->currentSender;
+ receiver->d_func()->currentSender = sender;
+ return previousSender;
}
-inline void q_guard_removeGuard(QGuard<QObject> *g)
+inline void QObjectPrivate::resetCurrentSender(QObject *receiver,
+ Sender *currentSender,
+ Sender *previousSender)
{
- if (g->next) g->next->prev = g->prev;
- *g->prev = g->next;
- g->next = 0;
- g->prev = 0;
+ // ref is set to zero when this object is deleted during the metacall
+ if (currentSender->ref == 1)
+ receiver->d_func()->currentSender = previousSender;
+ // if we've recursed, we need to tell the caller about the objects deletion
+ if (previousSender)
+ previousSender->ref = currentSender->ref;
}
+
Q_DECLARE_TYPEINFO(QObjectPrivate::Connection, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QObjectPrivate::Sender, Q_MOVABLE_TYPE);
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index f496354..555a1f5 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -273,6 +273,14 @@ public:
: QGenericArgument(aName, static_cast<const void *>(&aData))
{}
};
+template <class T>
+class QArgument<T &>: public QGenericArgument
+{
+public:
+ inline QArgument(const char *aName, T &aData)
+ : QGenericArgument(aName, static_cast<const void *>(&aData))
+ {}
+};
template <typename T>
diff --git a/src/corelib/kernel/qsystemsemaphore_symbian.cpp b/src/corelib/kernel/qsystemsemaphore_symbian.cpp
index c252dd5..8cef611 100644
--- a/src/corelib/kernel/qsystemsemaphore_symbian.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_symbian.cpp
@@ -44,7 +44,7 @@
#include "qcoreapplication.h"
#include <qdebug.h>
-#include <qcore_symbian_p.h>
+#include "qcore_symbian_p.h"
#include <e32cmn.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index e17c995..7650f6a 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -339,8 +339,20 @@ QT_END_INCLUDE_NAMESPACE
void QTimer::singleShot(int msec, QObject *receiver, const char *member)
{
- if (receiver && member)
+ if (receiver && member) {
+ if (msec == 0) {
+ // special code shortpath for 0-timers
+ const char* bracketPosition = strchr(member, '(');
+ if (!bracketPosition || !(member[0] >= '0' && member[0] <= '3')) {
+ qWarning("QTimer::singleShot: Invalid slot specification");
+ return;
+ }
+ QByteArray methodName(member+1, bracketPosition - 1 - member); // extract method name
+ QMetaObject::invokeMethod(receiver, methodName.constData(), Qt::QueuedConnection);
+ return;
+ }
(void) new QSingleShotTimer(msec, receiver, member);
+ }
}
/*!
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 7d1e1d3..1321b14 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -56,7 +56,7 @@
#include "qhash.h"
#include "qtranslator_p.h"
-#if defined(Q_OS_UNIX)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
#define QT_USE_MMAP
#include "private/qcore_unix_p.h"
#endif
@@ -412,12 +412,12 @@ bool QTranslator::load(const QString & filename, const QString & directory,
realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix);
fi.setFile(realname);
- if (fi.isReadable())
+ if (fi.isReadable() && fi.isFile())
break;
realname = prefix + fname;
fi.setFile(realname);
- if (fi.isReadable())
+ if (fi.isReadable() && fi.isFile())
break;
int rightmost = 0;
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 9a278bd..f5d7c0d 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -46,6 +46,7 @@
#include "qdebug.h"
#include "qmap.h"
#include "qdatetime.h"
+#include "qeasingcurve.h"
#include "qlist.h"
#include "qstring.h"
#include "qstringlist.h"
@@ -146,6 +147,11 @@ static void construct(QVariant::Private *x, const void *copy)
v_construct<QRegExp>(x, copy);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ v_construct<QEasingCurve>(x, copy);
+ break;
+#endif
case QVariant::Int:
x->data.i = copy ? *static_cast<const int *>(copy) : 0;
break;
@@ -259,6 +265,11 @@ static void clear(QVariant::Private *d)
v_clear<QRegExp>(d);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ v_clear<QEasingCurve>(d);
+ break;
+#endif
case QVariant::LongLong:
case QVariant::ULongLong:
case QVariant::Double:
@@ -317,6 +328,9 @@ static bool isNull(const QVariant::Private *d)
case QVariant::PointF:
return v_cast<QPointF>(d)->isNull();
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+#endif
case QVariant::Url:
case QVariant::Locale:
case QVariant::RegExp:
@@ -435,6 +449,10 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
return *v_cast<QTime>(a) == *v_cast<QTime>(b);
case QVariant::DateTime:
return *v_cast<QDateTime>(a) == *v_cast<QDateTime>(b);
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ return *v_cast<QEasingCurve>(a) == *v_cast<QEasingCurve>(b);
+#endif
case QVariant::ByteArray:
return *v_cast<QByteArray>(a) == *v_cast<QByteArray>(b);
case QVariant::BitArray:
@@ -1101,6 +1119,11 @@ static void streamDebug(QDebug dbg, const QVariant &v)
case QVariant::DateTime:
dbg.nospace() << v.toDateTime();
break;
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ dbg.nospace() << v.toEasingCurve();
+ break;
+#endif
case QVariant::ByteArray:
dbg.nospace() << v.toByteArray();
break;
@@ -1269,6 +1292,7 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
\value Date a QDate
\value DateTime a QDateTime
\value Double a double
+ \value EasingCurve a QEasingCurve
\value Font a QFont
\value Hash a QVariantHash
\value Icon a QIcon
@@ -1487,6 +1511,13 @@ QVariant::QVariant(const char *val)
*/
/*!
+ \since 4.7
+ \fn QVariant::QVariant(const QEasingCurve &val)
+
+ Constructs a new variant with an easing curve value, \a val.
+*/
+
+/*!
\fn QVariant::QVariant(const QByteArray &val)
Constructs a new variant with a bytearray value, \a val.
@@ -1685,6 +1716,10 @@ QVariant::QVariant(const QTime &val)
{ d.is_null = false; d.type = Time; v_construct<QTime>(&d, val); }
QVariant::QVariant(const QDateTime &val)
{ d.is_null = false; d.type = DateTime; v_construct<QDateTime>(&d, val); }
+#ifndef QT_BOOTSTRAPPED
+QVariant::QVariant(const QEasingCurve &val)
+{ d.is_null = false; d.type = EasingCurve; v_construct<QEasingCurve>(&d, val); }
+#endif
QVariant::QVariant(const QList<QVariant> &list)
{ d.is_null = false; d.type = List; v_construct<QVariantList>(&d, list); }
QVariant::QVariant(const QMap<QString, QVariant> &map)
@@ -1874,7 +1909,7 @@ QVariant::Type QVariant::nameToType(const char *name)
}
#ifndef QT_NO_DATASTREAM
-enum { MapFromThreeCount = 35 };
+enum { MapFromThreeCount = 36 };
static const ushort map_from_three[MapFromThreeCount] =
{
QVariant::Invalid,
@@ -1911,7 +1946,8 @@ static const ushort map_from_three[MapFromThreeCount] =
QVariant::KeySequence,
QVariant::Pen,
QVariant::LongLong,
- QVariant::ULongLong
+ QVariant::ULongLong,
+ QVariant::EasingCurve
};
/*!
@@ -2169,6 +2205,22 @@ QDateTime QVariant::toDateTime() const
}
/*!
+ \since 4.7
+ \fn QEasingCurve QVariant::toEasingCurve() const
+
+ Returns the variant as a QEasingCurve if the variant has type() \l
+ EasingCurve; otherwise returns a default easing curve.
+
+ \sa canConvert(), convert()
+*/
+#ifndef QT_BOOTSTRAPPED
+QEasingCurve QVariant::toEasingCurve() const
+{
+ return qVariantToHelper<QEasingCurve>(d, EasingCurve, handler);
+}
+#endif
+
+/*!
\fn QByteArray QVariant::toByteArray() const
Returns the variant as a QByteArray if the variant has type() \l
@@ -2609,8 +2661,9 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
/*QRegExp*/ 0,
-/*QHash*/ 0
+/*QHash*/ 0,
+/*QEasingCurve*/ 0
};
/*!
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 1a9e43a..cb2825c 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -60,6 +60,7 @@ class QBitArray;
class QDataStream;
class QDate;
class QDateTime;
+class QEasingCurve;
class QLine;
class QLineF;
class QLocale;
@@ -128,9 +129,10 @@ class Q_CORE_EXPORT QVariant
LineF = 24,
Point = 25,
PointF = 26,
- RegExp = 27,
+ RegExp = 27,
Hash = 28,
- LastCoreType = Hash,
+ EasingCurve = 29,
+ LastCoreType = EasingCurve,
// value 62 is internally reserved
#ifdef QT3_SUPPORT
@@ -219,6 +221,9 @@ class Q_CORE_EXPORT QVariant
#ifndef QT_NO_REGEXP
QVariant(const QRegExp &regExp);
#endif
+#ifndef QT_BOOTSTRAPPED
+ QVariant(const QEasingCurve &easing);
+#endif
QVariant(Qt::GlobalColor color);
QVariant& operator=(const QVariant &other);
@@ -280,6 +285,9 @@ class Q_CORE_EXPORT QVariant
#ifndef QT_NO_REGEXP
QRegExp toRegExp() const;
#endif
+#ifndef QT_BOOTSTRAPPED
+ QEasingCurve toEasingCurve() const;
+#endif
#ifdef QT3_SUPPORT
inline QT3_SUPPORT int &asInt();
@@ -581,8 +589,7 @@ template<typename T> inline T qvariant_cast(const QVariant &v)
template<> inline QVariant qvariant_cast<QVariant>(const QVariant &v)
{
- static const int vid = qRegisterMetaType<QVariant>("QVariant");
- if (vid == v.userType())
+ if (v.userType() == QMetaType::QVariant)
return *reinterpret_cast<const QVariant *>(v.constData());
return v;
}