summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/kernel.pri2
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h4
-rw-r--r--src/corelib/kernel/qabstractnativeeventfilter.h4
-rw-r--r--src/corelib/kernel/qbasictimer.h4
-rw-r--r--src/corelib/kernel/qcore_mac_p.h12
-rw-r--r--src/corelib/kernel/qcore_unix.cpp21
-rw-r--r--src/corelib/kernel/qcore_unix_p.h54
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp114
-rw-r--r--src/corelib/kernel/qcoreapplication.h25
-rw-r--r--src/corelib/kernel/qcoreevent.h4
-rw-r--r--src/corelib/kernel/qeventdispatcher_blackberry.cpp18
-rw-r--r--src/corelib/kernel/qeventdispatcher_blackberry_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp4
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp51
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix_p.h11
-rw-r--r--src/corelib/kernel/qeventloop.h4
-rw-r--r--src/corelib/kernel/qeventloop_p.h4
-rw-r--r--src/corelib/kernel/qfunctions_nacl.h4
-rw-r--r--src/corelib/kernel/qfunctions_p.h3
-rw-r--r--src/corelib/kernel/qfunctions_vxworks.cpp10
-rw-r--r--src/corelib/kernel/qfunctions_vxworks.h53
-rw-r--r--src/corelib/kernel/qfunctions_wince.h3
-rw-r--r--src/corelib/kernel/qmath.cpp87
-rw-r--r--src/corelib/kernel/qmath.h28
-rw-r--r--src/corelib/kernel/qmetaobject.h4
-rw-r--r--src/corelib/kernel/qmetatype.cpp8
-rw-r--r--src/corelib/kernel/qmetatype.h37
-rw-r--r--src/corelib/kernel/qmetatype_p.h2
-rw-r--r--src/corelib/kernel/qmimedata.h4
-rw-r--r--src/corelib/kernel/qobject.cpp4
-rw-r--r--src/corelib/kernel/qobject.h8
-rw-r--r--src/corelib/kernel/qobject_impl.h7
-rw-r--r--src/corelib/kernel/qobject_p.h77
-rw-r--r--src/corelib/kernel/qobjectcleanuphandler.h4
-rw-r--r--src/corelib/kernel/qobjectdefs.h4
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h7
-rw-r--r--src/corelib/kernel/qpointer.h100
-rw-r--r--src/corelib/kernel/qsharedmemory.h4
-rw-r--r--src/corelib/kernel/qsharedmemory_p.h2
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp3
-rw-r--r--src/corelib/kernel/qsignalmapper.h4
-rw-r--r--src/corelib/kernel/qsocketnotifier.h4
-rw-r--r--src/corelib/kernel/qsystemsemaphore.h4
-rw-r--r--src/corelib/kernel/qtimer.h4
-rw-r--r--src/corelib/kernel/qtimerinfo_unix.cpp84
-rw-r--r--src/corelib/kernel/qtimerinfo_unix_p.h14
-rw-r--r--src/corelib/kernel/qtranslator.h4
-rw-r--r--src/corelib/kernel/qvariant.cpp10
-rw-r--r--src/corelib/kernel/qvariant.h30
-rw-r--r--src/corelib/kernel/qwineventnotifier.h4
50 files changed, 599 insertions, 364 deletions
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 34e32a721d..5a8499d723 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -131,7 +131,7 @@ unix|integrity {
contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
- !linux-android-* {
+ !android {
SOURCES += kernel/qsharedmemory_unix.cpp \
kernel/qsystemsemaphore_unix.cpp
} else {
diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h
index c07c395a84..6f21cefa4e 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.h
+++ b/src/corelib/kernel/qabstracteventdispatcher.h
@@ -45,8 +45,6 @@
#include <QtCore/qobject.h>
#include <QtCore/qeventloop.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QAbstractNativeEventFilter;
@@ -129,6 +127,4 @@ protected:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QABSTRACTEVENTDISPATCHER_H
diff --git a/src/corelib/kernel/qabstractnativeeventfilter.h b/src/corelib/kernel/qabstractnativeeventfilter.h
index 09701a4923..9d1db2c19b 100644
--- a/src/corelib/kernel/qabstractnativeeventfilter.h
+++ b/src/corelib/kernel/qabstractnativeeventfilter.h
@@ -44,8 +44,6 @@
#include <QtCore/qnamespace.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QAbstractNativeEventFilterPrivate;
@@ -65,6 +63,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif /* QABSTRACTNATIVEEVENTFILTER_H */
diff --git a/src/corelib/kernel/qbasictimer.h b/src/corelib/kernel/qbasictimer.h
index 4fdb00d633..432e4d58c8 100644
--- a/src/corelib/kernel/qbasictimer.h
+++ b/src/corelib/kernel/qbasictimer.h
@@ -45,8 +45,6 @@
#include <QtCore/qglobal.h>
#include <QtCore/qnamespace.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -70,6 +68,4 @@ Q_DECLARE_TYPEINFO(QBasicTimer, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QBASICTIMER_H
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index cbbbc18814..35688f7463 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -63,6 +63,8 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
+#include "qglobal.h"
+
#ifndef Q_OS_IOS
#include <CoreServices/CoreServices.h>
#endif
@@ -137,14 +139,4 @@ private:
QT_END_NAMESPACE
-#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
-#ifndef __LP64__
- typedef float CGFloat;
- typedef int NSInteger;
- typedef unsigned int NSUInteger;
- #define SRefCon SInt32
- #define URefCon UInt32
-#endif
-#endif
-
#endif // QCORE_MAC_P_H
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp
index cc5479876d..241658acb1 100644
--- a/src/corelib/kernel/qcore_unix.cpp
+++ b/src/corelib/kernel/qcore_unix.cpp
@@ -60,8 +60,8 @@
QT_BEGIN_NAMESPACE
-static inline bool time_update(struct timeval *tv, const struct timeval &start,
- const struct timeval &timeout)
+static inline bool time_update(struct timespec *tv, const struct timespec &start,
+ const struct timespec &timeout)
{
if (!QElapsedTimer::isMonotonic()) {
// we cannot recalculate the timeout without a monotonic clock as the time may have changed
@@ -69,13 +69,13 @@ static inline bool time_update(struct timeval *tv, const struct timeval &start,
}
// clock source is monotonic, so we can recalculate how much timeout is left
- struct timeval now = qt_gettime();
+ struct timespec now = qt_gettime();
*tv = timeout + start - now;
return tv->tv_sec >= 0;
}
int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
- const struct timeval *orig_timeout)
+ const struct timespec *orig_timeout)
{
if (!orig_timeout) {
// no timeout -> block forever
@@ -84,13 +84,20 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
return ret;
}
- timeval start = qt_gettime();
- timeval timeout = *orig_timeout;
+ timespec start = qt_gettime();
+ timespec timeout = *orig_timeout;
// loop and recalculate the timeout as needed
int ret;
forever {
- ret = ::select(nfds, fdread, fdwrite, fdexcept, &timeout);
+#ifndef Q_OS_QNX
+ ret = ::pselect(nfds, fdread, fdwrite, fdexcept, &timeout, 0);
+#else
+ timeval timeoutVal;
+ timeoutVal.tv_sec = timeout.tv_sec;
+ timeoutVal.tv_usec = timeout.tv_nsec / 1000;
+ ret = ::select(nfds, fdread, fdwrite, fdexcept, &timeoutVal);
+#endif
if (ret != -1 || errno != EINTR)
return ret;
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index 6342b0362a..b68146cd6c 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -100,49 +100,49 @@ using namespace QT_PREPEND_NAMESPACE(QtLibcSupplement);
QT_BEGIN_NAMESPACE
-// Internal operator functions for timevals
-inline timeval &normalizedTimeval(timeval &t)
+// Internal operator functions for timespecs
+inline timespec &normalizedTimespec(timespec &t)
{
- while (t.tv_usec >= 1000000) {
+ while (t.tv_nsec >= 1000000000) {
++t.tv_sec;
- t.tv_usec -= 1000000;
+ t.tv_nsec -= 1000000000;
}
- while (t.tv_usec < 0) {
+ while (t.tv_nsec < 0) {
--t.tv_sec;
- t.tv_usec += 1000000;
+ t.tv_nsec += 1000000000;
}
return t;
}
-inline bool operator<(const timeval &t1, const timeval &t2)
-{ return t1.tv_sec < t2.tv_sec || (t1.tv_sec == t2.tv_sec && t1.tv_usec < t2.tv_usec); }
-inline bool operator==(const timeval &t1, const timeval &t2)
-{ return t1.tv_sec == t2.tv_sec && t1.tv_usec == t2.tv_usec; }
-inline timeval &operator+=(timeval &t1, const timeval &t2)
+inline bool operator<(const timespec &t1, const timespec &t2)
+{ return t1.tv_sec < t2.tv_sec || (t1.tv_sec == t2.tv_sec && t1.tv_nsec < t2.tv_nsec); }
+inline bool operator==(const timespec &t1, const timespec &t2)
+{ return t1.tv_sec == t2.tv_sec && t1.tv_nsec == t2.tv_nsec; }
+inline timespec &operator+=(timespec &t1, const timespec &t2)
{
t1.tv_sec += t2.tv_sec;
- t1.tv_usec += t2.tv_usec;
- return normalizedTimeval(t1);
+ t1.tv_nsec += t2.tv_nsec;
+ return normalizedTimespec(t1);
}
-inline timeval operator+(const timeval &t1, const timeval &t2)
+inline timespec operator+(const timespec &t1, const timespec &t2)
{
- timeval tmp;
+ timespec tmp;
tmp.tv_sec = t1.tv_sec + t2.tv_sec;
- tmp.tv_usec = t1.tv_usec + t2.tv_usec;
- return normalizedTimeval(tmp);
+ tmp.tv_nsec = t1.tv_nsec + t2.tv_nsec;
+ return normalizedTimespec(tmp);
}
-inline timeval operator-(const timeval &t1, const timeval &t2)
+inline timespec operator-(const timespec &t1, const timespec &t2)
{
- timeval tmp;
+ timespec tmp;
tmp.tv_sec = t1.tv_sec - (t2.tv_sec - 1);
- tmp.tv_usec = t1.tv_usec - (t2.tv_usec + 1000000);
- return normalizedTimeval(tmp);
+ tmp.tv_nsec = t1.tv_nsec - (t2.tv_nsec + 1000000000);
+ return normalizedTimespec(tmp);
}
-inline timeval operator*(const timeval &t1, int mul)
+inline timespec operator*(const timespec &t1, int mul)
{
- timeval tmp;
+ timespec tmp;
tmp.tv_sec = t1.tv_sec * mul;
- tmp.tv_usec = t1.tv_usec * mul;
- return normalizedTimeval(tmp);
+ tmp.tv_nsec = t1.tv_nsec * mul;
+ return normalizedTimespec(tmp);
}
inline void qt_ignore_sigpipe()
@@ -335,11 +335,11 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options)
#endif
// in qelapsedtimer_mac.cpp or qtimestamp_unix.cpp
-timeval qt_gettime() Q_DECL_NOTHROW;
+timespec qt_gettime() Q_DECL_NOTHROW;
void qt_nanosleep(timespec amount);
Q_CORE_EXPORT int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
- const struct timeval *tv);
+ const struct timespec *tv);
// according to X/OPEN we have to define semun ourselves
// we use prefix as on some systems sem.h will have it
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index ec808424f9..46de52ec9f 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -194,8 +194,32 @@ extern "C" void Q_CORE_EXPORT qt_startup_hook()
{
}
+typedef QList<QtStartUpFunction> QStartUpFuncList;
+Q_GLOBAL_STATIC(QStartUpFuncList, preRList)
typedef QList<QtCleanUpFunction> QVFuncList;
Q_GLOBAL_STATIC(QVFuncList, postRList)
+static QBasicMutex globalPreRoutinesMutex;
+
+/*!
+ \internal
+
+ Adds a global routine that will be called from the QCoreApplication
+ constructor. The public API is Q_COREAPP_STARTUP_FUNCTION.
+*/
+void qAddPreRoutine(QtStartUpFunction p)
+{
+ QStartUpFuncList *list = preRList();
+ if (!list)
+ return;
+ // Due to C++11 parallel dynamic initialization, this can be called
+ // from multiple threads.
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(&globalPreRoutinesMutex);
+#endif
+ if (QCoreApplication::instance())
+ p();
+ list->prepend(p); // in case QCoreApplication is re-created, see qt_call_pre_routines
+}
void qAddPostRoutine(QtCleanUpFunction p)
{
@@ -213,6 +237,21 @@ void qRemovePostRoutine(QtCleanUpFunction p)
list->removeAll(p);
}
+static void qt_call_pre_routines()
+{
+ QStartUpFuncList *list = preRList();
+ if (!list)
+ return;
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(&globalPreRoutinesMutex);
+#endif
+ // Unlike qt_call_post_routines, we don't empty the list, because
+ // Q_COREAPP_STARTUP_FUNCTION is a macro, so the user expects
+ // the function to be executed every time QCoreApplication is created.
+ for (int i = 0; i < list->count(); ++i)
+ list->at(i)();
+}
+
void Q_CORE_EXPORT qt_call_post_routines()
{
QVFuncList *list = 0;
@@ -261,13 +300,6 @@ struct QCoreApplicationData {
#ifndef QT_NO_LIBRARY
delete app_libpaths;
#endif
-
- // cleanup the QAdoptedThread created for the main() thread
- if (QCoreApplicationPrivate::theMainThread) {
- QThreadData *data = QThreadData::get2(QCoreApplicationPrivate::theMainThread);
- QCoreApplicationPrivate::theMainThread = 0;
- data->deref(); // deletes the data and the adopted thread
- }
}
#ifdef Q_OS_BLACKBERRY
@@ -637,6 +669,7 @@ void QCoreApplication::init()
d->processCommandLineArguments();
+ qt_call_pre_routines();
qt_startup_hook();
}
@@ -1999,9 +2032,21 @@ QStringList QCoreApplication::arguments()
\sa organizationDomain, applicationName
*/
+/*!
+ \fn void QCoreApplication::organizationNameChanged()
+ \internal
+
+ While not useful from C++ due to how organizationName is normally set once on
+ startup, this is still needed for QML so that bindings are reevaluated after
+ that initial change.
+*/
void QCoreApplication::setOrganizationName(const QString &orgName)
{
+ if (coreappdata()->orgName == orgName)
+ return;
coreappdata()->orgName = orgName;
+ if (QCoreApplication::self)
+ emit QCoreApplication::self->organizationNameChanged();
}
QString QCoreApplication::organizationName()
@@ -2027,9 +2072,19 @@ QString QCoreApplication::organizationName()
\sa organizationName, applicationName, applicationVersion
*/
+/*!
+ \fn void QCoreApplication::organizationDomainChanged()
+ \internal
+
+ Primarily for QML, see organizationNameChanged.
+*/
void QCoreApplication::setOrganizationDomain(const QString &orgDomain)
{
+ if (coreappdata()->orgDomain == orgDomain)
+ return;
coreappdata()->orgDomain = orgDomain;
+ if (QCoreApplication::self)
+ emit QCoreApplication::self->organizationDomainChanged();
}
QString QCoreApplication::organizationDomain()
@@ -2049,9 +2104,19 @@ QString QCoreApplication::organizationDomain()
\sa organizationName, organizationDomain, applicationVersion, applicationFilePath
*/
+/*!
+ \fn void QCoreApplication::applicationNameChanged()
+ \internal
+
+ Primarily for QML, see organizationNameChanged.
+*/
void QCoreApplication::setApplicationName(const QString &application)
{
+ if (coreappdata()->application == application)
+ return;
coreappdata()->application = application;
+ if (QCoreApplication::self)
+ emit QCoreApplication::self->applicationNameChanged();
}
QString QCoreApplication::applicationName()
@@ -2078,9 +2143,19 @@ Q_CORE_EXPORT QString qt_applicationName_noFallback()
\sa applicationName, organizationName, organizationDomain
*/
+/*!
+ \fn void QCoreApplication::applicationVersionChanged()
+ \internal
+
+ Primarily for QML, see organizationNameChanged.
+*/
void QCoreApplication::setApplicationVersion(const QString &version)
{
+ if (coreappdata()->applicationVersion == version)
+ return;
coreappdata()->applicationVersion = version;
+ if (QCoreApplication::self)
+ emit QCoreApplication::self->applicationVersionChanged();
}
QString QCoreApplication::applicationVersion()
@@ -2325,6 +2400,31 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
}
/*!
+ \macro Q_COREAPP_STARTUP_FUNCTION(QtStartUpFunction ptr)
+ \since 5.1
+ \relates QCoreApplication
+ \reentrant
+
+ Adds a global function that will be called from the QCoreApplication
+ constructor. This macro is normally used to initialize libraries
+ for program-wide functionality, without requiring the application to
+ call into the library for initialization.
+
+ The function specified by \a ptr should take no arguments and should
+ return nothing. For example:
+
+ \snippet code/src_corelib_kernel_qcoreapplication.cpp 3
+
+ Note that the startup function will run at the end of the QCoreApplication constructor,
+ before any GUI initialization. If GUI code is required in the function,
+ use a timer (or a queued invocation) to perform the initialization later on,
+ from the event loop.
+
+ If QCoreApplication is deleted and another QCoreApplication is created,
+ the startup function will be invoked again.
+*/
+
+/*!
\fn void qAddPostRoutine(QtCleanUpFunction ptr)
\relates QCoreApplication
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 0a87689ff3..022ef8c0bc 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -50,8 +50,6 @@
typedef struct tagMSG MSG;
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -68,10 +66,10 @@ class QAbstractNativeEventFilter;
class Q_CORE_EXPORT QCoreApplication : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName)
- Q_PROPERTY(QString applicationVersion READ applicationVersion WRITE setApplicationVersion)
- Q_PROPERTY(QString organizationName READ organizationName WRITE setOrganizationName)
- Q_PROPERTY(QString organizationDomain READ organizationDomain WRITE setOrganizationDomain)
+ Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName NOTIFY applicationNameChanged)
+ Q_PROPERTY(QString applicationVersion READ applicationVersion WRITE setApplicationVersion NOTIFY applicationVersionChanged)
+ Q_PROPERTY(QString organizationName READ organizationName WRITE setOrganizationName NOTIFY organizationNameChanged)
+ Q_PROPERTY(QString organizationDomain READ organizationDomain WRITE setOrganizationDomain NOTIFY organizationDomainChanged)
Q_PROPERTY(bool quitLockEnabled READ isQuitLockEnabled WRITE setQuitLockEnabled)
Q_DECLARE_PRIVATE(QCoreApplication)
@@ -166,6 +164,11 @@ Q_SIGNALS:
#endif
);
+ void organizationNameChanged();
+ void organizationDomainChanged();
+ void applicationNameChanged();
+ void applicationVersionChanged();
+
protected:
bool event(QEvent *);
@@ -220,12 +223,20 @@ public: \
{ return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \
private:
+typedef void (*QtStartUpFunction)();
typedef void (*QtCleanUpFunction)();
+Q_CORE_EXPORT void qAddPreRoutine(QtStartUpFunction);
Q_CORE_EXPORT void qAddPostRoutine(QtCleanUpFunction);
Q_CORE_EXPORT void qRemovePostRoutine(QtCleanUpFunction);
Q_CORE_EXPORT QString qAppName(); // get application name
+#define Q_COREAPP_STARTUP_FUNCTION(AFUNC) \
+ static void AFUNC ## _ctor_function() { \
+ qAddPreRoutine(AFUNC); \
+ } \
+ Q_CONSTRUCTOR_FUNCTION(AFUNC ## _ctor_function)
+
#if defined(Q_OS_WIN) && !defined(QT_NO_DEBUG_STREAM)
Q_CORE_EXPORT QString decodeMSG(const MSG &);
Q_CORE_EXPORT QDebug operator<<(QDebug, const MSG &);
@@ -233,6 +244,4 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const MSG &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QCOREAPPLICATION_H
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index d35b5198a9..47a461d330 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -46,8 +46,6 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qobjectdefs.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -377,6 +375,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QCOREEVENT_H
diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp
index 3e958ee277..5206334c09 100644
--- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp
+++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp
@@ -271,13 +271,13 @@ void QEventDispatcherBlackberry::unregisterSocketNotifier(QSocketNotifier *notif
}
}
-static inline int timevalToMillisecs(const timeval &tv)
+static inline int timespecToMillisecs(const timespec &tv)
{
- return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
+ return (tv.tv_sec * 1000) + (tv.tv_nsec / 1000000);
}
int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- timeval *timeout)
+ timespec *timeout)
{
Q_UNUSED(nfds);
Q_D(QEventDispatcherBlackberry);
@@ -306,9 +306,9 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef
// Convert timeout to milliseconds
int timeoutTotal = -1;
if (timeout)
- timeoutTotal = timevalToMillisecs(*timeout);
+ timeoutTotal = timespecToMillisecs(*timeout);
int timeoutLeft = timeoutTotal;
- timeval startTime = qt_gettime();
+ timespec startTime = qt_gettime();
// This loop exists such that we can drain the bps event queue of all native events
// more efficiently than if we were to return control to Qt after each event. This
@@ -332,16 +332,16 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef
// Update the timeout
// Clock source is monotonic, so we can recalculate how much timeout is left
if (timeoutTotal != -1) {
- timeval t2 = qt_gettime();
+ timespec t2 = qt_gettime();
timeoutLeft = timeoutTotal
- - (timevalToMillisecs(t2) - timevalToMillisecs(startTime));
+ - (timespecToMillisecs(t2) - timespecToMillisecs(startTime));
if (timeoutLeft < 0)
timeoutLeft = 0;
}
- timeval tnext;
+ timespec tnext;
if (d->timerList.timerWait(tnext)) {
- int timeoutNext = timevalToMillisecs(tnext);
+ int timeoutNext = timespecToMillisecs(tnext);
if (timeoutNext < timeoutLeft || timeoutTotal == -1) {
timeoutTotal = timeoutLeft = timeoutNext;
startTime = qt_gettime();
diff --git a/src/corelib/kernel/qeventdispatcher_blackberry_p.h b/src/corelib/kernel/qeventdispatcher_blackberry_p.h
index 79ed21dbf2..5a4c3a9dcd 100644
--- a/src/corelib/kernel/qeventdispatcher_blackberry_p.h
+++ b/src/corelib/kernel/qeventdispatcher_blackberry_p.h
@@ -77,7 +77,7 @@ protected:
QEventDispatcherBlackberry(QEventDispatcherBlackberryPrivate &dd, QObject *parent = 0);
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- timeval *timeout);
+ timespec *timeout);
int ioEvents(int fd);
};
diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp
index c6680d6a80..75cd88c456 100644
--- a/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ b/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -131,9 +131,9 @@ struct GTimerSource
static gboolean timerSourcePrepareHelper(GTimerSource *src, gint *timeout)
{
- timeval tv = { 0l, 0l };
+ timespec tv = { 0l, 0l };
if (!(src->processEventsFlags & QEventLoop::X11ExcludeTimers) && src->timerList.timerWait(tv))
- *timeout = (tv.tv_sec * 1000) + ((tv.tv_usec + 999) / 1000);
+ *timeout = (tv.tv_sec * 1000) + ((tv.tv_nsec + 999999) / 1000 / 1000);
else
*timeout = -1;
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index acdc7635e8..c79fe89105 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -56,6 +56,10 @@
#include <stdio.h>
#include <stdlib.h>
+#ifndef QT_NO_EVENTFD
+# include <sys/eventfd.h>
+#endif
+
// VxWorks doesn't correctly set the _POSIX_... options
#if defined(Q_OS_VXWORKS)
# if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK <= 0)
@@ -109,7 +113,7 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate()
}
#elif defined(Q_OS_VXWORKS)
char name[20];
- qsnprintf(name, sizeof(name), "/pipe/qt_%08x", int(taskIdCurrent));
+ qsnprintf(name, sizeof(name), "/pipe/qt_%08x", int(taskIdSelf()));
// make sure there is no pipe with this name
pipeDevDelete(name, true);
@@ -127,6 +131,12 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate()
}
}
#else
+# ifndef QT_NO_EVENTFD
+ thread_pipe[0] = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+ if (thread_pipe[0] != -1)
+ thread_pipe[1] = -1;
+ else // fall through the next "if"
+# endif
if (qt_safe_pipe(thread_pipe, O_NONBLOCK) == -1) {
perror("QEventDispatcherUNIXPrivate(): Unable to create thread pipe");
pipefail = true;
@@ -149,20 +159,21 @@ QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate()
close(thread_pipe[0]);
char name[20];
- qsnprintf(name, sizeof(name), "/pipe/qt_%08x", int(taskIdCurrent));
+ qsnprintf(name, sizeof(name), "/pipe/qt_%08x", int(taskIdSelf()));
pipeDevDelete(name, true);
#else
// cleanup the common parts of the event loop
close(thread_pipe[0]);
- close(thread_pipe[1]);
+ if (thread_pipe[1] != -1)
+ close(thread_pipe[1]);
#endif
// cleanup timers
qDeleteAll(timerList);
}
-int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, timeval *timeout)
+int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, timespec *timeout)
{
Q_Q(QEventDispatcherUNIX);
@@ -279,9 +290,18 @@ int QEventDispatcherUNIXPrivate::processThreadWakeUp(int nsel)
::read(thread_pipe[0], c, sizeof(c));
::ioctl(thread_pipe[0], FIOFLUSH, 0);
#else
- char c[16];
- while (::read(thread_pipe[0], c, sizeof(c)) > 0)
- ;
+# ifndef QT_NO_EVENTFD
+ if (thread_pipe[1] == -1) {
+ // eventfd
+ eventfd_t value;
+ eventfd_read(thread_pipe[0], &value);
+ } else
+# endif
+ {
+ char c[16];
+ while (::read(thread_pipe[0], c, sizeof(c)) > 0) {
+ }
+ }
#endif
if (!wakeUps.testAndSetRelease(1, 0)) {
// hopefully, this is dead code
@@ -307,7 +327,7 @@ QEventDispatcherUNIX::~QEventDispatcherUNIX()
}
int QEventDispatcherUNIX::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- timeval *timeout)
+ timespec *timeout)
{
return qt_safe_select(nfds, readfds, writefds, exceptfds, timeout);
}
@@ -580,8 +600,8 @@ bool QEventDispatcherUNIX::processEvents(QEventLoop::ProcessEventsFlags flags)
if (!d->interrupt) {
// return the maximum time we can wait for an event.
- timeval *tm = 0;
- timeval wait_tm = { 0l, 0l };
+ timespec *tm = 0;
+ timespec wait_tm = { 0l, 0l };
if (!(flags & QEventLoop::X11ExcludeTimers)) {
if (d->timerList.timerWait(wait_tm))
tm = &wait_tm;
@@ -593,7 +613,7 @@ bool QEventDispatcherUNIX::processEvents(QEventLoop::ProcessEventsFlags flags)
// no time to wait
tm->tv_sec = 0l;
- tm->tv_usec = 0l;
+ tm->tv_nsec = 0l;
}
nevents = d->doSelect(flags, tm);
@@ -630,6 +650,15 @@ void QEventDispatcherUNIX::wakeUp()
{
Q_D(QEventDispatcherUNIX);
if (d->wakeUps.testAndSetAcquire(0, 1)) {
+#ifndef QT_NO_EVENTFD
+ if (d->thread_pipe[1] == -1) {
+ // eventfd
+ eventfd_t value = 1;
+ int ret;
+ EINTR_LOOP(ret, eventfd_write(d->thread_pipe[0], value));
+ return;
+ }
+#endif
char c = 0;
qt_safe_write( d->thread_pipe[1], &c, 1 );
}
diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h
index afebe2fb7e..db89b7c444 100644
--- a/src/corelib/kernel/qeventdispatcher_unix_p.h
+++ b/src/corelib/kernel/qeventdispatcher_unix_p.h
@@ -61,9 +61,7 @@
#include "QtCore/qvarlengtharray.h"
#include "private/qtimerinfo_unix_p.h"
-#if defined(Q_OS_VXWORKS)
-# include <sys/times.h>
-#else
+#if !defined(Q_OS_VXWORKS)
# include <sys/time.h>
# if (!defined(Q_OS_HPUX) || defined(__ia64)) && !defined(Q_OS_NACL)
# include <sys/select.h>
@@ -132,7 +130,7 @@ protected:
virtual int select(int nfds,
fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- timeval *timeout);
+ timespec *timeout);
};
class Q_CORE_EXPORT QEventDispatcherUNIXPrivate : public QAbstractEventDispatcherPrivate
@@ -143,11 +141,14 @@ public:
QEventDispatcherUNIXPrivate();
~QEventDispatcherUNIXPrivate();
- int doSelect(QEventLoop::ProcessEventsFlags flags, timeval *timeout);
+ int doSelect(QEventLoop::ProcessEventsFlags flags, timespec *timeout);
virtual int initThreadWakeUp();
virtual int processThreadWakeUp(int nsel);
bool mainThread;
+
+ // note for eventfd(7) support:
+ // if thread_pipe[1] is -1, then eventfd(7) is in use and is stored in thread_pipe[0]
int thread_pipe[2];
// highest fd for all socket notifiers
diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h
index d4141a05bc..926be08265 100644
--- a/src/corelib/kernel/qeventloop.h
+++ b/src/corelib/kernel/qeventloop.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -106,6 +104,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QEVENTLOOP_H
diff --git a/src/corelib/kernel/qeventloop_p.h b/src/corelib/kernel/qeventloop_p.h
index 21a1dcda4c..8e2bfdb55e 100644
--- a/src/corelib/kernel/qeventloop_p.h
+++ b/src/corelib/kernel/qeventloop_p.h
@@ -44,8 +44,6 @@
#include "qobject_p.h"
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QEventLoopPrivate : public QObjectPrivate
@@ -76,6 +74,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QEVENTLOOP_P_H
diff --git a/src/corelib/kernel/qfunctions_nacl.h b/src/corelib/kernel/qfunctions_nacl.h
index 2cb9d16c95..bc44a21cb8 100644
--- a/src/corelib/kernel/qfunctions_nacl.h
+++ b/src/corelib/kernel/qfunctions_nacl.h
@@ -52,8 +52,6 @@
#define PTHREAD_CANCEL_ENABLE 2
#define PTHREAD_INHERIT_SCHED 3
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -89,8 +87,6 @@ int select(int nfds, fd_set * readfds, fd_set * writefds, fd_set * errorfds, str
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif //Q_OS_NACL
#endif //QFUNCTIONS_NACL_H
diff --git a/src/corelib/kernel/qfunctions_p.h b/src/corelib/kernel/qfunctions_p.h
index 57c6a8f295..6e094f1ed3 100644
--- a/src/corelib/kernel/qfunctions_p.h
+++ b/src/corelib/kernel/qfunctions_p.h
@@ -72,8 +72,5 @@
# define Q_STATIC_GLOBAL_INLINE_OPERATOR static inline
#endif
-QT_BEGIN_HEADER
-QT_END_HEADER
-
#endif
diff --git a/src/corelib/kernel/qfunctions_vxworks.cpp b/src/corelib/kernel/qfunctions_vxworks.cpp
index 2174588757..e1abecb9d6 100644
--- a/src/corelib/kernel/qfunctions_vxworks.cpp
+++ b/src/corelib/kernel/qfunctions_vxworks.cpp
@@ -46,7 +46,9 @@
#include "qplatformdefs.h"
#include "qfunctions_vxworks.h"
+#if defined(_WRS_KERNEL)
#include <vmLib.h>
+#endif
#include <selectLib.h>
#include <ioLib.h>
@@ -74,10 +76,12 @@ void *lfind(const void* key, const void* base, size_t* elements, size_t size,
// no rand_r(), but rand()
// NOTE: this implementation is wrong for multi threaded applications,
// but there is no way to get it right on VxWorks (in kernel mode)
+#if defined(_WRS_KERNEL)
int rand_r(unsigned int * /*seedp*/)
{
return rand();
}
+#endif
// no usleep() support
int usleep(unsigned int usec)
@@ -92,7 +96,7 @@ int usleep(unsigned int usec)
// gettimeofday() is declared, but is missing from the library
// It IS however defined in the Curtis-Wright X11 libraries, so
// we have to make the symbol 'weak'
-#if defined(Q_CC_DIAB)
+#if defined(Q_CC_DIAB) && !defined(VXWORKS_DKM) && !defined(VXWORKS_RTP)
# pragma weak gettimeofday
#endif
int gettimeofday(struct timeval *tv, void /*struct timezone*/ *)
@@ -118,7 +122,11 @@ int gettimeofday(struct timeval *tv, void /*struct timezone*/ *)
// neither getpagesize() or sysconf(_SC_PAGESIZE) are available
int getpagesize()
{
+#if defined(_WRS_KERNEL)
return vmPageSizeGet();
+#else
+ return sysconf(_SC_PAGESIZE);
+#endif
}
// symlinks are not supported (lstat is now just a call to stat - see qplatformdefs.h)
diff --git a/src/corelib/kernel/qfunctions_vxworks.h b/src/corelib/kernel/qfunctions_vxworks.h
index 6339903cff..02c599f490 100644
--- a/src/corelib/kernel/qfunctions_vxworks.h
+++ b/src/corelib/kernel/qfunctions_vxworks.h
@@ -52,7 +52,11 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/ioctl.h>
+#if defined(_WRS_KERNEL)
#include <sys/times.h>
+#else
+#include <sys/time.h>
+#endif
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -61,15 +65,50 @@
#include <net/if.h>
#endif
-QT_BEGIN_HEADER
+// VxWorks has public header mbuf.h which defines following variables for DKM.
+// Let's undef those to because they overlap with Qt variable names-
+// File mbuf.h is included in headers <netinet/in.h> <net/if.h>, so make sure
+// that those are included before undef's.
+#if defined(mbuf)
+# undef mbuf
+#endif
+#if defined(m_data)
+# undef m_data
+#endif
+#if defined(m_type)
+# undef m_type
+#endif
+#if defined(m_next)
+# undef m_next
+#endif
+#if defined(m_len)
+# undef m_len
+#endif
+#if defined(m_flags)
+# undef m_flags
+#endif
+#if defined(m_hdr)
+# undef m_hdr
+#endif
+#if defined(m_ext)
+# undef m_ext
+#endif
+#if defined(m_act)
+# undef m_act
+#endif
+#if defined(m_nextpkt)
+# undef m_nextpkt
+#endif
+#if defined(m_pkthdr)
+# undef m_pkthdr
+#endif
+
QT_BEGIN_NAMESPACE
#ifdef QT_BUILD_CORE_LIB
#endif
QT_END_NAMESPACE
-QT_END_HEADER
-
#ifndef RTLD_LOCAL
#define RTLD_LOCAL 0
@@ -95,17 +134,23 @@ void *lfind(const void* key, const void* base, size_t* elements, size_t size,
// no rand_r(), but rand()
// NOTE: this implementation is wrong for multi threaded applications,
// but there is no way to get it right on VxWorks (in kernel mode)
+#if defined(_WRS_KERNEL)
int rand_r(unsigned int * /*seedp*/);
+#endif
// no usleep() support
int usleep(unsigned int);
+#if defined(VXWORKS_DKM) || defined(VXWORKS_RTP)
+int gettimeofday(struct timeval *, void *);
+#else
// gettimeofday() is declared, but is missing from the library.
// It IS however defined in the Curtis-Wright X11 libraries, so
// we have to make the symbol 'weak'
int gettimeofday(struct timeval *tv, void /*struct timezone*/ *) __attribute__((weak));
+#endif
-// neither getpagesize() or sysconf(_SC_PAGESIZE) are available
+// getpagesize() not available
int getpagesize();
// symlinks are not supported (lstat is now just a call to stat - see qplatformdefs.h)
diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h
index e20a4ceaca..4eeb9cff6a 100644
--- a/src/corelib/kernel/qfunctions_wince.h
+++ b/src/corelib/kernel/qfunctions_wince.h
@@ -56,15 +56,12 @@
#include <winsock.h>
#include <ceconfig.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#ifdef QT_BUILD_CORE_LIB
#endif
QT_END_NAMESPACE
-QT_END_HEADER
-
// The standard SDK misses this define...
#define _control87 _controlfp
diff --git a/src/corelib/kernel/qmath.cpp b/src/corelib/kernel/qmath.cpp
index 1d6fcc2cd6..8f900e2101 100644
--- a/src/corelib/kernel/qmath.cpp
+++ b/src/corelib/kernel/qmath.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -302,4 +303,90 @@ const qreal qt_sine_table[QT_SINE_TABLE_SIZE] = {
qreal(-0.024541228522912448)
};
+/*!
+ \headerfile <QtMath>
+ \title Generic Math Declarations
+ \ingroup funclists
+
+ \brief The <QtMath> header file includes generic math declarations.
+
+ The global declarations include \l{functions}.
+
+ These functions are partly convenience definitions for basic
+ operations, for instance not available in the Standard Template Library et
+ al.
+*/
+
+/*!
+ \fn float qDegreesToRadians(float degrees)
+ \relates <QtMath>
+ \since 5.1
+
+ \brief The function converts the \a degrees in float to radians.
+
+ The purpose of the function is to aid the conversion as such a convenient
+ function is not part of the Standard Template Library, i.e. in <cmath> or
+ elsewhere.
+
+ Example:
+
+ \snippet code/src_corelib_kernel_qmath.cpp 0
+
+ \sa qRadiansToDegrees()
+*/
+
+/*!
+ \fn double qDegreesToRadians(double degrees)
+ \relates <QtMath>
+ \since 5.1
+
+ \brief The function converts the \a degrees in double to radians.
+
+ The purpose of the function is to aid the conversion as such a convenient
+ function is not part of the Standard Template Library, i.e. in <cmath> or
+ elsewhere.
+
+ Example:
+
+ \snippet code/src_corelib_kernel_qmath.cpp 1
+
+ \sa qRadiansToDegrees()
+*/
+
+/*!
+ \fn float qRadiansToDegrees(float radians)
+ \relates <QtMath>
+ \since 5.1
+
+ \brief The function converts the \a radians in float to degrees.
+
+ The purpose of the function is to aid the conversion as such a convenient
+ function is not part of the Standard Template Library, i.e. in <cmath> or
+ elsewhere.
+
+ Example:
+
+ \snippet code/src_corelib_kernel_qmath.cpp 2
+
+ \sa qDegreesToRadians()
+*/
+
+/*!
+ \fn double qRadiansToDegrees(double radians)
+ \relates <QtMath>
+ \since 5.1
+
+ \brief The function converts the \a radians in double to degrees.
+
+ The purpose of the function is to aid the conversion as such a convenient
+ function is not part of the Standard Template Library, i.e. in <cmath> or
+ elsewhere.
+
+ Example:
+
+ \snippet code/src_corelib_kernel_qmath.cpp 3
+
+ \sa qDegreesToRadians()
+*/
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index 097200d690..21e23b9eb0 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -42,12 +42,14 @@
#ifndef QMATH_H
#define QMATH_H
+#if 0
+#pragma qt_class(QtMath)
+#endif
+
#include <math.h>
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -264,8 +266,26 @@ inline qreal qFastCos(qreal x)
return qt_sine_table[si] - (qt_sine_table[ci] + 0.5 * qt_sine_table[si] * d) * d;
}
-QT_END_NAMESPACE
+Q_DECL_CONSTEXPR inline float qDegreesToRadians(float degrees)
+{
+ return degrees * float(M_PI/180);
+}
+
+Q_DECL_CONSTEXPR inline double qDegreesToRadians(double degrees)
+{
+ return degrees * (M_PI / 180);
+}
+
+Q_DECL_CONSTEXPR inline float qRadiansToDegrees(float radians)
+{
+ return radians * float(180/M_PI);
+}
-QT_END_HEADER
+Q_DECL_CONSTEXPR inline double qRadiansToDegrees(double radians)
+{
+ return radians * (180 / M_PI);
+}
+
+QT_END_NAMESPACE
#endif // QMATH_H
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 6d6b849d75..23fc89ffe3 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -45,8 +45,6 @@
#include <QtCore/qobjectdefs.h>
#include <QtCore/qvariant.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -274,6 +272,4 @@ Q_DECLARE_TYPEINFO(QMetaClassInfo, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QMETAOBJECT_H
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index abf220ebd4..b9f7462b12 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -959,11 +959,11 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
break;
#endif
#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGEXP
+#ifndef QT_NO_REGULAREXPRESSION
case QMetaType::QRegularExpression:
stream << *static_cast<const NS(QRegularExpression)*>(data);
break;
-#endif // QT_NO_REGEXP
+#endif // QT_NO_REGULAREXPRESSION
case QMetaType::QEasingCurve:
stream << *static_cast<const NS(QEasingCurve)*>(data);
break;
@@ -1182,11 +1182,11 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
break;
#endif
#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGEXP
+#ifndef QT_NO_REGULAREXPRESSION
case QMetaType::QRegularExpression:
stream >> *static_cast< NS(QRegularExpression)*>(data);
break;
-#endif // QT_NO_REGEXP
+#endif // QT_NO_REGULAREXPRESSION
case QMetaType::QEasingCurve:
stream >> *static_cast< NS(QEasingCurve)*>(data);
break;
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 3ffbfb8385..16ea1042a2 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -56,8 +56,6 @@
#error qmetatype.h must be included before any header file that defines Bool
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -534,6 +532,9 @@ struct QMetaTypeId2
static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
};
+template <typename T>
+struct QMetaTypeId2<const T&> : QMetaTypeId2<T> {};
+
namespace QtPrivate {
template <typename T, bool Defined = QMetaTypeId2<T>::Defined>
struct QMetaTypeIdHelper {
@@ -633,30 +634,30 @@ void qRegisterMetaTypeStreamOperators(const char *typeName
#endif // QT_NO_DATASTREAM
template <typename T>
-inline Q_DECL_CONSTEXPR int qMetaTypeId(
-#ifndef Q_QDOC
- T * /* dummy */ = 0
-#endif
-)
+inline Q_DECL_CONSTEXPR int qMetaTypeId()
{
Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
return QMetaTypeId2<T>::qt_metatype_id();
}
template <typename T>
-inline Q_DECL_CONSTEXPR int qRegisterMetaType(
-#if !defined(Q_QDOC) && !defined(Q_CC_SUN)
- T * dummy = 0
-#endif
-)
+inline Q_DECL_CONSTEXPR int qRegisterMetaType()
{
-#ifdef Q_CC_SUN
- return qMetaTypeId(static_cast<T *>(0));
-#else
- return qMetaTypeId(dummy);
-#endif
+ return qMetaTypeId<T>();
}
+#if QT_DEPRECATED_SINCE(5, 1) && !defined(Q_QDOC)
+// There used to be a T *dummy = 0 argument in Qt 4.0 to support MSVC6
+template <typename T>
+QT_DEPRECATED inline Q_DECL_CONSTEXPR int qMetaTypeId(T *)
+{ return qMetaTypeId<T>(); }
+#ifndef Q_CC_SUN
+template <typename T>
+QT_DEPRECATED inline Q_DECL_CONSTEXPR int qRegisterMetaType(T *)
+{ return qRegisterMetaType<T>(); }
+#endif
+#endif
+
template <typename T>
struct QMetaTypeIdQObject<T*, /* isPointerToTypeDerivedFromQObject */ true>
{
@@ -980,6 +981,4 @@ QT_END_NAMESPACE
QT_FOR_EACH_STATIC_TYPE(Q_DECLARE_BUILTIN_METATYPE)
-QT_END_HEADER
-
#endif // QMETATYPE_H
diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h
index 39bdd5e3bb..95b9e2e394 100644
--- a/src/corelib/kernel/qmetatype_p.h
+++ b/src/corelib/kernel/qmetatype_p.h
@@ -221,7 +221,7 @@ template<> struct TypeDefinition<QPointF> { static const bool IsAvailable = fals
#ifdef QT_NO_REGEXP
template<> struct TypeDefinition<QRegExp> { static const bool IsAvailable = false; };
#endif
-#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_REGEXP)
+#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_REGULAREXPRESSION)
template<> struct TypeDefinition<QRegularExpression> { static const bool IsAvailable = false; };
#endif
#ifdef QT_NO_SHORTCUT
diff --git a/src/corelib/kernel/qmimedata.h b/src/corelib/kernel/qmimedata.h
index 774a6e4986..84c73262b2 100644
--- a/src/corelib/kernel/qmimedata.h
+++ b/src/corelib/kernel/qmimedata.h
@@ -45,8 +45,6 @@
#include <QtCore/qvariant.h>
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -98,6 +96,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QMIMEDATA_H
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 36db55d25a..c96fb446d6 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1690,7 +1690,7 @@ void qt_qFindChildren_helper(const QObject *parent, const QRegExp &re,
}
#endif // QT_NO_REGEXP
-#ifndef QT_NO_REGEXP
+#ifndef QT_NO_REGULAREXPRESSION
/*!
\internal
*/
@@ -1712,7 +1712,7 @@ void qt_qFindChildren_helper(const QObject *parent, const QRegularExpression &re
qt_qFindChildren_helper(obj, re, mo, list, options);
}
}
-#endif // QT_NO_REGEXP
+#endif // QT_NO_REGULAREXPRESSION
/*!
\internal
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index a2d7dcd7ef..7beaa32855 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -56,8 +56,6 @@
#include <QtCore/qobject_impl.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -73,7 +71,7 @@ class QWidget;
#ifndef QT_NO_REGEXP
class QRegExp;
#endif
-#ifndef QT_NO_REGEXP
+#ifndef QT_NO_REGULAREXPRESSION
class QRegularExpression;
#endif
#ifndef QT_NO_USERDATA
@@ -179,7 +177,7 @@ public:
}
#endif
-#ifndef QT_NO_REGEXP
+#ifndef QT_NO_REGULAREXPRESSION
template<typename T>
inline QList<T> findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
@@ -496,8 +494,6 @@ namespace QtPrivate {
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
#endif // QOBJECT_H
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index 7ed4d33e96..0b5631f2a6 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -45,7 +45,10 @@
#error Do not include qobject_impl.h directly
#endif
-QT_BEGIN_HEADER
+#if 0
+#pragma qt_sync_skip_header_check
+#pragma qt_sync_stop_processing
+#endif
QT_BEGIN_NAMESPACE
@@ -207,6 +210,4 @@ namespace QtPrivate {
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index e4b4ce8b42..e849ec1599 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -198,6 +199,14 @@ public:
inline void connectNotify(const QMetaMethod &signal);
inline void disconnectNotify(const QMetaMethod &signal);
+ template <typename Func1, typename Func2>
+ static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
+ const typename QtPrivate::FunctionPointer<Func2>::Object *receiverPrivate, Func2 slot,
+ Qt::ConnectionType type = Qt::AutoConnection);
+
+ template <typename Func1, typename Func2>
+ static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
+ const typename QtPrivate::FunctionPointer<Func2>::Object *receiverPrivate, Func2 slot);
public:
ExtraData *extraData; // extra data set by the user
QThreadData *threadData; // id of the thread that owns the object
@@ -267,6 +276,74 @@ inline void QObjectPrivate::disconnectNotify(const QMetaMethod &signal)
q_ptr->disconnectNotify(signal);
}
+namespace QtPrivate {
+template<typename Func, typename Args, typename R> class QPrivateSlotObject : public QSlotObjectBase
+{
+ typedef QtPrivate::FunctionPointer<Func> FuncType;
+ Func function;
+ static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret)
+ {
+ switch (which) {
+ case Destroy:
+ delete static_cast<QPrivateSlotObject*>(this_);
+ break;
+ case Call:
+ FuncType::template call<Args, R>(static_cast<QPrivateSlotObject*>(this_)->function,
+ static_cast<typename FuncType::Object *>(QObjectPrivate::get(r)), a);
+ break;
+ case Compare:
+ *ret = *reinterpret_cast<Func *>(a) == static_cast<QPrivateSlotObject*>(this_)->function;
+ break;
+ case NumOperations: ;
+ }
+ }
+public:
+ explicit QPrivateSlotObject(Func f) : QSlotObjectBase(&impl), function(f) {}
+};
+} //namespace QtPrivate
+
+template <typename Func1, typename Func2>
+inline QMetaObject::Connection QObjectPrivate::connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
+ const typename QtPrivate::FunctionPointer<Func2>::Object *receiverPrivate, Func2 slot,
+ Qt::ConnectionType type)
+{
+ typedef QtPrivate::FunctionPointer<Func1> SignalType;
+ typedef QtPrivate::FunctionPointer<Func2> SlotType;
+ reinterpret_cast<typename SignalType::Object *>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<typename SignalType::Object *>(0));
+
+ //compilation error if the arguments does not match.
+ Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
+ "The slot requires more arguments than the signal provides.");
+ Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
+ "Signal and slot arguments are not compatible.");
+ Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
+ "Return type of the slot is not compatible with the return type of the signal.");
+
+ const int *types = 0;
+ if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
+ types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
+
+ return QObject::connectImpl(sender, reinterpret_cast<void **>(&signal),
+ receiverPrivate->q_func(), reinterpret_cast<void **>(&slot),
+ new QtPrivate::QPrivateSlotObject<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value,
+ typename SignalType::ReturnType>(slot),
+ type, types, &SignalType::Object::staticMetaObject);
+}
+
+template <typename Func1, typename Func2>
+bool QObjectPrivate::disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object* sender, Func1 signal,
+ const typename QtPrivate::FunctionPointer< Func2 >::Object* receiverPrivate, Func2 slot)
+{
+ typedef QtPrivate::FunctionPointer<Func1> SignalType;
+ typedef QtPrivate::FunctionPointer<Func2> SlotType;
+ reinterpret_cast<typename SignalType::Object *>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<typename SignalType::Object *>(0));
+ //compilation error if the arguments does not match.
+ Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
+ "Signal and slot arguments are not compatible.");
+ return QObject::disconnectImpl(sender, reinterpret_cast<void **>(&signal),
+ receiverPrivate->q_func(), reinterpret_cast<void **>(&slot),
+ &SignalType::Object::staticMetaObject);
+}
Q_DECLARE_TYPEINFO(QObjectPrivate::Connection, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QObjectPrivate::Sender, Q_MOVABLE_TYPE);
diff --git a/src/corelib/kernel/qobjectcleanuphandler.h b/src/corelib/kernel/qobjectcleanuphandler.h
index 96faabc173..1f053cc34b 100644
--- a/src/corelib/kernel/qobjectcleanuphandler.h
+++ b/src/corelib/kernel/qobjectcleanuphandler.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -72,6 +70,4 @@ private Q_SLOTS:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QOBJECTCLEANUPHANDLER_H
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index a0617379d5..afbe1a5ece 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -46,8 +46,6 @@
#include <QtCore/qobjectdefs_impl.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -483,6 +481,4 @@ inline const QMetaObject *QMetaObject::superClass() const
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QOBJECTDEFS_H
diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h
index 1452e720ad..959a255389 100644
--- a/src/corelib/kernel/qobjectdefs_impl.h
+++ b/src/corelib/kernel/qobjectdefs_impl.h
@@ -45,7 +45,10 @@
#error Do not include qobjectdefs_impl.h directly
#endif
-QT_BEGIN_HEADER
+#if 0
+#pragma qt_sync_skip_header_check
+#pragma qt_sync_stop_processing
+#endif
QT_BEGIN_NAMESPACE
@@ -601,6 +604,4 @@ namespace QtPrivate {
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h
index ebdeb156ba..230b6b66eb 100644
--- a/src/corelib/kernel/qpointer.h
+++ b/src/corelib/kernel/qpointer.h
@@ -46,67 +46,51 @@
#ifndef QT_NO_QOBJECT
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QVariant;
-class QPointerBase
-{
- QWeakPointer<QObject> wp;
-
-protected:
- inline QPointerBase() : wp() { }
- inline QPointerBase(QObject *p) : wp(p, true) { }
- // compiler-generated copy/move ctor/assignment operators are fine! (even though public)
- inline ~QPointerBase() { }
-
- inline QObject* data() const
- { return wp.data(); }
-
- inline void assign(QObject *p)
- { wp.assign(p); }
-
- inline bool isNull() const
- { return wp.isNull(); }
-
- inline void clear()
- { wp.clear(); }
-};
-
template <class T>
-class QPointer : private QPointerBase
+class QPointer
{
+ template<typename U>
+ struct TypeSelector
+ {
+ typedef QObject Type;
+ };
+ template<typename U>
+ struct TypeSelector<const U>
+ {
+ typedef const QObject Type;
+ };
+ typedef typename TypeSelector<T>::Type QObjectType;
+ QWeakPointer<QObjectType> wp;
public:
inline QPointer() { }
- inline QPointer(T *p) : QPointerBase(p) { }
+ inline QPointer(T *p) : wp(p, true) { }
// compiler-generated copy/move ctor/assignment operators are fine!
inline ~QPointer() { }
inline QPointer<T> &operator=(T* p)
- { QPointerBase::assign(p); return *this; }
+ { wp.assign(static_cast<QObjectType*>(p)); return *this; }
inline T* data() const
- { return static_cast<T*>(QPointerBase::data()); }
+ { return static_cast<T*>( wp.data()); }
inline T* operator->() const
{ return data(); }
inline T& operator*() const
{ return *data(); }
inline operator T*() const
{ return data(); }
-#ifdef Q_QDOC
- inline bool isNull() const;
- inline void clear();
-#else
- using QPointerBase::isNull;
- using QPointerBase::clear;
-#endif
+
+ inline bool isNull() const
+ { return wp.isNull(); }
+
+ inline void clear()
+ { wp.clear(); }
};
template <class T> Q_DECLARE_TYPEINFO_BODY(QPointer<T>, Q_MOVABLE_TYPE);
-#if (!defined(Q_CC_SUN) || (__SUNPRO_CC >= 0x580)) // ambiguity between const T * and T *
-
template <class T>
inline bool operator==(const T *o, const QPointer<T> &p)
{ return o == p.operator->(); }
@@ -115,18 +99,6 @@ template<class T>
inline bool operator==(const QPointer<T> &p, const T *o)
{ return p.operator->() == o; }
-#else
-
-template<class T>
-inline bool operator==(const void *o, const QPointer<T> &p)
-{ return o == p.operator->(); }
-
-template<class T>
-inline bool operator==(const QPointer<T> &p, const void *o)
-{ return p.operator->() == o; }
-
-#endif
-
template <class T>
inline bool operator==(T *o, const QPointer<T> &p)
{ return o == p.operator->(); }
@@ -139,9 +111,6 @@ template<class T>
inline bool operator==(const QPointer<T> &p1, const QPointer<T> &p2)
{ return p1.operator->() == p2.operator->(); }
-
-#if (!defined(Q_CC_SUN) || (__SUNPRO_CC >= 0x580)) // ambiguity between const T * and T *
-
template <class T>
inline bool operator!=(const T *o, const QPointer<T> &p)
{ return o != p.operator->(); }
@@ -150,18 +119,6 @@ template<class T>
inline bool operator!= (const QPointer<T> &p, const T *o)
{ return p.operator->() != o; }
-#else
-
-template<class T>
-inline bool operator!= (const void *o, const QPointer<T> &p)
-{ return o != p.operator->(); }
-
-template<class T>
-inline bool operator!= (const QPointer<T> &p, const void *o)
-{ return p.operator->() != o; }
-
-#endif
-
template <class T>
inline bool operator!=(T *o, const QPointer<T> &p)
{ return o != p.operator->(); }
@@ -174,17 +131,6 @@ template<class T>
inline bool operator!= (const QPointer<T> &p1, const QPointer<T> &p2)
{ return p1.operator->() != p2.operator->() ; }
-// Make MSVC < 1400 (2005) handle "if (NULL == p)" syntax
-#if defined(Q_CC_MSVC) && (_MSC_VER < 1400)
-template<class T>
-inline bool operator== (int i, const QPointer<T> &p)
-{ Q_ASSERT(i == 0); return !i && p.isNull(); }
-
-template<class T>
-inline bool operator!= (int i, const QPointer<T> &p)
-{ Q_ASSERT(i == 0); return !i && !p.isNull(); }
-#endif
-
template<typename T>
QPointer<T>
qPointerFromVariant(const QVariant &variant)
@@ -194,8 +140,6 @@ qPointerFromVariant(const QVariant &variant)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_QOBJECT
#endif // QPOINTER_H
diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h
index d87ba02ac9..6b44548f44 100644
--- a/src/corelib/kernel/qsharedmemory.h
+++ b/src/corelib/kernel/qsharedmemory.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -114,7 +112,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSHAREDMEMORY_H
diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h
index dd9856adf5..9f1e6c8aa1 100644
--- a/src/corelib/kernel/qsharedmemory_p.h
+++ b/src/corelib/kernel/qsharedmemory_p.h
@@ -69,7 +69,7 @@ namespace QSharedMemoryPrivate
#include "qsystemsemaphore.h"
#include "private/qobject_p.h"
-#if !defined(Q_OS_WIN) && !defined(Q_OS_LINUX_ANDROID)
+#if !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID)
# include <sys/sem.h>
#endif
diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp
index 7f13e3b1a2..fdd73657a9 100644
--- a/src/corelib/kernel/qsharedmemory_unix.cpp
+++ b/src/corelib/kernel/qsharedmemory_unix.cpp
@@ -151,9 +151,6 @@ key_t QSharedMemoryPrivate::handle()
*/
int QSharedMemoryPrivate::createUnixKeyFile(const QString &fileName)
{
- if (QFile::exists(fileName))
- return 0;
-
int fd = qt_safe_open(QFile::encodeName(fileName).constData(),
O_EXCL | O_CREAT | O_RDWR, 0640);
if (-1 == fd) {
diff --git a/src/corelib/kernel/qsignalmapper.h b/src/corelib/kernel/qsignalmapper.h
index f1f4428118..997e8e46de 100644
--- a/src/corelib/kernel/qsignalmapper.h
+++ b/src/corelib/kernel/qsignalmapper.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QSignalMapperPrivate;
@@ -86,6 +84,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSIGNALMAPPER_H
diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h
index 97321521e4..8cc6b9c4c4 100644
--- a/src/corelib/kernel/qsocketnotifier.h
+++ b/src/corelib/kernel/qsocketnotifier.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QSocketNotifierPrivate;
@@ -84,6 +82,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSOCKETNOTIFIER_H
diff --git a/src/corelib/kernel/qsystemsemaphore.h b/src/corelib/kernel/qsystemsemaphore.h
index 52547f0c1f..b7dd220832 100644
--- a/src/corelib/kernel/qsystemsemaphore.h
+++ b/src/corelib/kernel/qsystemsemaphore.h
@@ -45,8 +45,6 @@
#include <QtCore/qstring.h>
#include <QtCore/qscopedpointer.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -96,7 +94,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSYSTEMSEMAPHORE_H
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index 9a90ecc772..34bfff9089 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -47,8 +47,6 @@
#include <QtCore/qbasictimer.h> // conceptual inheritance
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -114,8 +112,6 @@ inline void QTimer::setSingleShot(bool asingleShot) { single = asingleShot; }
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_QOBJECT
#endif // QTIMER_H
diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp
index 7a29247fc5..0e33fa697a 100644
--- a/src/corelib/kernel/qtimerinfo_unix.cpp
+++ b/src/corelib/kernel/qtimerinfo_unix.cpp
@@ -77,7 +77,7 @@ QTimerInfoList::QTimerInfoList()
msPerTick = 1000/ticksPerSecond;
} else {
// detected monotonic timers
- previousTime.tv_sec = previousTime.tv_usec = 0;
+ previousTime.tv_sec = previousTime.tv_nsec = 0;
previousTicks = 0;
ticksPerSecond = 0;
msPerTick = 0;
@@ -87,24 +87,24 @@ QTimerInfoList::QTimerInfoList()
firstTimerInfo = 0;
}
-timeval QTimerInfoList::updateCurrentTime()
+timespec QTimerInfoList::updateCurrentTime()
{
return (currentTime = qt_gettime());
}
#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_INTEGRITY)) || defined(QT_BOOTSTRAPPED)
-timeval qAbsTimeval(const timeval &t)
+timespec qAbsTimespec(const timespec &t)
{
- timeval tmp = t;
+ timespec tmp = t;
if (tmp.tv_sec < 0) {
tmp.tv_sec = -tmp.tv_sec - 1;
- tmp.tv_usec -= 1000000;
+ tmp.tv_nsec -= 1000000000;
}
- if (tmp.tv_sec == 0 && tmp.tv_usec < 0) {
- tmp.tv_usec = -tmp.tv_usec;
+ if (tmp.tv_sec == 0 && tmp.tv_nsec < 0) {
+ tmp.tv_nsec = -tmp.tv_nsec;
}
- return normalizedTimeval(tmp);
+ return normalizedTimespec(tmp);
}
/*
@@ -114,7 +114,7 @@ timeval qAbsTimeval(const timeval &t)
If /a delta is nonzero, delta is set to our best guess at how much the system clock was changed.
*/
-bool QTimerInfoList::timeChanged(timeval *delta)
+bool QTimerInfoList::timeChanged(timespec *delta)
{
#ifdef Q_OS_NACL
Q_UNUSED(delta)
@@ -124,13 +124,13 @@ bool QTimerInfoList::timeChanged(timeval *delta)
clock_t currentTicks = times(&unused);
clock_t elapsedTicks = currentTicks - previousTicks;
- timeval elapsedTime = currentTime - previousTime;
+ timespec elapsedTime = currentTime - previousTime;
- timeval elapsedTimeTicks;
+ timespec elapsedTimeTicks;
elapsedTimeTicks.tv_sec = elapsedTicks / ticksPerSecond;
- elapsedTimeTicks.tv_usec = (((elapsedTicks * 1000) / ticksPerSecond) % 1000) * 1000;
+ elapsedTimeTicks.tv_nsec = (((elapsedTicks * 1000) / ticksPerSecond) % 1000) * 1000 * 1000;
- timeval dummy;
+ timespec dummy;
if (!delta)
delta = &dummy;
*delta = elapsedTime - elapsedTimeTicks;
@@ -140,16 +140,16 @@ bool QTimerInfoList::timeChanged(timeval *delta)
// If tick drift is more than 10% off compared to realtime, we assume that the clock has
// been set. Of course, we have to allow for the tick granularity as well.
- timeval tickGranularity;
+ timespec tickGranularity;
tickGranularity.tv_sec = 0;
- tickGranularity.tv_usec = msPerTick * 1000;
- return elapsedTimeTicks < ((qAbsTimeval(*delta) - tickGranularity) * 10);
+ tickGranularity.tv_nsec = msPerTick * 1000 * 1000;
+ return elapsedTimeTicks < ((qAbsTimespec(*delta) - tickGranularity) * 10);
}
/*
repair broken timer
*/
-void QTimerInfoList::timerRepair(const timeval &diff)
+void QTimerInfoList::timerRepair(const timespec &diff)
{
// repair all timers
for (int i = 0; i < size(); ++i) {
@@ -162,7 +162,7 @@ void QTimerInfoList::repairTimersIfNeeded()
{
if (QElapsedTimer::isMonotonic())
return;
- timeval delta;
+ timespec delta;
if (timeChanged(&delta))
timerRepair(delta);
}
@@ -189,27 +189,27 @@ void QTimerInfoList::timerInsert(QTimerInfo *ti)
insert(index+1, ti);
}
-inline timeval &operator+=(timeval &t1, int ms)
+inline timespec &operator+=(timespec &t1, int ms)
{
t1.tv_sec += ms / 1000;
- t1.tv_usec += ms % 1000 * 1000;
- return normalizedTimeval(t1);
+ t1.tv_nsec += ms % 1000 * 1000 * 1000;
+ return normalizedTimespec(t1);
}
-inline timeval operator+(const timeval &t1, int ms)
+inline timespec operator+(const timespec &t1, int ms)
{
- timeval t2 = t1;
+ timespec t2 = t1;
return t2 += ms;
}
-static timeval roundToMillisecond(timeval val)
+static timespec roundToMillisecond(timespec val)
{
// always round up
// worst case scenario is that the first trigger of a 1-ms timer is 0.999 ms late
- int us = val.tv_usec % 1000;
- val.tv_usec += 1000 - us;
- return normalizedTimeval(val);
+ int ns = val.tv_nsec % (1000 * 1000);
+ val.tv_nsec += 1000 * 1000 - ns;
+ return normalizedTimespec(val);
}
#ifdef QTIMERINFO_DEBUG
@@ -226,7 +226,7 @@ QDebug operator<<(QDebug s, Qt::TimerType t)
}
#endif
-static void calculateCoarseTimerTimeout(QTimerInfo *t, timeval currentTime)
+static void calculateCoarseTimerTimeout(QTimerInfo *t, timespec currentTime)
{
// The coarse timer works like this:
// - interval under 40 ms: round to even
@@ -245,7 +245,7 @@ static void calculateCoarseTimerTimeout(QTimerInfo *t, timeval currentTime)
// The objective is to make most timers wake up at the same time, thereby reducing CPU wakeups.
register uint interval = uint(t->interval);
- register uint msec = uint(t->timeout.tv_usec) / 1000;
+ register uint msec = uint(t->timeout.tv_nsec) / 1000 / 1000;
Q_ASSERT(interval >= 20);
// Calculate how much we can round and still keep within 5% error
@@ -327,16 +327,16 @@ static void calculateCoarseTimerTimeout(QTimerInfo *t, timeval currentTime)
recalculate:
if (msec == 1000u) {
++t->timeout.tv_sec;
- t->timeout.tv_usec = 0;
+ t->timeout.tv_nsec = 0;
} else {
- t->timeout.tv_usec = msec * 1000;
+ t->timeout.tv_nsec = msec * 1000 * 1000;
}
if (t->timeout < currentTime)
t->timeout += interval;
}
-static void calculateNextTimeout(QTimerInfo *t, timeval currentTime)
+static void calculateNextTimeout(QTimerInfo *t, timespec currentTime)
{
switch (t->timerType) {
case Qt::PreciseTimer:
@@ -382,9 +382,9 @@ static void calculateNextTimeout(QTimerInfo *t, timeval currentTime)
Returns the time to wait for the next timer, or null if no timers
are waiting.
*/
-bool QTimerInfoList::timerWait(timeval &tm)
+bool QTimerInfoList::timerWait(timespec &tm)
{
- timeval currentTime = updateCurrentTime();
+ timespec currentTime = updateCurrentTime();
repairTimersIfNeeded();
// Find first waiting timer not already active
@@ -405,7 +405,7 @@ bool QTimerInfoList::timerWait(timeval &tm)
} else {
// no time to wait
tm.tv_sec = 0;
- tm.tv_usec = 0;
+ tm.tv_nsec = 0;
}
return true;
@@ -418,9 +418,9 @@ bool QTimerInfoList::timerWait(timeval &tm)
*/
int QTimerInfoList::timerRemainingTime(int timerId)
{
- timeval currentTime = updateCurrentTime();
+ timespec currentTime = updateCurrentTime();
repairTimersIfNeeded();
- timeval tm = {0, 0};
+ timespec tm = {0, 0};
for (int i = 0; i < count(); ++i) {
register QTimerInfo *t = at(i);
@@ -428,7 +428,7 @@ int QTimerInfoList::timerRemainingTime(int timerId)
if (currentTime < t->timeout) {
// time to wait
tm = roundToMillisecond(t->timeout - currentTime);
- return tm.tv_sec*1000 + tm.tv_usec/1000;
+ return tm.tv_sec*1000 + tm.tv_nsec/1000/1000;
} else {
return 0;
}
@@ -451,7 +451,7 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time
t->obj = object;
t->activateRef = 0;
- timeval expected = updateCurrentTime() + interval;
+ timespec expected = updateCurrentTime() + interval;
switch (timerType) {
case Qt::PreciseTimer:
@@ -486,10 +486,10 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time
t->interval += 1;
t->interval >>= 1;
t->timeout.tv_sec = currentTime.tv_sec + t->interval;
- t->timeout.tv_usec = 0;
+ t->timeout.tv_nsec = 0;
// if we're past the half-second mark, increase the timeout again
- if (currentTime.tv_usec > 500*1000)
+ if (currentTime.tv_nsec > 500*1000*1000)
++t->timeout.tv_sec;
}
@@ -573,7 +573,7 @@ int QTimerInfoList::activateTimers()
int n_act = 0, maxCount = 0;
firstTimerInfo = 0;
- timeval currentTime = updateCurrentTime();
+ timespec currentTime = updateCurrentTime();
// qDebug() << "Thread" << QThread::currentThreadId() << "woken up at" << currentTime;
repairTimersIfNeeded();
diff --git a/src/corelib/kernel/qtimerinfo_unix_p.h b/src/corelib/kernel/qtimerinfo_unix_p.h
index 549062bd1f..ec7560429b 100644
--- a/src/corelib/kernel/qtimerinfo_unix_p.h
+++ b/src/corelib/kernel/qtimerinfo_unix_p.h
@@ -66,7 +66,7 @@ struct QTimerInfo {
int id; // - timer identifier
int interval; // - timer interval in milliseconds
Qt::TimerType timerType; // - timer type
- timeval timeout; // - when to actually fire
+ timespec timeout; // - when to actually fire
QObject *obj; // - object to receive event
QTimerInfo **activateRef; // - ref from activateTimers
@@ -80,13 +80,13 @@ struct QTimerInfo {
class Q_CORE_EXPORT QTimerInfoList : public QList<QTimerInfo*>
{
#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED)
- timeval previousTime;
+ timespec previousTime;
clock_t previousTicks;
int ticksPerSecond;
int msPerTick;
- bool timeChanged(timeval *delta);
- void timerRepair(const timeval &);
+ bool timeChanged(timespec *delta);
+ void timerRepair(const timespec &);
#endif
// state variables used by activateTimers()
@@ -95,13 +95,13 @@ class Q_CORE_EXPORT QTimerInfoList : public QList<QTimerInfo*>
public:
QTimerInfoList();
- timeval currentTime;
- timeval updateCurrentTime();
+ timespec currentTime;
+ timespec updateCurrentTime();
// must call updateCurrentTime() first!
void repairTimersIfNeeded();
- bool timerWait(timeval &);
+ bool timerWait(timespec &);
void timerInsert(QTimerInfo *);
int timerRemainingTime(int timerId);
diff --git a/src/corelib/kernel/qtranslator.h b/src/corelib/kernel/qtranslator.h
index 98c0b81c97..c3957aff3f 100644
--- a/src/corelib/kernel/qtranslator.h
+++ b/src/corelib/kernel/qtranslator.h
@@ -45,8 +45,6 @@
#include <QtCore/qobject.h>
#include <QtCore/qbytearray.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -87,6 +85,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTRANSLATOR_H
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index d70d8d9a68..ed1a8a4974 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1529,10 +1529,13 @@ QVariant::QVariant(const QLocale &l)
QVariant::QVariant(const QRegExp &regExp)
: d(RegExp)
{ v_construct<QRegExp>(&d, regExp); }
+#endif // QT_NO_REGEXP
#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_REGULAREXPRESSION
QVariant::QVariant(const QRegularExpression &re)
: d(RegularExpression)
{ v_construct<QRegularExpression>(&d, re); }
+#endif
QVariant::QVariant(const QUuid &uuid)
: d(Uuid)
{ v_construct<QUuid>(&d, uuid); }
@@ -1552,7 +1555,6 @@ QVariant::QVariant(const QJsonDocument &jsonDocument)
: d(QMetaType::QJsonDocument)
{ v_construct<QJsonDocument>(&d, jsonDocument); }
#endif // QT_BOOTSTRAPPED
-#endif // QT_NO_REGEXP
/*!
Returns the storage type of the value stored in the variant.
@@ -2214,6 +2216,7 @@ QRegExp QVariant::toRegExp() const
}
#endif
+#ifndef QT_BOOTSTRAPPED
/*!
\fn QRegularExpression QVariant::toRegularExpression() const
\since 5.0
@@ -2223,13 +2226,12 @@ QRegExp QVariant::toRegExp() const
\sa canConvert(), convert()
*/
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGEXP
+#ifndef QT_NO_REGULAREXPRESSION
QRegularExpression QVariant::toRegularExpression() const
{
return qVariantToHelper<QRegularExpression>(d, handlerManager);
}
-#endif
+#endif // QT_NO_REGULAREXPRESSION
/*!
\since 5.0
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index d21f48f98c..6f212f5000 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -51,8 +51,6 @@
#include <QtCore/qstring.h>
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -76,8 +74,10 @@ class QRect;
class QRectF;
#ifndef QT_NO_REGEXP
class QRegExp;
-class QRegularExpression;
#endif // QT_NO_REGEXP
+#ifndef QT_NO_REGULAREXPRESSION
+class QRegularExpression;
+#endif // QT_NO_REGULAREXPRESSION
class QTextFormat;
class QTextLength;
class QUrl;
@@ -240,11 +240,11 @@ class Q_CORE_EXPORT QVariant
QVariant(const QLocale &locale);
#ifndef QT_NO_REGEXP
QVariant(const QRegExp &regExp);
-#ifndef QT_BOOTSRAPPED
- QVariant(const QRegularExpression &re);
-#endif // QT_BOOTSTRAPPED
#endif // QT_NO_REGEXP
#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_REGULAREXPRESSION
+ QVariant(const QRegularExpression &re);
+#endif // QT_NO_REGULAREXPRESSION
QVariant(const QUrl &url);
QVariant(const QEasingCurve &easing);
QVariant(const QUuid &uuid);
@@ -253,7 +253,7 @@ class Q_CORE_EXPORT QVariant
QVariant(const QJsonObject &jsonObject);
QVariant(const QJsonArray &jsonArray);
QVariant(const QJsonDocument &jsonDocument);
-#endif
+#endif // QT_BOOTSTRAPPED
QVariant& operator=(const QVariant &other);
#ifdef Q_COMPILER_RVALUE_REFS
@@ -313,11 +313,11 @@ class Q_CORE_EXPORT QVariant
QLocale toLocale() const;
#ifndef QT_NO_REGEXP
QRegExp toRegExp() const;
-#ifndef QT_BOOTSTRAPPED
- QRegularExpression toRegularExpression() const;
-#endif // QT_BOOTSTRAPPED
#endif // QT_NO_REGEXP
#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_REGULAREXPRESSION
+ QRegularExpression toRegularExpression() const;
+#endif // QT_NO_REGULAREXPRESSION
QUrl toUrl() const;
QEasingCurve toEasingCurve() const;
QUuid toUuid() const;
@@ -326,7 +326,7 @@ class Q_CORE_EXPORT QVariant
QJsonObject toJsonObject() const;
QJsonArray toJsonArray() const;
QJsonDocument toJsonDocument() const;
-#endif
+#endif // QT_BOOTSTRAPPED
#ifndef QT_NO_DATASTREAM
void load(QDataStream &ds);
@@ -484,7 +484,7 @@ public:
template <typename T>
inline QVariant qVariantFromValue(const T &t)
{
- return QVariant(qMetaTypeId<T>(reinterpret_cast<T *>(0)), &t, QTypeInfo<T>::isPointer);
+ return QVariant(qMetaTypeId<T>(), &t, QTypeInfo<T>::isPointer);
}
template <>
@@ -494,7 +494,7 @@ template <typename T>
inline void qVariantSetValue(QVariant &v, const T &t)
{
//if possible we reuse the current QVariant private
- const uint type = qMetaTypeId<T>(reinterpret_cast<T *>(0));
+ const uint type = qMetaTypeId<T>();
QVariant::Private &d = v.data_ptr();
if (v.isDetached() && (type == d.type || (type <= uint(QVariant::Char) && d.type <= uint(QVariant::Char)))) {
d.type = type;
@@ -568,7 +568,7 @@ namespace QtPrivate {
{
static T metaType(const QVariant &v)
{
- const int vid = qMetaTypeId<T>(static_cast<T *>(0));
+ const int vid = qMetaTypeId<T>();
if (vid == v.userType())
return *reinterpret_cast<const T *>(v.constData());
if (vid < int(QMetaType::User)) {
@@ -620,6 +620,4 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QVariant::Type);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QVARIANT_H
diff --git a/src/corelib/kernel/qwineventnotifier.h b/src/corelib/kernel/qwineventnotifier.h
index ca84054d71..56605d9aaa 100644
--- a/src/corelib/kernel/qwineventnotifier.h
+++ b/src/corelib/kernel/qwineventnotifier.h
@@ -47,8 +47,6 @@
#ifdef Q_OS_WIN
#include "QtCore/qt_windows.h"
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QWinEventNotifierPrivate;
@@ -83,8 +81,6 @@ protected:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // Q_OS_WIN
#endif // QWINEVENTNOTIFIER_H