From 2b55d52669beb72396f94e449fdf172735349b3b Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 20 Apr 2010 10:34:03 +0200 Subject: Fix crash on startup on Symbian OS The changes to QThread introduced by commit 9aa4538b219ed759a47e8d1f93c2797bf07b5e2f mean that the QThread constructor calls into the event dispatcher. The Symbian event dispatcher owns a QThread, so it crashed when the code re-entered the partially constructed event dispatcher and used an uninitialised pointer. This change delays construction of the QThread until the point of use, so that the event dispatcher is fully constructed. Task-number: QTBUG-10029 Reviewed-by: Jason Barron --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 20 +++++++++++++++----- src/corelib/kernel/qeventdispatcher_symbian_p.h | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 8c96057..3b86e89 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -638,6 +638,7 @@ void QSocketActiveObject::deleteLater() QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent) : QAbstractEventDispatcher(parent), + m_selectThread(0), m_activeScheduler(0), m_wakeUpAO(0), m_completeDeferredAOs(0), @@ -665,11 +666,19 @@ void QEventDispatcherSymbian::startingUp() wakeUp(); } +QSelectThread& QEventDispatcherSymbian::selectThread() { + if (!m_selectThread) + m_selectThread = new QSelectThread; + return *m_selectThread; +} + void QEventDispatcherSymbian::closingDown() { - if (m_selectThread.isRunning()) { - m_selectThread.stop(); + if (m_selectThread && m_selectThread->isRunning()) { + m_selectThread->stop(); } + delete m_selectThread; + m_selectThread = 0; delete m_completeDeferredAOs; delete m_wakeUpAO; @@ -941,12 +950,13 @@ void QEventDispatcherSymbian::registerSocketNotifier ( QSocketNotifier * notifie { QSocketActiveObject *socketAO = q_check_ptr(new QSocketActiveObject(this, notifier)); m_notifiers.insert(notifier, socketAO); - m_selectThread.requestSocketEvents(notifier, &socketAO->iStatus); + selectThread().requestSocketEvents(notifier, &socketAO->iStatus); } void QEventDispatcherSymbian::unregisterSocketNotifier ( QSocketNotifier * notifier ) { - m_selectThread.cancelSocketEvents(notifier); + if (m_selectThread) + m_selectThread->cancelSocketEvents(notifier); if (m_notifiers.contains(notifier)) { QSocketActiveObject *sockObj = *m_notifiers.find(notifier); m_deferredSocketEvents.removeAll(sockObj); @@ -957,7 +967,7 @@ void QEventDispatcherSymbian::unregisterSocketNotifier ( QSocketNotifier * notif void QEventDispatcherSymbian::reactivateSocketNotifier(QSocketNotifier *notifier) { - m_selectThread.requestSocketEvents(notifier, &m_notifiers[notifier]->iStatus); + selectThread().requestSocketEvents(notifier, &m_notifiers[notifier]->iStatus); } void QEventDispatcherSymbian::registerTimer ( int timerId, int interval, QObject * object ) diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 1ab31cc..5281199 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -259,8 +259,9 @@ private: bool sendPostedEvents(); bool sendDeferredSocketEvents(); + QSelectThread& selectThread(); private: - QSelectThread m_selectThread; + QSelectThread *m_selectThread; CQtActiveScheduler *m_activeScheduler; -- cgit v0.12