From 3b514f853595c686d4ed8830567c1f27ea533faf Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Fri, 4 Jan 2019 16:01:46 +0100 Subject: qtlite: Fix build libs with -no-feature-regularexpression Change-Id: I427ff1f8f4986fbf466aba60a9d3de614c1e006f Reviewed-by: Lars Knoll --- src/corelib/kernel/qvariant.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 6541b97595..090436a3c7 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1052,11 +1052,13 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return false; #ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(regularexpression) case QMetaType::QRegularExpression: if (d->type != QMetaType::QCborValue || !v_cast(d)->isRegularExpression()) return false; *static_cast(result) = v_cast(d)->toRegularExpression(); break; +#endif case QMetaType::QJsonValue: switch (d->type) { case QMetaType::Nullptr: @@ -1232,9 +1234,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QVariant::Url: *static_cast(result) = QCborValue(*v_cast(d)); break; +#if QT_CONFIG(regularexpression) case QVariant::RegularExpression: *static_cast(result) = QCborValue(*v_cast(d)); break; +#endif case QVariant::Uuid: *static_cast(result) = QCborValue(*v_cast(d)); break; -- cgit v1.2.3 From ddb5d390450de25e510c72b17ed8124b9186a736 Mon Sep 17 00:00:00 2001 From: Andreas Hartmetz Date: Tue, 5 Feb 2019 14:39:41 +0100 Subject: QMetaObject::Connection overview documentation improvements Try to better describe what it is and what it does. Also mention its strongest use case. Change-Id: Ib5c3e8a3c9b96169c139c5d7e8995a6a49d7d5e1 Reviewed-by: Mitch Curtis Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 42c39f18e3..b4e885e407 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -5070,11 +5070,14 @@ bool QObjectPrivate::disconnect(const QObject *sender, int signal_index, void ** /*! \class QMetaObject::Connection \inmodule QtCore - Represents a handle to a signal-slot connection. - It can be used to disconnect that connection, or check if - the connection was successful + Represents a handle to a signal-slot (or signal-functor) connection. - \sa QObject::disconnect() + It can be used to check if the connection is valid and to disconnect it using + QObject::disconnect(). For a signal-functor connection without a context object, + it is the only way to selectively disconnect that connection. + + As Connection is just a handle, the underlying signal-slot connection is unaffected + when Connection is destroyed or reassigned. */ /*! -- cgit v1.2.3 From ae94ab264ba29a41beac81a61fb39c0d4f669270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 12 Feb 2019 14:04:04 +0100 Subject: Add developer documentation on how to debug missing auto-release pools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie3942210ab5bafea22d65d6f7c9a099e40ee6b73 Reviewed-by: Morten Johan Sørvig --- src/corelib/kernel/qcore_mac_objc.mm | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index bc23e821fd..140c60a080 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -129,6 +129,16 @@ QT_USE_NAMESPACE QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAutoReleasePoolTracker); QT_BEGIN_NAMESPACE + +/* + Manages a scoped auto-release pool. + + To track autoreleases without any pools in place, such as in main() + before the runloop has started, export OBJC_DEBUG_MISSING_POOLS=YES + and break in objc_autoreleaseNoPool, e.g.: + + br set -n objc_autoreleaseNoPool -c "[((NSObject*)$r14) class] == [QNSWindow class]" +*/ QMacAutoReleasePool::QMacAutoReleasePool() : pool([[NSAutoreleasePool alloc] init]) { -- cgit v1.2.3 From e1d42a40a2fabefdc57c40e25dbf7b923332ba5d Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 11 Feb 2019 00:02:37 +0100 Subject: Add missing "override" specifiers Annotate this function with 'override' or (rarely) 'final' [modernize-use-override] Change-Id: If31ab03b46f885e4984ba3aaaf1ad8d46aae9d9c Reviewed-by: Friedemann Kleint --- src/corelib/kernel/qeventdispatcher_win_p.h | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index a7ed8dda8a..707bc79407 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -80,31 +80,31 @@ public: explicit QEventDispatcherWin32(QObject *parent = 0); ~QEventDispatcherWin32(); - bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags); - bool hasPendingEvents(); + bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags) override; + bool hasPendingEvents() override; - void registerSocketNotifier(QSocketNotifier *notifier); - void unregisterSocketNotifier(QSocketNotifier *notifier); + void registerSocketNotifier(QSocketNotifier *notifier) override; + void unregisterSocketNotifier(QSocketNotifier *notifier) override; - void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object); - bool unregisterTimer(int timerId); - bool unregisterTimers(QObject *object); - QList registeredTimers(QObject *object) const; + void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) override; + bool unregisterTimer(int timerId) override; + bool unregisterTimers(QObject *object) override; + QList registeredTimers(QObject *object) const override; - bool registerEventNotifier(QWinEventNotifier *notifier); - void unregisterEventNotifier(QWinEventNotifier *notifier); + bool registerEventNotifier(QWinEventNotifier *notifier) override; + void unregisterEventNotifier(QWinEventNotifier *notifier) override; void activateEventNotifiers(); - int remainingTime(int timerId); + int remainingTime(int timerId) override; - void wakeUp(); - void interrupt(); - void flush(); + void wakeUp() override; + void interrupt() override; + void flush() override; - void startingUp(); - void closingDown(); + void startingUp() override; + void closingDown() override; - bool event(QEvent *e); + bool event(QEvent *e) override; HWND internalHwnd(); -- cgit v1.2.3 From 6c18f86af7affc60a571c65f0b335d7ee8947100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 12 Feb 2019 13:02:48 +0100 Subject: Track call sites of QMacAutoReleasePools for debugging pool usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Printing pools by calling [NSAutoreleasePool showPools] will now give a more detailed view of where the various pools in the stack were created, eg: AUTORELEASE POOLS for thread 0x1000be5c0 17 releases pending. [0x107802000] ................ PAGE (hot) (cold) [0x107802038] ################ POOL 0x107802038 [0x107802040] 0x107791c70 ^-- allocated in function: main [0x107802048] ################ POOL 0x107802048 [0x107802050] 0x1073b2e80 ^-- allocated in function: QCocoaWindow::initialize() [0x107802058] 0x107111ed0 NSCompositeAppearance [0x107802060] 0x107111ed0 NSCompositeAppearance [0x107802068] 0x107111ed0 NSCompositeAppearance [0x107802070] 0x1073bbe10 __NSCFString [0x107802078] 0x1073bbde0 _NSViewBackingLayer [0x107802080] 0x1073bc100 NSWeakObjectValue [0x107802088] 0x1073bbe40 QNSView [0x107802090] 0x1073bbe40 QNSView [0x107802098] 0x107111ed0 NSCompositeAppearance [0x1078020a0] 0x107111ed0 NSCompositeAppearance [0x1078020a8] 0x1073bbe40 QNSView [0x1078020b0] ################ POOL 0x1078020b0 [0x1078020b8] 0x1073bbe30 ^-- allocated in function: QCocoaWindow::recreateWindowIfNeeded() Change-Id: I97faf30db5835fea2f05320435b1b8c334a478d1 Reviewed-by: Morten Johan Sørvig Reviewed-by: Tor Arne Vestbø --- src/corelib/kernel/qcore_mac_objc.mm | 59 +++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 11 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index 140c60a080..4550891e2a 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -48,6 +48,11 @@ #include #endif +#include +#include +#include +#include + #include QT_BEGIN_NAMESPACE @@ -127,22 +132,54 @@ QT_USE_NAMESPACE } @end QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAutoReleasePoolTracker); -QT_BEGIN_NAMESPACE - -/* - Manages a scoped auto-release pool. - - To track autoreleases without any pools in place, such as in main() - before the runloop has started, export OBJC_DEBUG_MISSING_POOLS=YES - and break in objc_autoreleaseNoPool, e.g.: +QT_BEGIN_NAMESPACE - br set -n objc_autoreleaseNoPool -c "[((NSObject*)$r14) class] == [QNSWindow class]" -*/ QMacAutoReleasePool::QMacAutoReleasePool() : pool([[NSAutoreleasePool alloc] init]) { - [[[QMacAutoReleasePoolTracker alloc] initWithPool: + Class trackerClass = [QMacAutoReleasePoolTracker class]; + +#ifdef QT_DEBUG + void *poolFrame = nullptr; + if (__builtin_available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)) { + void *frame; + if (backtrace_from_fp(__builtin_frame_address(0), &frame, 1)) + poolFrame = frame; + } else { + static const int maxFrames = 3; + void *callstack[maxFrames]; + if (backtrace(callstack, maxFrames) == maxFrames) + poolFrame = callstack[maxFrames - 1]; + } + + if (poolFrame) { + Dl_info info; + if (dladdr(poolFrame, &info) && info.dli_sname) { + const char *symbolName = info.dli_sname; + if (symbolName[0] == '_') { + int status; + if (char *demangled = abi::__cxa_demangle(info.dli_sname, nullptr, 0, &status)) + symbolName = demangled; + } + + char *className = nullptr; + asprintf(&className, " ^-- allocated in function: %s", symbolName); + + if (Class existingClass = objc_getClass(className)) + trackerClass = existingClass; + else + trackerClass = objc_duplicateClass(trackerClass, className, 0); + + free(className); + + if (symbolName != info.dli_sname) + free((char*)symbolName); + } + } +#endif + + [[[trackerClass alloc] initWithPool: reinterpret_cast(&pool)] autorelease]; } -- cgit v1.2.3 From 91deac4a65a31141764cd2739066166475f024d8 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 15 Feb 2019 21:21:20 +0100 Subject: QtCore: replace null and nullptr with \nullptr in documentation Replace null and '\c nullptr' with \nullptr in the documentation. Change-Id: Ib9e0cfc2eb2830b213e6523773603d56180b0998 Reviewed-by: Friedemann Kleint --- src/corelib/kernel/qcoreapplication.cpp | 19 ++++++++++--------- src/corelib/kernel/qmetaobject.cpp | 2 +- src/corelib/kernel/qmetatype.cpp | 2 +- src/corelib/kernel/qobject.cpp | 4 ++-- src/corelib/kernel/qvariant.cpp | 4 ++-- 5 files changed, 16 insertions(+), 15 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e5098b8415..db66157a0e 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1636,14 +1636,15 @@ bool QCoreApplication::compressEvent(QEvent *event, QObject *receiver, QPostEven /*! Immediately dispatches all events which have been previously queued - with QCoreApplication::postEvent() and which are for the object \a receiver - and have the event type \a event_type. + with QCoreApplication::postEvent() and which are for the object \a + receiver and have the event type \a event_type. Events from the window system are \e not dispatched by this function, but by processEvents(). - If \a receiver is null, the events of \a event_type are sent for all - objects. If \a event_type is 0, all the events are sent for \a receiver. + If \a receiver is \nullptr, the events of \a event_type are sent for + all objects. If \a event_type is 0, all the events are sent for + \a receiver. \note This method must be called from the thread in which its QObject parameter, \a receiver, lives. @@ -1824,10 +1825,10 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type call it, be aware that killing events may cause \a receiver to break one or more invariants. - If \a receiver is null, the events of \a eventType are removed for - all objects. If \a eventType is 0, all the events are removed for - \a receiver. You should never call this function with \a eventType - of 0. + If \a receiver is \nullptr, the events of \a eventType are removed + for all objects. If \a eventType is 0, all the events are removed + for \a receiver. You should never call this function with \a + eventType of 0. \threadsafe */ @@ -2140,7 +2141,7 @@ static void replacePercentN(QString *result, int n) \a disambiguation is an identifying string, for when the same \a sourceText is used in different roles within the same context. By - default, it is null. + default, it is \nullptr. See the \l QTranslator and \l QObject::tr() documentation for more information about contexts, disambiguations and comments. diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 8082b7fe9b..c15a9f7b0f 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -3522,7 +3522,7 @@ bool QMetaProperty::isStored(const QObject *object) const false. e.g., the \c text property is the \c USER editable property of a QLineEdit. - If \a object is null, the function returns \c false if the \c + If \a object is \nullptr, the function returns \c false if the \c {Q_PROPERTY()}'s \c USER attribute is false. Otherwise it returns true. diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index a1d53be197..45d0b5df6c 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -432,7 +432,7 @@ struct DefinedTypesFilter { \since 5.0 Returns a copy of \a copy, assuming it is of the type that this - QMetaType instance was created for. If \a copy is null, creates + QMetaType instance was created for. If \a copy is \nullptr, creates a default constructed instance. \sa QMetaType::destroy() diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 2cdb9eaaa6..77f507ff3f 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3284,7 +3284,7 @@ QMetaObject::Connection QMetaObject::connect(const QObject *sender, int signal_i \internal Same as the QMetaObject::connect, but \a signal_index must be the result of QObjectPrivate::signalIndex - method_index is relative to the rmeta metaobject, if rmeta is null, then it is absolute index + method_index is relative to the rmeta metaobject, if rmeta is \nullptr, then it is absolute index the QObjectPrivate::Connection* has a refcount of 2, so it must be passed to a QMetaObject::Connection */ @@ -3856,7 +3856,7 @@ void QMetaObject::activate(QObject *sender, int signal_index, void **argv) It is different from QMetaObject::indexOfSignal(): indexOfSignal is the same as indexOfMethod while QObjectPrivate::signalIndex is smaller because it doesn't give index to slots. - If \a meta is not 0, it is set to the meta-object where the signal was found. + If \a meta is not \nullptr, it is set to the meta-object where the signal was found. */ int QObjectPrivate::signalIndex(const char *signalName, const QMetaObject **meta) const diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 090436a3c7..18c7f7648d 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1768,7 +1768,7 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names \fn QVariant::QVariant(int typeId, const void *copy) Constructs variant of type \a typeId, and initializes with - \a copy if \a copy is not 0. + \a copy if \a copy is not \nullptr. Note that you have to pass the address of the variable you want stored. @@ -1797,7 +1797,7 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names \internal Constructs a variant private of type \a type, and initializes with \a copy if - \a copy is not 0. + \a copy is not \nullptr. */ void QVariant::create(int type, const void *copy) -- cgit v1.2.3