diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-21 14:32:54 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-21 14:32:54 (GMT) |
commit | 0ed389f6d1bedb4caffde70f22efae91d70c4a90 (patch) | |
tree | e88b8ee3f9f07917b284af117b7a415a81da6040 /src/corelib/kernel/qobject.cpp | |
parent | c74dac2a0ef5d1b428c4da4e48fab05f9886233a (diff) | |
parent | ad0c6b17cde4a3ce0041d1a54b96ccb5a6792520 (diff) | |
download | Qt-0ed389f6d1bedb4caffde70f22efae91d70c4a90.zip Qt-0ed389f6d1bedb4caffde70f22efae91d70c4a90.tar.gz Qt-0ed389f6d1bedb4caffde70f22efae91d70c4a90.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (22 commits)
Fixes wrong QGraphicsView's viewport cursor reset.
Optimize ~QObject
Document that QFileSystemWatcher needs to be destroyed before ~QCoreApp
Build fix for mingw
Fixes keyboard shortcuts for QGraphicsTextItem.
Optimize QMetaObject::activate
Benchmark emission of signal connected to nothing
Micro optimisations in QMutexLocker
Fixed assert failure when trying to load invalid SVG file.
Added QIcon::name()
QDialog: user-moved dialog would not show on the same place after hide
Fixed image drawing inconsistencies when drawing 1x1 images/subrects.
Fixed pixel-bleeding when stretching subrected pixmaps.
Fixed a crash when declaring an animation with Q_GLOBAL_STATIC
Add a test to QListView to check initialisation of style option index, similar to QTreeView test.
Odf export: Remove double namespace in tab-stops and fix table padding
Mac: Fix off-by-one in vertical position for elided and non-elided text
QX11GL: Fix bug with pixmaps drawn on multiple top-levels
Use QGLContextPrivate to track attribarray enabled state.
Don't crash when calling drawPixmapFragements with a null pixmap
...
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c13d829..6a6db51 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -101,7 +101,7 @@ static QBasicAtomicInt objectCount = Q_BASIC_ATOMIC_INITIALIZER(0); /** \internal * mutex to be locked when accessing the connectionlists or the senders list */ -static QMutex *signalSlotLock(const QObject *o) +static inline QMutex *signalSlotLock(const QObject *o) { if (!signalSlotMutexes) { QMutexPool *mp = new QMutexPool; @@ -393,27 +393,6 @@ void QObjectPrivate::cleanConnectionLists() } } -QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver, - Sender *sender) -{ - Sender *previousSender = receiver->d_func()->currentSender; - receiver->d_func()->currentSender = sender; - return previousSender; -} - -void QObjectPrivate::resetCurrentSender(QObject *receiver, - Sender *currentSender, - Sender *previousSender) -{ - // ref is set to zero when this object is deleted during the metacall - if (currentSender->ref == 1) - receiver->d_func()->currentSender = previousSender; - // if we've recursed, we need to tell the caller about the objects deletion - if (previousSender) - previousSender->ref = currentSender->ref; -} - - typedef QMultiHash<QObject *, QObject **> GuardHash; Q_GLOBAL_STATIC(GuardHash, guardHash) Q_GLOBAL_STATIC(QMutex, guardHashLock) @@ -880,19 +859,14 @@ QObject::~QObject() if (d->declarativeData) QAbstractDeclarativeData::destroyed(d->declarativeData, this); - { - QMutex *signalSlotMutex = 0; - QT_TRY { - signalSlotMutex = signalSlotLock(this); - } QT_CATCH(const std::bad_alloc &) { - // out of memory - swallow to prevent a crash - } - QMutexLocker locker(signalSlotMutex); + // set ref to zero to indicate that this object has been deleted + if (d->currentSender != 0) + d->currentSender->ref = 0; + d->currentSender = 0; - // set ref to zero to indicate that this object has been deleted - if (d->currentSender != 0) - d->currentSender->ref = 0; - d->currentSender = 0; + if (d->connectionLists || d->senders) { + QMutex *signalSlotMutex = signalSlotLock(this); + QMutexLocker locker(signalSlotMutex); // disconnect all receivers if (d->connectionLists) { @@ -910,7 +884,7 @@ QObject::~QObject() } QMutex *m = signalSlotLock(c->receiver); - bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m); + bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); if (c->receiver) { *c->prev = c->next; @@ -938,7 +912,7 @@ QObject::~QObject() QObject *sender = node->sender; QMutex *m = signalSlotLock(sender); node->prev = &node; - bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m); + bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); //the node has maybe been removed while the mutex was unlocked in relock? if (!node || node->sender != sender) { m->unlock(); @@ -972,7 +946,8 @@ QObject::~QObject() qt_removeObject(this); - QCoreApplication::removePostedEvents(this); + if (d->postedEvents) + QCoreApplication::removePostedEvents(this, 0); if (d->parent) // remove it from parent object d->setParent_helper(0); @@ -3231,9 +3206,9 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign argv ? argv : empty_argv); } - QMutexLocker locker(signalSlotLock(sender)); QThreadData *currentThreadData = QThreadData::current(); + QMutexLocker locker(signalSlotLock(sender)); QObjectConnectionListVector *connectionLists = sender->d_func()->connectionLists; if (!connectionLists) { locker.unlock(); @@ -3329,7 +3304,7 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign if (connectionLists->orphaned) { if (!connectionLists->inUse) delete connectionLists; - } else { + } else if (connectionLists->dirty) { sender->d_func()->cleanConnectionLists(); } |