From 8c2f0ac3827e765dfd31711ad576b396df7df467 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 20 Sep 2014 18:52:15 +0200 Subject: QObject: fix a memory leak in moveToThread For some reason it seems to be supported to call moveToThread(0). That call will allocate a new QThreadData for the object. However, if we then detect that we're calling moveToThread from a thread which is not the one the QObject has affinity with, we error out leaking that QThreadData object. Change-Id: I0fe6625a2a9887535e457f3897b514d2a03d1480 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/corelib/kernel/qobject.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index e588808ee8..9ab952362c 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1461,14 +1461,14 @@ void QObject::moveToThread(QThread *targetThread) } QThreadData *currentData = QThreadData::current(); - QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : new QThreadData(0); + QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : Q_NULLPTR; if (d->threadData->thread == 0 && currentData == targetData) { // one exception to the rule: we allow moving objects with no thread affinity to the current thread currentData = d->threadData; } else if (d->threadData != currentData) { qWarning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n" "Cannot move to target thread (%p)\n", - currentData->thread, d->threadData->thread, targetData->thread); + currentData->thread, d->threadData->thread, targetData ? targetData->thread : Q_NULLPTR); #ifdef Q_OS_MAC qWarning("On Mac OS X, you might be loading two sets of Qt binaries into the same process. " @@ -1482,6 +1482,9 @@ void QObject::moveToThread(QThread *targetThread) // prepare to move d->moveToThread_helper(); + if (!targetData) + targetData = new QThreadData(0); + QOrderedMutexLocker locker(¤tData->postEventList.mutex, &targetData->postEventList.mutex); -- cgit v1.2.3 From 54853c5f66288a82fc77e4e8c3e01a8565073436 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 11 Sep 2014 11:57:14 +0200 Subject: Doc: Use title case in section1 titles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using Python script title-cased.py Task-number: QTBUG-41250 Change-Id: I00d3d7a0b30db7304a7904efd6d63abd9a7b493b Reviewed-by: Topi Reiniƶ --- src/corelib/kernel/qobject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 65b22021fd..337ea7da3c 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -678,7 +678,7 @@ void QMetaCallEvent::placeMetaCall(QObject *object) will remain in the old thread when moveToThread() is called. \target No copy constructor - \section1 No copy constructor or assignment operator + \section1 No Copy Constructor or Assignment Operator QObject has neither a copy constructor nor an assignment operator. This is by design. Actually, they are declared, but in a @@ -723,7 +723,7 @@ void QMetaCallEvent::placeMetaCall(QObject *object) and both standard Qt widgets and user-created forms can be given dynamic properties. - \section1 Internationalization (i18n) + \section1 Internationalization (I18n) All QObject subclasses support Qt's translation features, making it possible to translate an application's user interface into different languages. -- cgit v1.2.3 From a4aea7b578dd5ed6544ad8dbe488bb14817785b6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 7 Oct 2014 10:20:21 +0200 Subject: MSVC: Restore 'public' accessibility of QVariant member functions. The were made 'protected' as a side effect of a change enabling support of template friends for MSVC. However, accessibility is part of the MSVC's name mangling and thus BC was broken. Task-number: QTBUG-41810 Change-Id: I5ce4c7010673c06d5b75219c89c7ebd337bac6c0 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 2d97cf5a6a..bdbd0dd8ef 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -442,7 +442,8 @@ protected: #ifndef QT_NO_DEBUG_STREAM friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QVariant &); #endif -#ifndef Q_NO_TEMPLATE_FRIENDS +// ### Qt6: FIXME: Remove the special Q_CC_MSVC handling, it was introduced to maintain BC for QTBUG-41810 . +#if !defined(Q_NO_TEMPLATE_FRIENDS) && !defined(Q_CC_MSVC) template friend inline T qvariant_cast(const QVariant &); template friend struct QtPrivate::QVariantValueHelper; -- cgit v1.2.3