From 59eb393cf57015a4dfea94617c863aafb096afa7 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 14 Oct 2012 16:29:39 +0100 Subject: Rename QRegularExpression-related feature defs to QT_NO_REGULAREXPRESSION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QRegExp and QRegularExpression are totally independent, therefore using two different defines is the right thing to do. Also, document the new define in qfeatures.{txt,h}. Change-Id: Ice4826ea543f4b22f1cc27bf31ed6e043d0c43b0 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qmetatype.cpp | 8 ++++---- src/corelib/kernel/qmetatype_p.h | 2 +- src/corelib/kernel/qobject.cpp | 4 ++-- src/corelib/kernel/qobject.h | 4 ++-- src/corelib/kernel/qvariant.cpp | 10 ++++++---- src/corelib/kernel/qvariant.h | 20 +++++++++++--------- 6 files changed, 26 insertions(+), 22 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 6194f20912..8a04b06c42 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -943,11 +943,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(data); break; -#endif // QT_NO_REGEXP +#endif // QT_NO_REGULAREXPRESSION case QMetaType::QEasingCurve: stream << *static_cast(data); break; @@ -1166,11 +1166,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_p.h b/src/corelib/kernel/qmetatype_p.h index 351baa9aaa..f31392e00d 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -221,7 +221,7 @@ template<> struct TypeDefinition { static const bool IsAvailable = fals #ifdef QT_NO_REGEXP template<> struct TypeDefinition { 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 { static const bool IsAvailable = false; }; #endif #ifdef QT_NO_SHORTCUT diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 9091b5579e..28b0b66ba8 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 e9316c98f0..36aded2cdb 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -73,7 +73,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 @@ -187,7 +187,7 @@ public: } #endif -#ifndef QT_NO_REGEXP +#ifndef QT_NO_REGULAREXPRESSION template inline QList findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 26deeba6a2..a88b7d2b1f 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 ®Exp) : d(RegExp) { v_construct(&d, regExp); } +#endif // QT_NO_REGEXP #ifndef QT_BOOTSTRAPPED +#ifndef QT_NO_REGULAREXPRESSION QVariant::QVariant(const QRegularExpression &re) : d(RegularExpression) { v_construct(&d, re); } +#endif QVariant::QVariant(const QUuid &uuid) : d(Uuid) { v_construct(&d, uuid); } @@ -1552,7 +1555,6 @@ QVariant::QVariant(const QJsonDocument &jsonDocument) : d(QMetaType::QJsonDocument) { v_construct(&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(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 86b43cf69a..692af9afc6 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -76,8 +76,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 +242,11 @@ class Q_CORE_EXPORT QVariant QVariant(const QLocale &locale); #ifndef QT_NO_REGEXP QVariant(const QRegExp ®Exp); -#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 +255,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 +315,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 +328,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); -- cgit v1.2.3 From f927efd77a8e75e330b3592996277ad6e6eb6a8d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 25 Oct 2012 12:38:13 -0700 Subject: Add support for Linux eventfd(7) in the UNIX event loop eventfd(7) uses less resources than a pipe, as it only needs to store a single 64-bit integer, as opposed to a full buffer. It was introduced first on Linux version 2.6.22 and glibc 2.7. However, both the configure-time test and the runtime usage require the use of EFD_CLOEXEC for thread-safety, so this code will be enabled only for Linux 2.6.27 and up as well as glibc 2.9 and up. Change-Id: Ic7e10b28d7b1d4ca24be614ed84055c4429a68e4 Reviewed-by: Robin Burchell Reviewed-by: Oswald Buddenhagen --- src/corelib/kernel/qeventdispatcher_unix.cpp | 37 +++++++++++++++++++++++++--- src/corelib/kernel/qeventdispatcher_unix_p.h | 3 +++ 2 files changed, 36 insertions(+), 4 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index 995f5101cb..6408147567 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -56,6 +56,10 @@ #include #include +#ifndef QT_NO_EVENTFD +# include +#endif + // VxWorks doesn't correctly set the _POSIX_... options #if defined(Q_OS_VXWORKS) # if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK <= 0) @@ -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; @@ -155,7 +165,8 @@ QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate() #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 @@ -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 @@ -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 98ea19ced8..e96acf65af 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -148,6 +148,9 @@ public: 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 -- cgit v1.2.3 From d147285d644157bc12487584578b5389b56eea31 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 14 Jan 2013 12:58:31 +0100 Subject: Add Q_COREAPP_STARTUP_FUNCTION macro. This is necessary for initializing things in a library, which require a QCoreApplication instance (unlike Q_CONSTRUCTOR_FUNCTION, which runs before that). Example use cases: KCrash (segv handler), and KCheckAccelerators (debugging tool triggered by magic key combination). Change-Id: I5f4c4699dd4d21aea72b007989ba57467e86ed10 Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcoreapplication.cpp | 65 +++++++++++++++++++++++++++++++++ src/corelib/kernel/qcoreapplication.h | 8 ++++ 2 files changed, 73 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 8ede244145..c9f973b52f 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 QStartUpFuncList; +Q_GLOBAL_STATIC(QStartUpFuncList, preRList) typedef QList 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; @@ -637,6 +676,7 @@ void QCoreApplication::init() d->processCommandLineArguments(); + qt_call_pre_routines(); qt_startup_hook(); } @@ -2324,6 +2364,31 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc mainThread->setEventDispatcher(eventDispatcher); } +/*! + \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 185aea53d1..0dfad6f23e 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -220,12 +220,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 &); -- cgit v1.2.3 From 7e3d5a720752900b1ccbb3d8dcbf12cc02b01b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Fri, 15 Jun 2012 13:33:58 +0300 Subject: Use Qt defined gettimeofday for VxWorks and no fallback to X11 version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VxWorks don't have gettimeofday function so we always use the one implemented in Qt. VxWorks DIAB compiler is not supported building Qt for VxWorks 6.9.2. Anyone using older VxWorks should also not be affected so use new defines VXWORKS_DKM and VXWORKS_RTP for VxWorks version 6.9.2 onward. Change-Id: I2e9546a101256ea0557b65163b40cd0f28be8519 Reviewed-by: Samuel Rødal --- src/corelib/kernel/qfunctions_vxworks.cpp | 2 +- src/corelib/kernel/qfunctions_vxworks.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qfunctions_vxworks.cpp b/src/corelib/kernel/qfunctions_vxworks.cpp index add4108762..49d9d51ac0 100644 --- a/src/corelib/kernel/qfunctions_vxworks.cpp +++ b/src/corelib/kernel/qfunctions_vxworks.cpp @@ -92,7 +92,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*/ *) diff --git a/src/corelib/kernel/qfunctions_vxworks.h b/src/corelib/kernel/qfunctions_vxworks.h index d0f6e60cb2..323d662ba1 100644 --- a/src/corelib/kernel/qfunctions_vxworks.h +++ b/src/corelib/kernel/qfunctions_vxworks.h @@ -52,7 +52,11 @@ #include #include #include +#if defined(_WRS_KERNEL) #include +#else +#include +#endif #include #include #include @@ -100,10 +104,14 @@ int rand_r(unsigned int * /*seedp*/); // 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 int getpagesize(); -- cgit v1.2.3 From 608cd1ad84484448ac9b0b8b4d88e0e8ff4a9cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Fri, 15 Jun 2012 14:30:15 +0300 Subject: Use taskIdSelf() function instead of taskIdCurrent global variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The uniprocessor taskIdCurrent global variable (declared in taskLib.h) does not exist in VxWorks SMP, because of concurrent execution on multiple CPUs. Any uniprocessor code that reads taskIdCurrent should make calls to taskIdSelf() instead. Change-Id: I4e0efef32297f339d6121c7d4bca3820e0fc9294 Reviewed-by: Samuel Rødal --- src/corelib/kernel/qeventdispatcher_unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index 6408147567..b22260a420 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -113,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); @@ -159,7 +159,7 @@ 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 -- cgit v1.2.3 From 00faa09aadfc6c6db9da639ba6b7866c72447e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Wed, 13 Jun 2012 14:47:40 +0300 Subject: Add support getting memory page size to RTP mode on VxWorks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id71bf7fd8e7371284076247558cba7edb0307e13 Reviewed-by: Samuel Rødal --- src/corelib/kernel/qfunctions_vxworks.cpp | 6 ++++++ src/corelib/kernel/qfunctions_vxworks.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qfunctions_vxworks.cpp b/src/corelib/kernel/qfunctions_vxworks.cpp index 49d9d51ac0..5ed2a62052 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 +#endif #include #include @@ -118,7 +120,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 323d662ba1..67920d13cb 100644 --- a/src/corelib/kernel/qfunctions_vxworks.h +++ b/src/corelib/kernel/qfunctions_vxworks.h @@ -113,7 +113,7 @@ int gettimeofday(struct timeval *, void *); 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) -- cgit v1.2.3 From 2d2da44f6381fdeaa195319c0dc66e3909c2ca7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Tue, 15 Jan 2013 14:32:11 +0200 Subject: Use time.h related includes from qfunctions_vxworks.h file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In VxWorks qfunctions_vxworks.h file includes correct time related headers and it is included already at file qplatformdefs.h for all mkspecs targets. Change-Id: I8677eef8c79cebb445d89203284f3af27abbdd7f Reviewed-by: Samuel Rødal --- src/corelib/kernel/qeventdispatcher_unix_p.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index e96acf65af..6759a33823 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 -#else +#if !defined(Q_OS_VXWORKS) # include # if (!defined(Q_OS_HPUX) || defined(__ia64)) && !defined(Q_OS_NACL) # include -- cgit v1.2.3 From f7bd8652caab2f53ced739ce90c640924d4962dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Thu, 17 Jan 2013 17:24:21 +0200 Subject: Undefine overlapping variable names defined in VxWorks headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VxWorks has defined variables with same name as in Qt's headers. Undefine those variables to avoid naming conflict. Change-Id: Ia8ca04a66acece683cd6c7f71df7e5a2800ec98d Reviewed-by: Oswald Buddenhagen Reviewed-by: Samuel Rødal --- src/corelib/kernel/qfunctions_vxworks.h | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qfunctions_vxworks.h b/src/corelib/kernel/qfunctions_vxworks.h index 67920d13cb..272f912a67 100644 --- a/src/corelib/kernel/qfunctions_vxworks.h +++ b/src/corelib/kernel/qfunctions_vxworks.h @@ -65,6 +65,44 @@ #include #endif +// 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 , 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_HEADER QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 119c581dd1e0b9164e1631f43820abc3dee82e27 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Jan 2013 23:08:45 -0800 Subject: Simplify checking of the SHM/SEM Unix key file's existence We don't need to stat(2) the file to check if it exists before creating it. We're about to open(2) with O_CREAT|O_EXCL, which will not recreate it if it existed. Change-Id: I2d2176054e7776a32a4520832ee104b9c4ccf748 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Richard J. Moore --- src/corelib/kernel/qsharedmemory_unix.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp index 6bcb4076b4..7b64ff1181 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) { -- cgit v1.2.3 From bf5f2a9e3e3bf70c373b65bf95a332f4e1c514f9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 10 Aug 2012 16:14:48 +0200 Subject: Switch to struct timespec everywhere instead of timeval This avoids an extra division by 1000 when getting the current time. This can't overflow, under normal circumstances, even on 32-bit: when adding two values less than 1 billion, the result is less than 2 billion, which is less than 2^31. Change-Id: I6f8e1aadfe2fcf6ac8da584eab4c1e61aee51cbb Reviewed-by: David Faure (KDE) Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcore_unix.cpp | 14 ++--- src/corelib/kernel/qcore_unix_p.h | 54 +++++++++--------- src/corelib/kernel/qeventdispatcher_glib.cpp | 4 +- src/corelib/kernel/qeventdispatcher_unix.cpp | 10 ++-- src/corelib/kernel/qeventdispatcher_unix_p.h | 4 +- src/corelib/kernel/qtimerinfo_unix.cpp | 82 ++++++++++++++-------------- src/corelib/kernel/qtimerinfo_unix_p.h | 14 ++--- 7 files changed, 91 insertions(+), 91 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index cc5479876d..5ab1d510ef 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,13 @@ 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); + ret = ::pselect(nfds, fdread, fdwrite, fdexcept, &timeout, 0); 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/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 233b7eef2f..c79fe89105 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -173,7 +173,7 @@ QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate() qDeleteAll(timerList); } -int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, timeval *timeout) +int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, timespec *timeout) { Q_Q(QEventDispatcherUNIX); @@ -327,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); } @@ -600,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; @@ -613,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); diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index f1d33f9f09..db89b7c444 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -130,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 @@ -141,7 +141,7 @@ 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); diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp index 0eee425cf9..a81fa83f29 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,7 +87,7 @@ QTimerInfoList::QTimerInfoList() firstTimerInfo = 0; } -timeval QTimerInfoList::updateCurrentTime() +timespec QTimerInfoList::updateCurrentTime() { return (currentTime = qt_gettime()); } @@ -95,17 +95,17 @@ timeval QTimerInfoList::updateCurrentTime() #if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_INTEGRITY)) || defined(QT_BOOTSTRAPPED) template <> -timeval qAbs(const timeval &t) +timespec qAbs(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); } /* @@ -115,7 +115,7 @@ timeval qAbs(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) @@ -125,13 +125,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; @@ -141,16 +141,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; + tickGranularity.tv_nsec = msPerTick * 1000 * 1000; return elapsedTimeTicks < ((qAbs(*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) { @@ -163,7 +163,7 @@ void QTimerInfoList::repairTimersIfNeeded() { if (QElapsedTimer::isMonotonic()) return; - timeval delta; + timespec delta; if (timeChanged(&delta)) timerRepair(delta); } @@ -190,27 +190,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 @@ -227,7 +227,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 @@ -246,7 +246,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 @@ -328,16 +328,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: @@ -383,9 +383,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 @@ -406,7 +406,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; @@ -419,9 +419,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); @@ -429,7 +429,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; } @@ -452,7 +452,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: @@ -487,10 +487,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; } @@ -574,7 +574,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 { #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 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); -- cgit v1.2.3 From 07e3bcdc106ac42703ae0fb88b6cac2d2bfdd072 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Sat, 26 Jan 2013 21:42:12 +0100 Subject: Remove QT_{BEGIN,END}_HEADER macro usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp Reviewed-by: Jędrzej Nowacki Reviewed-by: hjk --- src/corelib/kernel/qabstracteventdispatcher.h | 4 ---- src/corelib/kernel/qabstractnativeeventfilter.h | 4 ---- src/corelib/kernel/qbasictimer.h | 4 ---- src/corelib/kernel/qcoreapplication.h | 4 ---- src/corelib/kernel/qcoreevent.h | 4 ---- src/corelib/kernel/qeventloop.h | 4 ---- src/corelib/kernel/qeventloop_p.h | 4 ---- src/corelib/kernel/qfunctions_nacl.h | 4 ---- src/corelib/kernel/qfunctions_p.h | 3 --- src/corelib/kernel/qfunctions_vxworks.h | 3 --- src/corelib/kernel/qfunctions_wince.h | 3 --- src/corelib/kernel/qmath.h | 4 ---- src/corelib/kernel/qmetaobject.h | 4 ---- src/corelib/kernel/qmetatype.h | 4 ---- src/corelib/kernel/qmimedata.h | 4 ---- src/corelib/kernel/qobject.h | 4 ---- src/corelib/kernel/qobject_impl.h | 4 ---- src/corelib/kernel/qobjectcleanuphandler.h | 4 ---- src/corelib/kernel/qobjectdefs.h | 4 ---- src/corelib/kernel/qobjectdefs_impl.h | 4 ---- src/corelib/kernel/qpointer.h | 4 ---- src/corelib/kernel/qsharedmemory.h | 4 ---- src/corelib/kernel/qsignalmapper.h | 4 ---- src/corelib/kernel/qsocketnotifier.h | 4 ---- src/corelib/kernel/qsystemsemaphore.h | 4 ---- src/corelib/kernel/qtimer.h | 4 ---- src/corelib/kernel/qtranslator.h | 4 ---- src/corelib/kernel/qvariant.h | 4 ---- src/corelib/kernel/qwineventnotifier.h | 4 ---- 29 files changed, 113 deletions(-) (limited to 'src/corelib/kernel') 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 #include -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 -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 #include -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/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 5333ea22f4..b235e327e0 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 @@ -241,6 +239,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 #include -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/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 -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.h b/src/corelib/kernel/qfunctions_vxworks.h index 6776a6a721..d12a302c8d 100644 --- a/src/corelib/kernel/qfunctions_vxworks.h +++ b/src/corelib/kernel/qfunctions_vxworks.h @@ -103,15 +103,12 @@ # undef m_pkthdr #endif -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE #ifdef QT_BUILD_CORE_LIB #endif QT_END_NAMESPACE -QT_END_HEADER - #ifndef RTLD_LOCAL #define RTLD_LOCAL 0 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 #include -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.h b/src/corelib/kernel/qmath.h index 097200d690..ce49a91e93 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -46,8 +46,6 @@ #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -266,6 +264,4 @@ inline qreal qFastCos(qreal x) QT_END_NAMESPACE -QT_END_HEADER - #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 #include -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.h b/src/corelib/kernel/qmetatype.h index 3ffbfb8385..76cee612ce 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 @@ -980,6 +978,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/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 #include -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.h b/src/corelib/kernel/qobject.h index 92392fe994..7d47c377da 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -56,8 +56,6 @@ #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -508,8 +506,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 fbc523b8b7..49fa1897f7 100644 --- a/src/corelib/kernel/qobject_impl.h +++ b/src/corelib/kernel/qobject_impl.h @@ -45,8 +45,6 @@ #error Do not include qobject_impl.h directly #endif -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -207,6 +205,4 @@ namespace QtPrivate { QT_END_NAMESPACE -QT_END_HEADER - #endif 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 -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 -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 68d8fdf961..2d2107f666 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -45,8 +45,6 @@ #error Do not include qobjectdefs_impl.h directly #endif -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -601,6 +599,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..e84900e3b1 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -46,8 +46,6 @@ #ifndef QT_NO_QOBJECT -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class QVariant; @@ -194,8 +192,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 -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/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 -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 -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 #include -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 // conceptual inheritance #include -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/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 #include -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.h b/src/corelib/kernel/qvariant.h index 166a5cad6f..172ce29050 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -51,8 +51,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -622,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 -- cgit v1.2.3 From b28d56588a93852a8c7034a3b8b3c9146d1d8b28 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Sat, 26 Jan 2013 13:41:12 +0000 Subject: Generate forward header (QtMath) for the math operations with syncqt Change-Id: Ief5b5871a5d56bb606e09efcfd3a1422dcfbcd08 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmath.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h index ce49a91e93..75ec55f845 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -42,6 +42,10 @@ #ifndef QMATH_H #define QMATH_H +#if 0 +#pragma qt_class(QtMath) +#endif + #include #include -- cgit v1.2.3 From 36f64ec6ac07b3d02838b75f80efc445fd923891 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Tue, 29 Jan 2013 15:01:45 +0100 Subject: Work around posix violation in qnx (missing pselect()) Change-Id: I7c1ae85ee7e92da3f394b488643613894977556e Reviewed-by: Peter Hartmann Reviewed-by: Rafael Roquetto Reviewed-by: Bernd Weimer Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcore_unix.cpp | 7 +++++++ src/corelib/kernel/qeventdispatcher_blackberry.cpp | 18 +++++++++--------- src/corelib/kernel/qeventdispatcher_blackberry_p.h | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index 5ab1d510ef..241658acb1 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -90,7 +90,14 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, // loop and recalculate the timeout as needed int ret; forever { +#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/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); }; -- cgit v1.2.3 From 6c6960015ef32f3e58c9a1a14fe61413cbb19ce8 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Sat, 26 Jan 2013 13:25:45 +0000 Subject: Add qDegreesToRadians and qRadiansToDegrees math functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6e9fd76f2d2860f46531a72349b46193b8eeaaa7 Reviewed-by: Samuel Rødal --- src/corelib/kernel/qmath.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++++ src/corelib/kernel/qmath.h | 20 ++++++++++ 2 files changed, 107 insertions(+) (limited to 'src/corelib/kernel') 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 ** 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 + \title Generic Math Declarations + \ingroup funclists + + \brief The 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 + \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 or + elsewhere. + + Example: + + \snippet code/src_corelib_kernel_qmath.cpp 0 + + \sa qRadiansToDegrees() +*/ + +/*! + \fn double qDegreesToRadians(double degrees) + \relates + \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 or + elsewhere. + + Example: + + \snippet code/src_corelib_kernel_qmath.cpp 1 + + \sa qRadiansToDegrees() +*/ + +/*! + \fn float qRadiansToDegrees(float radians) + \relates + \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 or + elsewhere. + + Example: + + \snippet code/src_corelib_kernel_qmath.cpp 2 + + \sa qDegreesToRadians() +*/ + +/*! + \fn double qRadiansToDegrees(double radians) + \relates + \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 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 75ec55f845..21e23b9eb0 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -266,6 +266,26 @@ inline qreal qFastCos(qreal x) return qt_sine_table[si] - (qt_sine_table[ci] + 0.5 * qt_sine_table[si] * d) * d; } +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); +} + +Q_DECL_CONSTEXPR inline double qRadiansToDegrees(double radians) +{ + return radians * (180 / M_PI); +} + QT_END_NAMESPACE #endif // QMATH_H -- cgit v1.2.3 From c6cb4ddbf9401ca430a0c0fb0324040313131658 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 5 Feb 2013 15:46:28 +0100 Subject: qMetaTypeId(): deprecate the dummy parameter. It was there because of MSVC6 compatibility. It is not removed, because some code used to do qMetaTypeId(&myVariable); This was not a documented feature anyway, so it should not be user visible. Change-Id: I55327d7e73e67a6bb741817741d530d5a650291a Reviewed-by: Thiago Macieira Reviewed-by: Stephen Kelly --- src/corelib/kernel/qmetatype.h | 30 +++++++++++++++--------------- src/corelib/kernel/qvariant.h | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 76cee612ce..e4f1052673 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -631,30 +631,30 @@ void qRegisterMetaTypeStreamOperators(const char *typeName #endif // QT_NO_DATASTREAM template -inline Q_DECL_CONSTEXPR int qMetaTypeId( -#ifndef Q_QDOC - T * /* dummy */ = 0 -#endif -) +inline Q_DECL_CONSTEXPR int qMetaTypeId() { Q_STATIC_ASSERT_X(QMetaTypeId2::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system"); return QMetaTypeId2::qt_metatype_id(); } template -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(0)); -#else - return qMetaTypeId(dummy); -#endif + return qMetaTypeId(); } +#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 +QT_DEPRECATED inline Q_DECL_CONSTEXPR int qMetaTypeId(T *) +{ return qMetaTypeId(); } +#ifndef Q_CC_SUN +template +QT_DEPRECATED inline Q_DECL_CONSTEXPR int qRegisterMetaType(T *) +{ return qRegisterMetaType(); } +#endif +#endif + template struct QMetaTypeIdQObject { diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 172ce29050..6f212f5000 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -484,7 +484,7 @@ public: template inline QVariant qVariantFromValue(const T &t) { - return QVariant(qMetaTypeId(reinterpret_cast(0)), &t, QTypeInfo::isPointer); + return QVariant(qMetaTypeId(), &t, QTypeInfo::isPointer); } template <> @@ -494,7 +494,7 @@ template inline void qVariantSetValue(QVariant &v, const T &t) { //if possible we reuse the current QVariant private - const uint type = qMetaTypeId(reinterpret_cast(0)); + const uint type = qMetaTypeId(); 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(static_cast(0)); + const int vid = qMetaTypeId(); if (vid == v.userType()) return *reinterpret_cast(v.constData()); if (vid < int(QMetaType::User)) { -- cgit v1.2.3 From c21ed8ca1f03c82731abf01fc66e4c2f2e4c2a50 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 10 Feb 2013 14:51:43 +0100 Subject: Remove dead code from QPointer. The compilers checked here are not supported in Qt 5. Additionally, the QSharedPointer implementation has similar operators without such guards, so in reality these compilers may not have worked with Qt 4.6+ either. Change-Id: I208f3cde7c689770ae15245a555e3a58b749a8a3 Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/corelib/kernel/qpointer.h | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h index e84900e3b1..385bc2814b 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -103,8 +103,6 @@ public: }; template Q_DECLARE_TYPEINFO_BODY(QPointer, Q_MOVABLE_TYPE); -#if (!defined(Q_CC_SUN) || (__SUNPRO_CC >= 0x580)) // ambiguity between const T * and T * - template inline bool operator==(const T *o, const QPointer &p) { return o == p.operator->(); } @@ -113,18 +111,6 @@ template inline bool operator==(const QPointer &p, const T *o) { return p.operator->() == o; } -#else - -template -inline bool operator==(const void *o, const QPointer &p) -{ return o == p.operator->(); } - -template -inline bool operator==(const QPointer &p, const void *o) -{ return p.operator->() == o; } - -#endif - template inline bool operator==(T *o, const QPointer &p) { return o == p.operator->(); } @@ -137,9 +123,6 @@ template inline bool operator==(const QPointer &p1, const QPointer &p2) { return p1.operator->() == p2.operator->(); } - -#if (!defined(Q_CC_SUN) || (__SUNPRO_CC >= 0x580)) // ambiguity between const T * and T * - template inline bool operator!=(const T *o, const QPointer &p) { return o != p.operator->(); } @@ -148,18 +131,6 @@ template inline bool operator!= (const QPointer &p, const T *o) { return p.operator->() != o; } -#else - -template -inline bool operator!= (const void *o, const QPointer &p) -{ return o != p.operator->(); } - -template -inline bool operator!= (const QPointer &p, const void *o) -{ return p.operator->() != o; } - -#endif - template inline bool operator!=(T *o, const QPointer &p) { return o != p.operator->(); } @@ -172,17 +143,6 @@ template inline bool operator!= (const QPointer &p1, const QPointer &p2) { return p1.operator->() != p2.operator->() ; } -// Make MSVC < 1400 (2005) handle "if (NULL == p)" syntax -#if defined(Q_CC_MSVC) && (_MSC_VER < 1400) -template -inline bool operator== (int i, const QPointer &p) -{ Q_ASSERT(i == 0); return !i && p.isNull(); } - -template -inline bool operator!= (int i, const QPointer &p) -{ Q_ASSERT(i == 0); return !i && !p.isNull(); } -#endif - template QPointer qPointerFromVariant(const QVariant &variant) -- cgit v1.2.3 From 8840ad56a3afb185b4e0b9158130d6e265161f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Mon, 11 Feb 2013 16:11:27 +0200 Subject: Use stub function rand_r for VxWorks DKM mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vxworks DKM mode does not have rand_r function, use function implementation from qfunctions_vxworks.h/cpp instead. Change-Id: I8f23c3453ab9f31280eb90f66dd83d7a64ee98c9 Reviewed-by: Samuel Rødal --- src/corelib/kernel/qfunctions_vxworks.cpp | 2 ++ src/corelib/kernel/qfunctions_vxworks.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qfunctions_vxworks.cpp b/src/corelib/kernel/qfunctions_vxworks.cpp index 8d25ad6a8d..e1abecb9d6 100644 --- a/src/corelib/kernel/qfunctions_vxworks.cpp +++ b/src/corelib/kernel/qfunctions_vxworks.cpp @@ -76,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) diff --git a/src/corelib/kernel/qfunctions_vxworks.h b/src/corelib/kernel/qfunctions_vxworks.h index d12a302c8d..02c599f490 100644 --- a/src/corelib/kernel/qfunctions_vxworks.h +++ b/src/corelib/kernel/qfunctions_vxworks.h @@ -134,7 +134,9 @@ 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); -- cgit v1.2.3 From cc7239da8d1ab95e68e12a64df3ca3051419cb34 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 10 Feb 2013 10:57:43 +0100 Subject: Make it possible to use QPointer This is possible with QWeakPointer, so allow it for migrating code too. In the process, replace the QPointerBase with a member variable for simplicity. The functionality of the QPointerBase is replaced by a TypeSelector template. Change-Id: I3b4c77bdeda2b863cc33e84a3da8a25bae928c8c Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart --- src/corelib/kernel/qpointer.h | 56 +++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h index 385bc2814b..230b6b66eb 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -50,56 +50,44 @@ QT_BEGIN_NAMESPACE class QVariant; -class QPointerBase -{ - QWeakPointer 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 QPointer : private QPointerBase +class QPointer { + template + struct TypeSelector + { + typedef QObject Type; + }; + template + struct TypeSelector + { + typedef const QObject Type; + }; + typedef typename TypeSelector::Type QObjectType; + QWeakPointer 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 &operator=(T* p) - { QPointerBase::assign(p); return *this; } + { wp.assign(static_cast(p)); return *this; } inline T* data() const - { return static_cast(QPointerBase::data()); } + { return static_cast( 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 Q_DECLARE_TYPEINFO_BODY(QPointer, Q_MOVABLE_TYPE); -- cgit v1.2.3 From 0768920dbdabef25eb7d41e8dbba891704b24f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 16 Feb 2013 14:56:50 +0100 Subject: Remove ifdefs for supporting Mac OS <= 10.5 Qt5 requires Mac OS 10.6, so we can remove checks such as if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 Change-Id: Iea21727a277291148704ecf9677ed0b68c24920f Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcore_mac_p.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index c3a3afaf6c..b833eb4962 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -136,14 +136,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 -- cgit v1.2.3 From 03b25125986f083a260b421abeed1f1d088d27b3 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 5 Feb 2013 14:35:10 +0100 Subject: Fix QMetaType of const references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes QMetaType detection of const reference arguments in signals while connecting using the new syntax and Qt::QueuedConnection const references should have the same QMetaType as non references. That means we need to remove the const reference while getting the QMetaType. Change-Id: I9b2688da7fb9ae985aec0d8fa62a1165357ffe71 Reviewed-by: Thiago Macieira Reviewed-by: Stephen Kelly Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qmetatype.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index e4f1052673..16ea1042a2 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -532,6 +532,9 @@ struct QMetaTypeId2 static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId::qt_metatype_id(); } }; +template +struct QMetaTypeId2 : QMetaTypeId2 {}; + namespace QtPrivate { template ::Defined> struct QMetaTypeIdHelper { -- cgit v1.2.3 From 3bc4afc223bcd56245797a0bd3628f02a992301c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 1 Nov 2012 12:31:50 +0100 Subject: iOS: Move Q_OS_IOS out of makesespec to qsystemdetection.h We treat iOS as a variant of Mac OS, so for iOS both Q_OS_MAC and Q_OS_IOS will be defined. This matches what Apple assumes in the header file TargetConditionals.h Change-Id: I55cc851401b748297478e4c32e84e0f6e1fdfc28 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcore_mac_p.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index b833eb4962..361a6c2c67 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -63,6 +63,8 @@ #include #endif +#include "qglobal.h" + #ifndef Q_OS_IOS #include #endif -- cgit v1.2.3 From ab59a7ef09d56e59f9496ac59d88ba05db61e298 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 12 Oct 2012 12:20:40 +0200 Subject: Add private API to connect to slots in QObjectPrivate Change-Id: I16ffbf91ff4c6e9fca6fe7984800d2c24e70701b Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject_p.h | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'src/corelib/kernel') 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 ** 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 + static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer::Object *sender, Func1 signal, + const typename QtPrivate::FunctionPointer::Object *receiverPrivate, Func2 slot, + Qt::ConnectionType type = Qt::AutoConnection); + + template + static inline bool disconnect(const typename QtPrivate::FunctionPointer::Object *sender, Func1 signal, + const typename QtPrivate::FunctionPointer::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 class QPrivateSlotObject : public QSlotObjectBase +{ + typedef QtPrivate::FunctionPointer FuncType; + Func function; + static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret) + { + switch (which) { + case Destroy: + delete static_cast(this_); + break; + case Call: + FuncType::template call(static_cast(this_)->function, + static_cast(QObjectPrivate::get(r)), a); + break; + case Compare: + *ret = *reinterpret_cast(a) == static_cast(this_)->function; + break; + case NumOperations: ; + } + } +public: + explicit QPrivateSlotObject(Func f) : QSlotObjectBase(&impl), function(f) {} +}; +} //namespace QtPrivate + +template +inline QMetaObject::Connection QObjectPrivate::connect(const typename QtPrivate::FunctionPointer::Object *sender, Func1 signal, + const typename QtPrivate::FunctionPointer::Object *receiverPrivate, Func2 slot, + Qt::ConnectionType type) +{ + typedef QtPrivate::FunctionPointer SignalType; + typedef QtPrivate::FunctionPointer SlotType; + reinterpret_cast(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast(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::value), + "Signal and slot arguments are not compatible."); + Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible::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::types(); + + return QObject::connectImpl(sender, reinterpret_cast(&signal), + receiverPrivate->q_func(), reinterpret_cast(&slot), + new QtPrivate::QPrivateSlotObject::Value, + typename SignalType::ReturnType>(slot), + type, types, &SignalType::Object::staticMetaObject); +} + +template +bool QObjectPrivate::disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object* sender, Func1 signal, + const typename QtPrivate::FunctionPointer< Func2 >::Object* receiverPrivate, Func2 slot) +{ + typedef QtPrivate::FunctionPointer SignalType; + typedef QtPrivate::FunctionPointer SlotType; + reinterpret_cast(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast(0)); + //compilation error if the arguments does not match. + Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments::value), + "Signal and slot arguments are not compatible."); + return QObject::disconnectImpl(sender, reinterpret_cast(&signal), + receiverPrivate->q_func(), reinterpret_cast(&slot), + &SignalType::Object::staticMetaObject); +} Q_DECLARE_TYPEINFO(QObjectPrivate::Connection, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QObjectPrivate::Sender, Q_MOVABLE_TYPE); -- cgit v1.2.3 From 8b0868bb17690fa601b3b0cb8c630ac7a178062a Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 25 Feb 2013 13:37:37 -0800 Subject: Add notify signals to some QCoreApplication properties The various string properties are good candidates for exposure to QML. While QCoreApplication itself is unlikely to be exposed to QML directly, a wrapper exposure also needs these signals in order to react to changes from QCoreApplication. Change-Id: I266da6010f1c9300de4bb5e7775a0bdacab7f26c Reviewed-by: Richard J. Moore --- src/corelib/kernel/qcoreapplication.cpp | 42 +++++++++++++++++++++++++++++++++ src/corelib/kernel/qcoreapplication.h | 13 ++++++---- 2 files changed, 51 insertions(+), 4 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 05688d3ba6..1696aeb77b 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2039,9 +2039,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() @@ -2067,9 +2079,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() @@ -2089,9 +2111,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() @@ -2118,9 +2150,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() diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index b235e327e0..022ef8c0bc 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -66,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) @@ -164,6 +164,11 @@ Q_SIGNALS: #endif ); + void organizationNameChanged(); + void organizationDomainChanged(); + void applicationNameChanged(); + void applicationVersionChanged(); + protected: bool event(QEvent *); -- cgit v1.2.3 From d93b2ef968f70fe2dd66f0879cc13ad4170e8553 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 22 Dec 2012 13:10:53 -0800 Subject: Mark all qtbase headers that aren't clean QtCore has a few headers that, though public, aren't meant to be included directly. Those are the atomic headers, the three _impl.h headers and qt_windows.h. QtGui includes two OpenGL headers that don't compile on their own. Other libraries should not have headers like that (but they do, something we need to fix eventually). Change-Id: I55e4eb057748f47df927ee618f9409acbc189cc1 Reviewed-by: Sean Harmer Reviewed-by: Gunnar Sletta Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject_impl.h | 5 +++++ src/corelib/kernel/qobjectdefs_impl.h | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h index e6f924814d..0b5631f2a6 100644 --- a/src/corelib/kernel/qobject_impl.h +++ b/src/corelib/kernel/qobject_impl.h @@ -45,6 +45,11 @@ #error Do not include qobject_impl.h directly #endif +#if 0 +#pragma qt_sync_skip_header_check +#pragma qt_sync_stop_processing +#endif + QT_BEGIN_NAMESPACE diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 2d2107f666..8d85175a17 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -45,6 +45,11 @@ #error Do not include qobjectdefs_impl.h directly #endif +#if 0 +#pragma qt_sync_skip_header_check +#pragma qt_sync_stop_processing +#endif + QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 97fcf3bc987a18f32233fea550eb4a5a22e2b822 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 4 Mar 2013 10:16:42 +0100 Subject: Introducing the Qt Android port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on the Necessitas project by Bogdan Vatra. Contributors to the Qt5 project: BogDan Vatra Eskil Abrahamsen Blomfeldt hjk Oswald Buddenhagen Paul Olav Tvete Robin Burchell Samuel Rødal Yoann Lopes The full history of the Qt5 port can be found in refs/old-heads/android, SHA-1 249ca9ca2c7d876b91b31df9434dde47f9065d0d Change-Id: Iff1a7b2dbb707c986f2639e65e39ed8f22430120 Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/corelib/kernel/kernel.pri | 2 +- src/corelib/kernel/qsharedmemory_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index d2de873cef..d5a6fa6122 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -129,7 +129,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/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 #endif -- cgit v1.2.3 From 950b35cf97ad398f97883efd2a18ee97994a8a9c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 18 Jan 2013 14:39:00 +0800 Subject: Clear the current thread data for the main thread This avoids crashes accessing deleted memory when creating a QObject after the last QObject had been deleted, like a qDebug() in global destructors. ==41000== Invalid read of size 4 ==41000== at 0x5F01ED5: bool QBasicAtomicOps<4>::ref(int&) (qatomic_x86.h:208) ==41000== by 0x5F01309: QBasicAtomicInteger::ref() (qbasicatomic.h:147) ==41000== by 0x5F24051: QThreadData::ref() (qthread.cpp:100) ==41000== by 0x614A984: QObject::QObject(QObject*) (qobject.cpp:681) ==41000== Address 0x6ee73f0 is 0 bytes inside a block of size 152 free'd ==41000== at 0x4A0736C: operator delete(void*) (vg_replace_malloc.c:480) ==41000== by 0x5F240BF: QThreadData::deref() (qthread.cpp:109) ==41000== by 0x6113F6B: QCoreApplicationData::~QCoreApplicationData() (qcoreapplication.cpp:268) The comment right above the change in qthread.cpp looks eerily similar to the problem I'm trying to fix. However, the actual change that introduced the change is not in the Qt public history, so we can't know for sure what the problem was then. Change-Id: I0dba895b041fe6cf81e6f8939ca85035cd00aad1 Reviewed-by: Olivier Goffart --- src/corelib/kernel/qcoreapplication.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 1696aeb77b..46de52ec9f 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -300,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 -- cgit v1.2.3 From 6b68be9587c6d6946faff34f88d80de53f11ed86 Mon Sep 17 00:00:00 2001 From: Axel Waggershauser Date: Wed, 6 Mar 2013 17:18:48 +0100 Subject: Let QMetaObject::connectSlotsByName(o) also check for signals of o QMetaObject::connectSlotsByName(QObject* o) creates a list of all children to look for signals that match slots of o. This changeset simply adds the object o itself to that list. The motivation is to finally fix the long standing QtCreator bug QTCREATORBUG-6494. Where executing 'Go to slot...' and choosing 'accepted()' for a simple QDialog named 'MyDialog' will add a on_MyDialog_accepted() slot to MyDialog. That slot never gets connected. More details may be found in the linked QTBUG-7595. Task-number: QTBUG-7595 Task-number: QTCREATORBUG-6494 Change-Id: I35f52761791af697eabb569adb5faee6fae50638 Reviewed-by: Olivier Goffart Reviewed-by: Friedemann Kleint --- src/corelib/kernel/qobject.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c96fb446d6..617fadc1ab 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3219,6 +3219,9 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, \snippet code/src_corelib_kernel_qobject.cpp 34 + If \a object itself has a properly set object name, its own signals are also + connected to its respective slots. + \sa QObject::setObjectName() */ void QMetaObject::connectSlotsByName(QObject *o) @@ -3227,7 +3230,10 @@ void QMetaObject::connectSlotsByName(QObject *o) return; const QMetaObject *mo = o->metaObject(); Q_ASSERT(mo); - const QObjectList list = o->findChildren(QString()); + const QObjectList list = // list of all objects to look for matching signals including... + o->findChildren(QString()) // all children of 'o'... + << o; // and the object 'o' itself + for (int i = 0; i < mo->methodCount(); ++i) { QByteArray slotSignature = mo->method(i).methodSignature(); const char *slot = slotSignature.constData(); -- cgit v1.2.3 From 3372b0faa74114184afbfde20a3bc27049df2c94 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 11 Mar 2013 13:56:12 +0100 Subject: g_thread_init is deprecated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since glib 2.32 this function is just an empty body. Fix the warning and don't try to call it. There seems to be no way to disable threading in glib. Change-Id: Id30e606d341bd6ef871737275336f6c6b3b2559b Reviewed-by: Friedemann Kleint Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qeventdispatcher_glib.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp index 75cd88c456..17830868da 100644 --- a/src/corelib/kernel/qeventdispatcher_glib.cpp +++ b/src/corelib/kernel/qeventdispatcher_glib.cpp @@ -293,12 +293,14 @@ static GSourceFuncs postEventSourceFuncs = { QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context) : mainContext(context) { +#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 32 if (qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")) { static QBasicMutex mutex; QMutexLocker locker(&mutex); if (!g_thread_supported()) g_thread_init(NULL); } +#endif if (mainContext) { g_main_context_ref(mainContext); -- cgit v1.2.3 From 3c2748afd58ef84d14b028fa43d193addb1add4c Mon Sep 17 00:00:00 2001 From: Axel Waggershauser Date: Wed, 6 Mar 2013 17:44:15 +0100 Subject: Improve warning messages (and readability) of connectSlotsByName() While adding a test case for the new behavior, two issues with the connectSlotsByName implementation came up: 1. for auto-connected slots that don't exactly match a signal, a 'compatible' one is searched. There might be more than one of those. The implementation randomly picks any. 2. The "No matching signal for %s" warning gets printed even for slots that can never be connected via connectSlotsMyName anyway (e.g. "on_something"). This is inconsistent. This fixed both: an explicit warning is printed if more than one 'compatible' signal is found and the "No matching signal for %s" warning is only printed if the slot adheres to the full "on_child_signal()" naming convention. In the process I added comments and changed the code slightly to make it more readable and explicitly hint at non-obvious behavior. Change-Id: Icc8e3b9936188d2da8dfff9f0373c8e5c776eb14 Reviewed-by: Olivier Goffart Reviewed-by: Friedemann Kleint --- src/corelib/kernel/qobject.cpp | 52 ++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 12 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 617fadc1ab..3e578b36d7 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3234,38 +3234,62 @@ void QMetaObject::connectSlotsByName(QObject *o) o->findChildren(QString()) // all children of 'o'... << o; // and the object 'o' itself + // for each method/slot of o ... for (int i = 0; i < mo->methodCount(); ++i) { - QByteArray slotSignature = mo->method(i).methodSignature(); + const QByteArray slotSignature = mo->method(i).methodSignature(); const char *slot = slotSignature.constData(); Q_ASSERT(slot); + + // ...that starts with "on_", ... if (slot[0] != 'o' || slot[1] != 'n' || slot[2] != '_') continue; + + // ...we check each object in our list, ... bool foundIt = false; for(int j = 0; j < list.count(); ++j) { const QObject *co = list.at(j); - QByteArray objName = co->objectName().toLatin1(); - int len = objName.length(); - if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_') + const QByteArray coName = co->objectName().toLatin1(); + + // ...discarding those whose objectName is not fitting the pattern "on__...", ... + if (coName.isEmpty() || qstrncmp(slot + 3, coName.constData(), coName.size()) || slot[coName.size()+3] != '_') continue; + + const char *signal = slot + coName.size() + 4; // the 'signal' part of the slot name + + // ...for the presence of a matching signal "on__". const QMetaObject *smeta; - int sigIndex = co->d_func()->signalIndex(slot + len + 4, &smeta); - if (sigIndex < 0) { // search for compatible signals + int sigIndex = co->d_func()->signalIndex(signal, &smeta); + if (sigIndex < 0) { + // if no exactly fitting signal (name + complete parameter type list) could be found + // look for just any signal with the correct name and at least the slot's parameter list. + // Note: if more than one of thoses signals exist, the one that gets connected is + // chosen 'at random' (order of declaration in source file) + QList compatibleSignals; const QMetaObject *smo = co->metaObject(); - int slotlen = qstrlen(slot + len + 4) - 1; - for (int k = 0; k < QMetaObjectPrivate::absoluteSignalCount(smo); ++k) { - QMetaMethod method = QMetaObjectPrivate::signal(smo, k); - if (!qstrncmp(method.methodSignature().constData(), slot + len + 4, slotlen)) { + int sigLen = qstrlen(signal) - 1; // ignore the trailing ')' + for (int k = QMetaObjectPrivate::absoluteSignalCount(smo)-1; k >= 0; --k) { + const QMetaMethod method = QMetaObjectPrivate::signal(smo, k); + if (!qstrncmp(method.methodSignature().constData(), signal, sigLen)) { smeta = method.enclosingMetaObject(); sigIndex = k; - break; + compatibleSignals.prepend(method.methodSignature()); } } + if (compatibleSignals.size() > 1) + qWarning() << "QMetaObject::connectSlotsByName: Connecting slot" << slot + << "with the first of the following compatible signals:" << compatibleSignals; } + if (sigIndex < 0) continue; + // we connect it... if (Connection(QMetaObjectPrivate::connect(co, sigIndex, smeta, o, i))) { foundIt = true; + // ...and stop looking for further objects with the same name. + // Note: the Designer will make sure each object name is unique in the above + // 'list' but other code may create two child objects with the same name. In + // this case one is chosen 'at random'. break; } } @@ -3274,7 +3298,11 @@ void QMetaObject::connectSlotsByName(QObject *o) while (mo->method(i + 1).attributes() & QMetaMethod::Cloned) ++i; } else if (!(mo->method(i).attributes() & QMetaMethod::Cloned)) { - qWarning("QMetaObject::connectSlotsByName: No matching signal for %s", slot); + // check if the slot has the following signature: "on_..._...(..." + int iParen = slotSignature.indexOf('('); + int iLastUnderscore = slotSignature.lastIndexOf('_', iParen-1); + if (iLastUnderscore > 3) + qWarning("QMetaObject::connectSlotsByName: No matching signal for %s", slot); } } } -- cgit v1.2.3 From 203f2800c05df1e926777e025fbc1ac0824c1679 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 6 Dec 2012 21:05:34 +0100 Subject: make Q_DECLARE_TR_FUNCTIONS() compile with QT_NO_DEPRECATED Change-Id: I9cde256347e5b59f7754bc578e56c60227c926ab Reviewed-by: hjk --- src/corelib/kernel/qcoreapplication.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 022ef8c0bc..5f87820823 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -215,12 +215,19 @@ inline QString QCoreApplication::translate(const char *, const char *sourceText, } #endif +#ifdef QT_NO_DEPRECATED +# define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) +#else +# define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \ + QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = 0, int n = -1) \ + { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } +#endif + #define Q_DECLARE_TR_FUNCTIONS(context) \ public: \ static inline QString tr(const char *sourceText, const char *disambiguation = 0, int n = -1) \ { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \ - QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = 0, int n = -1) \ - { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \ + QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \ private: typedef void (*QtStartUpFunction)(); -- cgit v1.2.3 From de5562ff38e8355c0314a6f994629570146645aa Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 6 Dec 2012 21:07:39 +0100 Subject: make stubbed QCoreApplication::translate() resolve %n Change-Id: I36326d0f11e71580977d6589c9810ffa252a0fa7 Reviewed-by: hjk --- src/corelib/kernel/qcoreapplication.cpp | 13 +++++++++++++ src/corelib/kernel/qcoreapplication.h | 7 ------- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 46de52ec9f..d89df92bdb 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1781,6 +1781,19 @@ bool QCoreApplicationPrivate::isTranslatorInstalled(QTranslator *translator) && QCoreApplication::self->d_func()->translators.contains(translator); } +#else + +QString QCoreApplication::translate(const char *context, const char *sourceText, + const char *disambiguation, int n) +{ + Q_UNUSED(context) + Q_UNUSED(disambiguation) + QString ret = QString::fromUtf8(sourceText); + if (n >= 0) + ret.replace(QLatin1String("%n"), QString::number(n)); + return ret; +} + #endif //QT_NO_TRANSLATE /*! diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 5f87820823..9f9a1c14fd 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -208,13 +208,6 @@ inline bool QCoreApplication::sendEvent(QObject *receiver, QEvent *event) inline bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *event) { if (event) event->spont = true; return self ? self->notifyInternal(receiver, event) : false; } -#ifdef QT_NO_TRANSLATION -inline QString QCoreApplication::translate(const char *, const char *sourceText, const char *, int) -{ - return QString::fromUtf8(sourceText); -} -#endif - #ifdef QT_NO_DEPRECATED # define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) #else -- cgit v1.2.3 From 096e32d814ab7b15ed86fb731007c44736768e45 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 12 Mar 2013 19:38:01 +0100 Subject: simplify/fix QT_BOOTSTRAPPED-related #ifdefs don't test for building specific tools when we actually only want to know whether we are bootstrapping. so far, this was only redundant; with the upcoming change of not bootstrapping unnecessarily it would be outright broken. Change-Id: I7600d8ebb14a4194640c50035e35a04263f2ccce Reviewed-by: Joerg Bornemann --- src/corelib/kernel/qcore_mac_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 35688f7463..4211a23e0f 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -57,7 +57,7 @@ # define __IMAGECAPTURE__ #endif -#if defined(QT_BUILD_QMAKE) || defined(QT_BOOTSTRAPPED) +#if defined(QT_BOOTSTRAPPED) #include #else #include -- cgit v1.2.3 From 59fc1102f304e3d103eaa5d9cd69acb7402efc28 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 6 Dec 2012 20:02:08 +0100 Subject: add QCoreApplication to bootstrap lib this required making it compile with QT_NO_QOBJECT. of course this disables anything related to threading and event processing. needed for bootstrapping qmldevtools (qmlmin, lupdate) Change-Id: I6f8bd3996ac7b6eee49a5b8a55143d358abe35ee Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- src/corelib/kernel/qcoreapplication.cpp | 101 +++++++++++++++++++++++++--- src/corelib/kernel/qcoreapplication.h | 33 ++++++++- src/corelib/kernel/qcoreapplication_p.h | 46 +++++++++---- src/corelib/kernel/qcoreapplication_win.cpp | 8 ++- 4 files changed, 160 insertions(+), 28 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index d89df92bdb..3540e3163d 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -42,9 +42,11 @@ #include "qcoreapplication.h" #include "qcoreapplication_p.h" +#ifndef QT_NO_QOBJECT #include "qabstracteventdispatcher.h" #include "qcoreevent.h" #include "qeventloop.h" +#endif #include "qcorecmdlineargs_p.h" #include #include @@ -55,10 +57,12 @@ #include #include #include +#ifndef QT_NO_QOBJECT #include #include #include #include +#endif #include #include #include @@ -66,6 +70,7 @@ #include #include +#ifndef QT_NO_QOBJECT #if defined(Q_OS_UNIX) # if defined(Q_OS_BLACKBERRY) # include "qeventdispatcher_blackberry_p.h" @@ -78,10 +83,10 @@ # include "qeventdispatcher_unix_p.h" # endif #endif - #ifdef Q_OS_WIN # include "qeventdispatcher_win_p.h" #endif +#endif // QT_NO_QOBJECT #ifdef Q_OS_MAC # include "qcore_mac_p.h" @@ -91,6 +96,7 @@ #ifdef Q_OS_UNIX # include +# include #endif #ifdef Q_OS_VXWORKS @@ -99,6 +105,7 @@ QT_BEGIN_NAMESPACE +#ifndef QT_NO_QOBJECT class QMutexUnlocker { public: @@ -113,6 +120,7 @@ private: QMutex *mtx; }; +#endif #if defined(Q_OS_WIN) || defined(Q_OS_MAC) extern QString qAppFileName(); @@ -183,12 +191,14 @@ void QCoreApplicationPrivate::processCommandLineArguments() // Support for introspection +#ifndef QT_NO_QOBJECT QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set = { 0, 0, 0, 0 }; void qt_register_signal_spy_callbacks(const QSignalSpyCallbackSet &callback_set) { qt_signal_spy_callback_set = callback_set; } +#endif extern "C" void Q_CORE_EXPORT qt_startup_hook() { @@ -198,7 +208,9 @@ typedef QList QStartUpFuncList; Q_GLOBAL_STATIC(QStartUpFuncList, preRList) typedef QList QVFuncList; Q_GLOBAL_STATIC(QVFuncList, postRList) +#ifndef QT_NO_QOBJECT static QBasicMutex globalPreRoutinesMutex; +#endif /*! \internal @@ -269,12 +281,15 @@ void Q_CORE_EXPORT qt_call_post_routines() } +// initialized in qcoreapplication and in qtextstream autotest when setlocale is called. +static bool qt_locale_initialized = false; + +#ifndef QT_NO_QOBJECT + // app starting up if false bool QCoreApplicationPrivate::is_app_running = false; // app closing down if true bool QCoreApplicationPrivate::is_app_closing = false; -// initialized in qcoreapplication and in qtextstream autotest when setlocale is called. -static bool qt_locale_initialized = false; Q_CORE_EXPORT uint qGlobalPostedEventsCount() { @@ -282,14 +297,17 @@ Q_CORE_EXPORT uint qGlobalPostedEventsCount() return currentThreadData->postEventList.size() - currentThreadData->postEventList.startOffset; } -QCoreApplication *QCoreApplication::self = 0; QAbstractEventDispatcher *QCoreApplicationPrivate::eventDispatcher = 0; -uint QCoreApplicationPrivate::attribs = (1 << Qt::AA_SynthesizeMouseForUnhandledTouchEvents); #ifdef Q_OS_UNIX Qt::HANDLE qt_application_thread_id = 0; #endif +#endif // QT_NO_QOBJECT + +QCoreApplication *QCoreApplication::self = 0; +uint QCoreApplicationPrivate::attribs = (1 << Qt::AA_SynthesizeMouseForUnhandledTouchEvents); + struct QCoreApplicationData { QCoreApplicationData() { #ifndef QT_NO_LIBRARY @@ -341,20 +359,29 @@ struct QCoreApplicationData { Q_GLOBAL_STATIC(QCoreApplicationData, coreappdata) +#ifndef QT_NO_QOBJECT static bool quitLockRefEnabled = true; +#endif QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint flags) - : QObjectPrivate() - , argc(aargc) + : +#ifndef QT_NO_QOBJECT + QObjectPrivate(), +#endif + argc(aargc) , argv(aargv) #ifdef Q_OS_WIN , origArgc(aargc) , origArgv(new char *[aargc]) #endif , application_type(0) +#ifndef QT_NO_QOBJECT , in_exec(false) , aboutToQuitEmitted(false) , threadData_clean(false) +#else + , q_ptr(0) +#endif { app_compile_version = flags & 0xffffff; static const char *const empty = ""; @@ -362,27 +389,35 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint argc = 0; argv = (char **)∅ // ouch! careful with QCoreApplication::argv()! } +#ifdef Q_OS_WIN + qCopy(argv, argv + argc, origArgv); +#endif + +#ifndef QT_NO_QOBJECT QCoreApplicationPrivate::is_app_closing = false; -#if defined(Q_OS_UNIX) +# if defined(Q_OS_UNIX) qt_application_thread_id = QThread::currentThreadId(); -#elif defined(Q_OS_WIN) - qCopy(argv, argv + argc, origArgv); -#endif +# endif // note: this call to QThread::currentThread() may end up setting theMainThread! if (QThread::currentThread() != theMainThread) qWarning("WARNING: QApplication was not created in the main() thread."); +#endif } QCoreApplicationPrivate::~QCoreApplicationPrivate() { +#ifndef QT_NO_QOBJECT cleanupThreadData(); +#endif #ifdef Q_OS_WIN delete [] origArgv; #endif } +#ifndef QT_NO_QOBJECT + void QCoreApplicationPrivate::cleanupThreadData() { if (threadData && !threadData_clean) { @@ -455,6 +490,8 @@ void QCoreApplicationPrivate::checkReceiverThread(QObject *receiver) } #endif +#endif // QT_NO_QOBJECT + void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths() { #ifndef QT_NO_LIBRARY @@ -576,13 +613,18 @@ void QCoreApplicationPrivate::initLocale() \internal */ QCoreApplication::QCoreApplication(QCoreApplicationPrivate &p) +#ifdef QT_NO_QOBJECT + : d_ptr(&p) +#else : QObject(p, 0) +#endif { init(); // note: it is the subclasses' job to call // QCoreApplicationPrivate::eventDispatcher->startingUp(); } +#ifndef QT_NO_QOBJECT /*! Flushes the platform specific event queues. @@ -599,6 +641,7 @@ void QCoreApplication::flush() if (self && self->d_func()->eventDispatcher) self->d_func()->eventDispatcher->flush(); } +#endif /*! Constructs a Qt kernel application. Kernel applications are @@ -619,16 +662,23 @@ QCoreApplication::QCoreApplication(int &argc, char **argv , int _internal #endif ) +#ifdef QT_NO_QOBJECT + : d_ptr(new QCoreApplicationPrivate(argc, argv, _internal)) +#else : QObject(*new QCoreApplicationPrivate(argc, argv, _internal)) +#endif { init(); +#ifndef QT_NO_QOBJECT QCoreApplicationPrivate::eventDispatcher->startingUp(); +#endif } // ### move to QCoreApplicationPrivate constructor? void QCoreApplication::init() { + d_ptr->q_ptr = this; Q_D(QCoreApplication); QCoreApplicationPrivate::initLocale(); @@ -636,6 +686,7 @@ void QCoreApplication::init() Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object"); QCoreApplication::self = this; +#ifndef QT_NO_QOBJECT // use the event dispatcher created by the app programmer (if any) if (!QCoreApplicationPrivate::eventDispatcher) QCoreApplicationPrivate::eventDispatcher = d->threadData->eventDispatcher; @@ -650,17 +701,20 @@ void QCoreApplication::init() } d->threadData->eventDispatcher = QCoreApplicationPrivate::eventDispatcher; +#endif #ifndef QT_NO_LIBRARY if (coreappdata()->app_libpaths) d->appendApplicationPathToLibraryPaths(); #endif +#ifndef QT_NO_QOBJECT #if defined(Q_OS_UNIX) && !(defined(QT_NO_PROCESS)) // Make sure the process manager thread object is created in the main // thread. QProcessPrivate::initializeProcessManager(); #endif +#endif #ifdef QT_EVAL extern void qt_core_eval_init(uint); @@ -681,8 +735,10 @@ QCoreApplication::~QCoreApplication() qt_call_post_routines(); self = 0; +#ifndef QT_NO_QOBJECT QCoreApplicationPrivate::is_app_closing = true; QCoreApplicationPrivate::is_app_running = false; +#endif #if !defined(QT_NO_THREAD) // Synchronize and stop the global thread pool threads. @@ -696,10 +752,12 @@ QCoreApplication::~QCoreApplication() globalThreadPool->waitForDone(); #endif +#ifndef QT_NO_QOBJECT d_func()->threadData->eventDispatcher = 0; if (QCoreApplicationPrivate::eventDispatcher) QCoreApplicationPrivate::eventDispatcher->closingDown(); QCoreApplicationPrivate::eventDispatcher = 0; +#endif #ifndef QT_NO_LIBRARY delete coreappdata()->app_libpaths; @@ -741,6 +799,8 @@ bool QCoreApplication::testAttribute(Qt::ApplicationAttribute attribute) } +#ifndef QT_NO_QOBJECT + /*! \property QCoreApplication::quitLockEnabled @@ -1603,6 +1663,8 @@ void QCoreApplication::quit() \sa quit() */ +#endif // QT_NO_QOBJECT + #ifndef QT_NO_TRANSLATION /*! Adds the translation file \a translationFile to the list of @@ -1644,8 +1706,11 @@ bool QCoreApplication::installTranslator(QTranslator *translationFile) return false; #endif +#ifndef QT_NO_QOBJECT QEvent ev(QEvent::LanguageChange); QCoreApplication::sendEvent(self, &ev); +#endif + return true; } @@ -1667,10 +1732,12 @@ bool QCoreApplication::removeTranslator(QTranslator *translationFile) return false; QCoreApplicationPrivate *d = self->d_func(); if (d->translators.removeAll(translationFile)) { +#ifndef QT_NO_QOBJECT if (!self->closingDown()) { QEvent ev(QEvent::LanguageChange); QCoreApplication::sendEvent(self, &ev); } +#endif return true; } return false; @@ -2058,8 +2125,10 @@ void QCoreApplication::setOrganizationName(const QString &orgName) if (coreappdata()->orgName == orgName) return; coreappdata()->orgName = orgName; +#ifndef QT_NO_QOBJECT if (QCoreApplication::self) emit QCoreApplication::self->organizationNameChanged(); +#endif } QString QCoreApplication::organizationName() @@ -2096,8 +2165,10 @@ void QCoreApplication::setOrganizationDomain(const QString &orgDomain) if (coreappdata()->orgDomain == orgDomain) return; coreappdata()->orgDomain = orgDomain; +#ifndef QT_NO_QOBJECT if (QCoreApplication::self) emit QCoreApplication::self->organizationDomainChanged(); +#endif } QString QCoreApplication::organizationDomain() @@ -2128,8 +2199,10 @@ void QCoreApplication::setApplicationName(const QString &application) if (coreappdata()->application == application) return; coreappdata()->application = application; +#ifndef QT_NO_QOBJECT if (QCoreApplication::self) emit QCoreApplication::self->applicationNameChanged(); +#endif } QString QCoreApplication::applicationName() @@ -2167,8 +2240,10 @@ void QCoreApplication::setApplicationVersion(const QString &version) if (coreappdata()->applicationVersion == version) return; coreappdata()->applicationVersion = version; +#ifndef QT_NO_QOBJECT if (QCoreApplication::self) emit QCoreApplication::self->applicationVersionChanged(); +#endif } QString QCoreApplication::applicationVersion() @@ -2317,6 +2392,8 @@ void QCoreApplication::removeLibraryPath(const QString &path) #endif //QT_NO_LIBRARY +#ifndef QT_NO_QOBJECT + /*! Installs an event filter \a filterObj for all native events received by the application in the main thread. @@ -2412,6 +2489,8 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc mainThread->setEventDispatcher(eventDispatcher); } +#endif // QT_NO_QOBJECT + /*! \macro Q_COREAPP_STARTUP_FUNCTION(QtStartUpFunction ptr) \since 5.1 diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 9f9a1c14fd..ae17aeec0e 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -42,13 +42,21 @@ #ifndef QCOREAPPLICATION_H #define QCOREAPPLICATION_H +#include +#include +#ifndef QT_NO_QOBJECT #include #include #include +#else +#include +#endif +#ifndef QT_NO_QOBJECT #if defined(Q_OS_WIN) && !defined(tagMSG) typedef struct tagMSG MSG; #endif +#endif QT_BEGIN_NAMESPACE @@ -63,14 +71,19 @@ class QAbstractNativeEventFilter; #define qApp QCoreApplication::instance() -class Q_CORE_EXPORT QCoreApplication : public QObject +class Q_CORE_EXPORT QCoreApplication +#ifndef QT_NO_QOBJECT + : public QObject +#endif { +#ifndef QT_NO_QOBJECT Q_OBJECT 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) +#endif Q_DECLARE_PRIVATE(QCoreApplication) public: @@ -101,6 +114,7 @@ public: static QCoreApplication *instance() { return self; } +#ifndef QT_NO_QOBJECT static int exec(); static void processEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents); static void processEvents(QEventLoop::ProcessEventsFlags flags, int maxtime); @@ -118,6 +132,7 @@ public: static bool startingUp(); static bool closingDown(); +#endif static QString applicationDirPath(); static QString applicationFilePath(); @@ -146,6 +161,7 @@ public: { return translate(context, key, disambiguation, n); } #endif +#ifndef QT_NO_QOBJECT static void flush(); void installNativeEventFilter(QAbstractNativeEventFilter *filterObj); @@ -173,13 +189,20 @@ protected: bool event(QEvent *); virtual bool compressEvent(QEvent *, QObject *receiver, QPostEventList *); +#endif // QT_NO_QOBJECT protected: QCoreApplication(QCoreApplicationPrivate &p); +#ifdef QT_NO_QOBJECT + QScopedPointer d_ptr; +#endif + private: +#ifndef QT_NO_QOBJECT static bool sendSpontaneousEvent(QObject *receiver, QEvent *event); bool notifyInternal(QObject *receiver, QEvent *event); +#endif void init(); @@ -187,7 +210,6 @@ private: Q_DISABLE_COPY(QCoreApplication) - friend class QEventDispatcherUNIXPrivate; friend class QApplication; friend class QApplicationPrivate; friend class QGuiApplication; @@ -196,17 +218,22 @@ private: friend class QWidget; friend class QWidgetWindow; friend class QWidgetPrivate; +#ifndef QT_NO_QOBJECT + friend class QEventDispatcherUNIXPrivate; friend class QCocoaEventDispatcherPrivate; friend bool qt_sendSpontaneousEvent(QObject*, QEvent*); +#endif friend Q_CORE_EXPORT QString qAppName(); friend class QClassFactory; }; +#ifndef QT_NO_QOBJECT inline bool QCoreApplication::sendEvent(QObject *receiver, QEvent *event) { if (event) event->spont = false; return self ? self->notifyInternal(receiver, event) : false; } inline bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *event) { if (event) event->spont = true; return self ? self->notifyInternal(receiver, event) : false; } +#endif #ifdef QT_NO_DEPRECATED # define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) @@ -237,10 +264,12 @@ Q_CORE_EXPORT QString qAppName(); // get application name } \ Q_CONSTRUCTOR_FUNCTION(AFUNC ## _ctor_function) +#ifndef QT_NO_QOBJECT #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 &); #endif +#endif QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 36ba0663b7..563a3b2093 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -56,7 +56,9 @@ #include "QtCore/qcoreapplication.h" #include "QtCore/qtranslator.h" #include "QtCore/qsettings.h" +#ifndef QT_NO_QOBJECT #include "private/qobject_p.h" +#endif QT_BEGIN_NAMESPACE @@ -64,7 +66,10 @@ typedef QList QTranslatorList; class QAbstractEventDispatcher; -class Q_CORE_EXPORT QCoreApplicationPrivate : public QObjectPrivate +class Q_CORE_EXPORT QCoreApplicationPrivate +#ifndef QT_NO_QOBJECT + : public QObjectPrivate +#endif { Q_DECLARE_PUBLIC(QCoreApplication) @@ -77,23 +82,27 @@ public: QCoreApplicationPrivate(int &aargc, char **aargv, uint flags); ~QCoreApplicationPrivate(); + QString appName() const; + +#ifdef Q_OS_MAC + static QString macMenuBarName(); +#endif + + static void initLocale(); + + static bool checkInstance(const char *method); + +#ifndef QT_NO_QOBJECT bool sendThroughApplicationEventFilters(QObject *, QEvent *); bool sendThroughObjectEventFilters(QObject *, QEvent *); bool notify_helper(QObject *, QEvent *); - QString appName() const; virtual void createEventDispatcher(); static void removePostedEvent(QEvent *); #ifdef Q_OS_WIN static void removePostedTimerEvent(QObject *object, int timerId); #endif -#ifdef Q_OS_MAC - static QString macMenuBarName(); -#endif - - static void initLocale(); - QAtomicInt quitLockRef; void ref(); void deref(); @@ -104,12 +113,14 @@ public: static QThread *theMainThread; static QThread *mainThread(); - static bool checkInstance(const char *method); static void sendPostedEvents(QObject *receiver, int event_type, QThreadData *data); #if !defined (QT_NO_DEBUG) || defined (QT_MAC_FRAMEWORK_BUILD) void checkReceiverThread(QObject *receiver); #endif + void cleanupThreadData(); +#endif // QT_NO_QOBJECT + int &argc; char **argv; #ifdef Q_OS_WIN @@ -117,24 +128,27 @@ public: char **origArgv; // store unmodified arguments for QCoreApplication::arguments() #endif void appendApplicationPathToLibraryPaths(void); - void cleanupThreadData(); #ifndef QT_NO_TRANSLATION QTranslatorList translators; + + static bool isTranslatorInstalled(QTranslator *translator); #endif + uint application_type; - bool in_exec; - bool aboutToQuitEmitted; - bool threadData_clean; QString cachedApplicationDirPath; QString cachedApplicationFilePath; - static bool isTranslatorInstalled(QTranslator *translator); +#ifndef QT_NO_QOBJECT + bool in_exec; + bool aboutToQuitEmitted; + bool threadData_clean; static QAbstractEventDispatcher *eventDispatcher; static bool is_app_running; static bool is_app_closing; +#endif static uint attribs; static inline bool testAttribute(uint flag) { return attribs & (1 << flag); } @@ -143,6 +157,10 @@ public: void processCommandLineArguments(); QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging. inline QString qmljsDebugArgumentsString() { return qmljs_debug_arguments; } + +#ifdef QT_NO_QOBJECT + QCoreApplication *q_ptr; +#endif }; QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 3cb89e8fcd..93e45d3984 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -43,10 +43,12 @@ #include "qcoreapplication_p.h" #include "qstringlist.h" #include "qvector.h" -#include "qmutex.h" #include "qfileinfo.h" #include "qcorecmdlineargs_p.h" +#ifndef QT_NO_QOBJECT +#include "qmutex.h" #include +#endif #include #include @@ -157,6 +159,8 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, Q_UNUSED(prevInstance); } +#ifndef QT_NO_QOBJECT + void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerId) { QThreadData *data = object->d_func()->threadData; @@ -996,4 +1000,6 @@ QDebug operator<<(QDebug dbg, const MSG &msg) } #endif +#endif // QT_NO_QOBJECT + QT_END_NAMESPACE -- cgit v1.2.3 From b11317a64339f5a4bcffc8234ecaf15c7fb416f2 Mon Sep 17 00:00:00 2001 From: Axel Waggershauser Date: Fri, 15 Mar 2013 00:42:15 +0100 Subject: Whitespace cleanup: remove trailing whitespace Remove all trailing whitespace from the following list of files: *.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README excluding 3rdparty, test-data and auto generated code. Note A): the only non 3rdparty c++-files that still have trailing whitespace after this change are: * src/corelib/codecs/cp949codetbl_p.h * src/corelib/codecs/qjpunicode.cpp * src/corelib/codecs/qbig5codec.cpp * src/corelib/xml/qxmlstream_p.h * src/tools/qdoc/qmlparser/qqmljsgrammar.cpp * src/tools/uic/ui4.cpp * tests/auto/other/qtokenautomaton/tokenizers/* * tests/benchmarks/corelib/tools/qstring/data.cpp * util/lexgen/tokenizer.cpp Note B): in about 30 files some overlapping 'leading tab' and 'TAB character in non-leading whitespace' issues have been fixed to make the sanity bot happy. Plus some general ws-fixes here and there as asked for during review. Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d Reviewed-by: Oswald Buddenhagen --- src/corelib/kernel/qfunctions_nacl.h | 2 +- src/corelib/kernel/qmath.qdoc | 6 +++--- src/corelib/kernel/qmetaobject.cpp | 10 +++++----- src/corelib/kernel/qobject.cpp | 8 ++++---- src/corelib/kernel/qsystemerror_p.h | 6 +++--- src/corelib/kernel/qsystemsemaphore_win.cpp | 2 +- src/corelib/kernel/qvariant_p.h | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qfunctions_nacl.h b/src/corelib/kernel/qfunctions_nacl.h index bc44a21cb8..f40807a0d9 100644 --- a/src/corelib/kernel/qfunctions_nacl.h +++ b/src/corelib/kernel/qfunctions_nacl.h @@ -67,7 +67,7 @@ int pthread_cancel(pthread_t thread); int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched); -int pthread_attr_getinheritsched(const pthread_attr_t *attr, +int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched); // event dispatcher, select diff --git a/src/corelib/kernel/qmath.qdoc b/src/corelib/kernel/qmath.qdoc index 448b167662..06d8db9277 100644 --- a/src/corelib/kernel/qmath.qdoc +++ b/src/corelib/kernel/qmath.qdoc @@ -25,7 +25,7 @@ ** ****************************************************************************/ -/*! +/*! \headerfile \title Math Functions \ingroup funclists @@ -35,11 +35,11 @@ /*! \fn int qCeil(qreal v) - Return the ceiling of the value \a v. + Return the ceiling of the value \a v. The ceiling is the smallest integer that is not less than \a v. For example, if \a v is 41.2, then the ceiling is 42. - + \relates \sa qFloor() */ diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 14d96e96fd..4399349352 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1001,7 +1001,7 @@ int QMetaObject::indexOfProperty(const char *name) const Q_ASSERT(priv(this->d.data)->revision >= 3); if (priv(this->d.data)->flags & DynamicMetaObject) { - QAbstractDynamicMetaObject *me = + QAbstractDynamicMetaObject *me = const_cast(static_cast(this)); return me->createProperty(name, 0); @@ -2041,8 +2041,8 @@ QMetaMethod QMetaMethod::fromSignalImpl(const QMetaObject *metaObject, void **si \snippet code/src_corelib_kernel_qmetaobject.cpp 8 - QMetaObject::normalizedSignature() is used here to ensure that the format - of the signature is what invoke() expects. E.g. extra whitespace is + QMetaObject::normalizedSignature() is used here to ensure that the format + of the signature is what invoke() expects. E.g. extra whitespace is removed. If the "compute" slot does not take exactly one QString, one int @@ -2970,7 +2970,7 @@ QMetaMethod QMetaProperty::notifySignal() const { int id = notifySignalIndex(); if (id != -1) - return mobj->method(id); + return mobj->method(id); else return QMetaMethod(); } @@ -2978,7 +2978,7 @@ QMetaMethod QMetaProperty::notifySignal() const /*! \since 4.6 - Returns the index of the property change notifying signal if one was + Returns the index of the property change notifying signal if one was specified, otherwise returns -1. \sa hasNotifySignal() diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 3e578b36d7..a60deefe90 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -927,7 +927,7 @@ QObjectPrivate::Connection::~Connection() \relates QObject Returns the given \a object cast to type T if the object is of type - T (or of a subclass); otherwise returns 0. If \a object is 0 then + T (or of a subclass); otherwise returns 0. If \a object is 0 then it will also return 0. The class T must inherit (directly or indirectly) QObject and be @@ -3089,8 +3089,8 @@ bool QMetaObject::disconnect(const QObject *sender, int signal_index, /*! \internal -Disconnect a single signal connection. If QMetaObject::connect() has been called -multiple times for the same sender, signal_index, receiver and method_index only +Disconnect a single signal connection. If QMetaObject::connect() has been called +multiple times for the same sender, signal_index, receiver and method_index only one of these connections will be removed. */ bool QMetaObject::disconnectOne(const QObject *sender, int signal_index, @@ -3368,7 +3368,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i return; if (sender->d_func()->declarativeData && QAbstractDeclarativeData::signalEmitted) - QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender, + QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender, signal_index, argv); void *empty_argv[] = { 0 }; diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h index 94bfb5deb4..4b46011129 100644 --- a/src/corelib/kernel/qsystemerror_p.h +++ b/src/corelib/kernel/qsystemerror_p.h @@ -66,14 +66,14 @@ public: StandardLibraryError, NativeError }; - + inline QSystemError(int error, ErrorScope scope); inline QSystemError(); - + QString toString(); inline ErrorScope scope(); inline int error(); - + //data members int errorCode; ErrorScope errorScope; diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp index 6b064c1d52..835a9fde5b 100644 --- a/src/corelib/kernel/qsystemsemaphore_win.cpp +++ b/src/corelib/kernel/qsystemsemaphore_win.cpp @@ -46,7 +46,7 @@ #include QT_BEGIN_NAMESPACE - + #ifndef QT_NO_SYSTEMSEMAPHORE QSystemSemaphorePrivate::QSystemSemaphorePrivate() : diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index e7940e0039..04b9d92f55 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -150,7 +150,7 @@ inline void v_construct(QVariant::Private *x, const T &t) template inline void v_clear(QVariant::Private *d, T* = 0) { - + if (!QVariantIntegrator::CanUseInternalSpace) { //now we need to cast //because QVariant::PrivateShared doesn't have a virtual destructor -- cgit v1.2.3 From d1b4857d1718ef50dba64c8700253fed5d187ab2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 10 Mar 2013 13:34:52 -0700 Subject: Make sure that we #include qconfig.h before testing for features. This is mandatory in public headers (qiodevice.h, qopengl*, etc.), but it's a good idea even in private headers, in case someone includes that header first somewhere. In particular, all platformsupport API is private. Change-Id: If287baa5d9ed14e93c1666efa0e6332c4c1cd9a4 Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- src/corelib/kernel/qfunctions_nacl.h | 2 ++ src/corelib/kernel/qfunctions_vxworks.h | 3 +++ src/corelib/kernel/qfunctions_wince.h | 3 +++ src/corelib/kernel/qtimer.h | 2 ++ 4 files changed, 10 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qfunctions_nacl.h b/src/corelib/kernel/qfunctions_nacl.h index f40807a0d9..c15b9756d0 100644 --- a/src/corelib/kernel/qfunctions_nacl.h +++ b/src/corelib/kernel/qfunctions_nacl.h @@ -42,6 +42,8 @@ #ifndef QFUNCTIONS_NACL_H #define QFUNCTIONS_NACL_H +#include + #ifdef Q_OS_NACL #include diff --git a/src/corelib/kernel/qfunctions_vxworks.h b/src/corelib/kernel/qfunctions_vxworks.h index 02c599f490..e33401a86a 100644 --- a/src/corelib/kernel/qfunctions_vxworks.h +++ b/src/corelib/kernel/qfunctions_vxworks.h @@ -41,6 +41,9 @@ #ifndef QFUNCTIONS_VXWORKS_H #define QFUNCTIONS_VXWORKS_H + +#include + #ifdef Q_OS_VXWORKS #include diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h index 4eeb9cff6a..ab7bbe3f99 100644 --- a/src/corelib/kernel/qfunctions_wince.h +++ b/src/corelib/kernel/qfunctions_wince.h @@ -41,6 +41,9 @@ #ifndef QFUNCTIONS_WINCE_H #define QFUNCTIONS_WINCE_H + +#include + #ifdef Q_OS_WINCE #include #include diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 34bfff9089..3484f4dba8 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -42,6 +42,8 @@ #ifndef QTIMER_H #define QTIMER_H +#include + #ifndef QT_NO_QOBJECT #include // conceptual inheritance -- cgit v1.2.3 From e66159cfc7f78b8ad617175bbef6b70edbf9da6b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 3 Mar 2013 17:22:26 +0100 Subject: Mark QtPrivate::ApplyReturnType constructor as explicit. Else, the operator,(T, ApplyReturnType) is sometimes chosen if a pointer is passed, and that is breaking some decltype expressions. (such as the one in ComputeFunctorArgumentCount in the next patch) Change-Id: Ic203bbb1a8f5abbebb3b11786454807aa20be5fd Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobjectdefs_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 959a255389..46a6eab253 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -93,7 +93,7 @@ namespace QtPrivate { template struct ApplyReturnValue { void *data; - ApplyReturnValue(void *data_) : data(data_) {} + explicit ApplyReturnValue(void *data_) : data(data_) {} }; template void operator,(const T &value, const ApplyReturnValue &container) { -- cgit v1.2.3 From bc98bba2f302922761209c0e91485e809354abc1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 1 Mar 2013 10:18:36 +0100 Subject: Support connection to functor with multiple operator() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When variadic templates and decltype are supported, detect the best overload of operator() to call. Currently, the code takes the type of the operator(), which requires that the functor only has one, and that it has no template parameter. This feature is required if we want to connect to c++1y generic lambda (N3418) Change-Id: Ifa957da6955ea39ab804b58f320da9f98ff47d63 Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qobject.h | 34 ++++++++++++++++++++++++++++----- src/corelib/kernel/qobjectdefs_impl.h | 36 ++++++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 6 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 7beaa32855..aaa09fac50 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Olivier Goffart ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -265,27 +266,50 @@ public: static inline typename QtPrivate::QEnableIf::ArgumentCount == -1, QMetaObject::Connection>::Type connect(const typename QtPrivate::FunctionPointer::Object *sender, Func1 signal, Func2 slot) { +#if defined (Q_COMPILER_DECLTYPE) && defined (Q_COMPILER_VARIADIC_TEMPLATES) + typedef QtPrivate::FunctionPointer SignalType; + const int FunctorArgumentCount = QtPrivate::ComputeFunctorArgumentCount::Value; + + Q_STATIC_ASSERT_X((FunctorArgumentCount >= 0), + "Signal and slot arguments are not compatible."); + const int SlotArgumentCount = (FunctorArgumentCount >= 0) ? FunctorArgumentCount : 0; + typedef typename QtPrivate::FunctorReturnType::Value>::Value SlotReturnType; +#else + // Without variadic template, we don't detect the best overload of operator(). We just + // assume there is only one simple operator() and connect to &Func2::operator() + + /* If you get an error such as: + couldn't deduce template parameter 'Func2Operator' + or + cannot resolve address of overloaded function + It means the functor does not have a single operator(). + Functors with overloaded or templated operator() are only supported if the compiler supports + C++11 variadic templates + */ #ifndef Q_COMPILER_DECLTYPE //Workaround the lack of decltype using another function as indirection return connect_functor(sender, signal, slot, &Func2::operator()); } template static inline QMetaObject::Connection connect_functor(const QObject *sender, Func1 signal, Func2 slot, Func2Operator) { typedef QtPrivate::FunctionPointer SlotType ; #else - typedef QtPrivate::FunctionPointer SlotType ; #endif typedef QtPrivate::FunctionPointer SignalType; + typedef typename SlotType::ReturnType SlotReturnType; + const int SlotArgumentCount = SlotType::ArgumentCount; - Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount), + Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= SlotArgumentCount, "The slot requires more arguments than the signal provides."); Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments::value), "Signal and slot arguments are not compatible."); - Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible::value), +#endif + + Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible::value), "Return type of the slot is not compatible with the return type of the signal."); return connectImpl(sender, reinterpret_cast(&signal), sender, 0, - new QtPrivate::QFunctorSlotObject::Value, + new QtPrivate::QFunctorSlotObject::Value, typename SignalType::ReturnType>(slot), Qt::DirectConnection, 0, &SignalType::Object::staticMetaObject); } diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 46a6eab253..4f44d9204e 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Olivier Goffart ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -597,10 +598,43 @@ namespace QtPrivate { enum { value = AreArgumentsCompatible::Type, typename RemoveConstRef::Type>::value && CheckCompatibleArguments, List>::value }; }; +#endif + +#if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_VARIADIC_TEMPLATES) + /* + Find the maximum number of arguments a functor object can take and be still compatible with + the arguments from the signal. + Value is the number of arguments, or -1 if nothing matches. + */ + template struct ComputeFunctorArgumentCount; + + template struct ComputeFunctorArgumentCountHelper + { enum { Value = -1 }; }; + template + struct ComputeFunctorArgumentCountHelper, false> + : ComputeFunctorArgumentCount, sizeof...(ArgList)>::Value> {}; + + template struct ComputeFunctorArgumentCount> + { + template static D dummy(); + template static auto test(F f) -> decltype(((f.operator()((dummy())...)), int())); + static char test(...); + enum { + Ok = sizeof(test(dummy())) == sizeof(int), + Value = Ok ? sizeof...(ArgList) : int(ComputeFunctorArgumentCountHelper, Ok>::Value) + }; + }; + /* get the return type of a functor, given the signal argument list */ + template struct FunctorReturnType; + template struct FunctorReturnType> { + template static D dummy(); + typedef decltype(dummy().operator()((dummy())...)) Value; + }; #endif -} +} QT_END_NAMESPACE -- cgit v1.2.3 From 51ccd1ef8f9e51a794828598ed45803bb01fa69f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 4 Mar 2013 13:09:51 +0100 Subject: Document restrictions on the new connection syntax ... when the compiler do not support variadic template Change-Id: Iec84cad8ece2fc28b0c224872fdd90d30ae60fc9 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index a60deefe90..1312e64d8b 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4185,6 +4185,9 @@ void qDeleteInEventHandler(QObject *o) \snippet code/src_corelib_kernel_qobject.cpp 25 make sure to declare the argument type with Q_DECLARE_METATYPE + + \note The number of arguments in the signal or slot are limited to 6 if + the compiler does not support C++11 variadic templates. */ @@ -4215,6 +4218,10 @@ void qDeleteInEventHandler(QObject *o) \snippet code/src_corelib_kernel_qobject.cpp 46 The connection will automatically disconnect if the sender is destroyed. + + \note If the compiler does not support C++11 variadic templates, the number + of arguments in the signal or slot are limited to 6, and the functor object + must not have an overloaded or templated operator(). */ /** -- cgit v1.2.3