From 4c466703eb096b7ea0e18fb1efee0729ac688772 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 14 Jan 2011 12:16:35 +0100 Subject: Fix the warnings when QBasicTimer are member of the ObjectPrivate If a class has QBasicTimer as member of a derived class QObjectPrivate, the QBasicTimer will be destroyed after the timer has been cleaned. The QBasicTimer will stop the timer in its destructor. But that means that the same timer will be stoped twice, leading to ugly bugs. Reviewed-by: Thiago Reviewed-by: Brad Task-number: QTBUG-16558 Task-number: QTBUG-16175 --- src/corelib/kernel/qobject.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 2e9d003..c6153cb 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -161,6 +161,17 @@ QObjectPrivate::QObjectPrivate(int version) QObjectPrivate::~QObjectPrivate() { + if (pendTimer) { + // unregister pending timers + if (threadData->eventDispatcher) + threadData->eventDispatcher->unregisterTimers(q_ptr); + } + + if (postedEvents) + QCoreApplication::removePostedEvents(q_ptr, 0); + + threadData->deref(); + delete static_cast(metaObject); #ifdef QT_JAMBI_BUILD if (deleteWatch) @@ -911,25 +922,14 @@ QObject::~QObject() } } - if (d->pendTimer) { - // unregister pending timers - if (d->threadData->eventDispatcher) - d->threadData->eventDispatcher->unregisterTimers(this); - } - if (!d->children.isEmpty()) d->deleteChildren(); qt_removeObject(this); - if (d->postedEvents) - QCoreApplication::removePostedEvents(this, 0); - if (d->parent) // remove it from parent object d->setParent_helper(0); - d->threadData->deref(); - #ifdef QT_JAMBI_BUILD if (d->inEventHandler) { qWarning("QObject: Do not delete object, '%s', during its event handler!", -- cgit v0.12 From 0f9cbfc6124b331d006b396d56ad5ae0e6d548e0 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 17 Jan 2011 10:42:47 +0100 Subject: qRound: do not do operation with double when qreal is float 0.5 is double a literal, and they force computation on double while it would be more optimized on qreal if qreal is a float Task-number: QTBUG-16673 Reviewed-by: Thierry --- src/corelib/global/qglobal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 945e45c..2a41b9e 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1123,14 +1123,14 @@ template inline T qAbs(const T &t) { return t >= 0 ? t : -t; } inline int qRound(qreal d) -{ return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); } +{ return d >= qreal(0.0) ? int(d + qreal(0.5)) : int(d - int(d-1) + qreal(0.5)) + int(d-1); } #if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN) inline qint64 qRound64(double d) { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); } #else inline qint64 qRound64(qreal d) -{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); } +{ return d >= qreal(0.0) ? qint64(d + qreal(0.5)) : qint64(d - qreal(qint64(d-1)) + qreal(0.5)) + qint64(d-1); } #endif template -- cgit v0.12