summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2009-08-10 13:18:56 (GMT)
committermread <qt-info@nokia.com>2009-08-10 13:18:56 (GMT)
commit34dd8163f4fcd16be5677fc94ce960cc464991d5 (patch)
treef871fef42b4f337a98bce77ad307efe079b7dc5f /src/corelib/kernel
parent0dfca6e13a7ad3cce38d5509d446f76eb496f398 (diff)
parent70e098d965318651acb725374b73e026f2946b76 (diff)
downloadQt-34dd8163f4fcd16be5677fc94ce960cc464991d5.zip
Qt-34dd8163f4fcd16be5677fc94ce960cc464991d5.tar.gz
Qt-34dd8163f4fcd16be5677fc94ce960cc464991d5.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qobject.cpp16
-rw-r--r--src/corelib/kernel/qobject_p.h2
-rw-r--r--src/corelib/kernel/qvariant.cpp16
-rw-r--r--src/corelib/kernel/qvariant.h1
4 files changed, 31 insertions, 4 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index e6947a0..0f8548a 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -56,6 +56,7 @@
#include <qvarlengtharray.h>
#include <qset.h>
#include <qsemaphore.h>
+#include <qsharedpointer.h>
#include <private/qorderedmutexlocker_p.h>
#include <private/qmutexpool_p.h>
@@ -794,6 +795,18 @@ QObject::~QObject()
QObjectPrivate::clearGuards(this);
}
+ if (d->sharedRefcount) {
+ if (d->sharedRefcount->strongref > 0) {
+ qWarning("QObject: shared QObject was deleted directly. The program is malformed and may crash.");
+ // but continue deleting, it's too late to stop anyway
+ }
+
+ // indicate to all QWeakPointers that this QObject has now been deleted
+ d->sharedRefcount->strongref = 0;
+ if (!d->sharedRefcount->weakref.deref())
+ delete d->sharedRefcount;
+ }
+
QT_TRY {
emit destroyed(this);
if (d->declarativeData)
@@ -814,6 +827,7 @@ QObject::~QObject()
#endif
}
+
{
QMutex *signalSlotMutex = 0;
QT_TRY {
@@ -878,9 +892,9 @@ QObject::~QObject()
if (senderLists)
senderLists->dirty = true;
+ node = node->next;
if (needToUnlock)
m->unlock();
- node = node->next;
}
}
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index e58ee6c..5d17bfd 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -67,6 +67,7 @@ QT_BEGIN_NAMESPACE
class QVariant;
class QThreadData;
class QObjectConnectionListVector;
+namespace QtSharedPointer { struct ExternalRefCountData; }
/* mirrored in QtTestLib, DON'T CHANGE without prior warning */
struct QSignalSpyCallbackSet
@@ -187,6 +188,7 @@ public:
// plus QPointer, which keeps a separate list
QDeclarativeData *declarativeData;
QGuard<QObject> *objectGuards;
+ QAtomicPointer<QtSharedPointer::ExternalRefCountData> sharedRefcount;
int *deleteWatch;
};
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 5016d3b..a7e4135 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -170,6 +170,9 @@ static void construct(QVariant::Private *x, const void *copy)
case QMetaType::Float:
x->data.f = copy ? *static_cast<const float*>(copy) : 0.0f;
break;
+ case QMetaType::QObjectStar:
+ x->data.o = copy ? *static_cast<QObject *const*>(copy) : 0;
+ break;
case QVariant::LongLong:
#if defined(Q_CC_RVCT)
// Using trinary operator with 64bit constants crashes when ran on Symbian device
@@ -284,6 +287,7 @@ static void clear(QVariant::Private *d)
case QVariant::ULongLong:
case QVariant::Double:
case QMetaType::Float:
+ case QMetaType::QObjectStar:
break;
case QVariant::Invalid:
case QVariant::UserType:
@@ -353,6 +357,7 @@ static bool isNull(const QVariant::Private *d)
case QVariant::Bool:
case QVariant::Double:
case QMetaType::Float:
+ case QMetaType::QObjectStar:
break;
}
return d->is_null;
@@ -446,6 +451,8 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
return a->data.d == b->data.d;
case QMetaType::Float:
return a->data.f == b->data.f;
+ case QMetaType::QObjectStar:
+ return a->data.o == b->data.o;
case QVariant::Date:
return *v_cast<QDate>(a) == *v_cast<QDate>(b);
case QVariant::Time:
@@ -1075,6 +1082,9 @@ static void streamDebug(QDebug dbg, const QVariant &v)
case QMetaType::Float:
dbg.nospace() << qVariantValue<float>(v);
break;
+ case QMetaType::QObjectStar:
+ dbg.nospace() << qVariantValue<QObject *>(v);
+ break;
case QVariant::Double:
dbg.nospace() << v.toDouble();
break;
@@ -1388,7 +1398,7 @@ void QVariant::create(int type, const void *copy)
QVariant::~QVariant()
{
- if (d.type > Char && d.type != QMetaType::Float && (!d.is_shared || !d.data.shared->ref.deref()))
+ if (d.type > Char && d.type != QMetaType::Float && d.type != QMetaType::QObjectStar && (!d.is_shared || !d.data.shared->ref.deref()))
handler->clear(&d);
}
@@ -1404,7 +1414,7 @@ QVariant::QVariant(const QVariant &p)
{
if (d.is_shared) {
d.data.shared->ref.ref();
- } else if (p.d.type > Char && p.d.type != QMetaType::Float) {
+ } else if (p.d.type > Char && p.d.type != QMetaType::Float && p.d.type != QMetaType::QObjectStar) {
handler->construct(&d, p.constData());
d.is_null = p.d.is_null;
}
@@ -1760,7 +1770,7 @@ QVariant& QVariant::operator=(const QVariant &variant)
if (variant.d.is_shared) {
variant.d.data.shared->ref.ref();
d = variant.d;
- } else if (variant.d.type > Char && variant.d.type != QMetaType::Float) {
+ } else if (variant.d.type > Char && variant.d.type != QMetaType::Float && variant.d.type != QMetaType::QObjectStar) {
d.type = variant.d.type;
handler->construct(&d, variant.constData());
d.is_null = variant.d.is_null;
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index a68939d..4489e95 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -358,6 +358,7 @@ class Q_CORE_EXPORT QVariant
float f;
qlonglong ll;
qulonglong ull;
+ QObject *o;
void *ptr;
PrivateShared *shared;
} data;