summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-02-04 09:11:01 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-07 23:52:49 +0100
commit29804462f4f7205ba941973e209642dfc81a5f14 (patch)
tree73b631f49e303cfd9805c0de7fb613962825018d /src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
parent59892468c95946ae3c3c3360e46d39bd62d8b9ea (diff)
Windows file dialog: Clean up thread manually.
Do not use deleteLater() to delete the thread. Task-number: QTBUG-36357 Change-Id: Ie7c87b92a7c73d5fbac01d4951d387ee2facd05c Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsdialoghelpers.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index 2abfb426cc..f0770d7d18 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -502,11 +502,31 @@ template <class BaseClass>
QWindowsDialogHelperBase<BaseClass>::QWindowsDialogHelperBase() :
m_nativeDialog(0),
m_ownerWindow(0),
- m_timerId(0)
+ m_timerId(0),
+ m_thread(0)
{
}
template <class BaseClass>
+void QWindowsDialogHelperBase<BaseClass>::cleanupThread()
+{
+ if (m_thread) { // Thread may be running if the dialog failed to close.
+ if (m_thread->isRunning())
+ m_thread->wait(500);
+ if (m_thread->isRunning()) {
+ m_thread->terminate();
+ m_thread->wait(300);
+ if (m_thread->isRunning())
+ qCCritical(lcQpaDialogs) <<__FUNCTION__ << "Failed to terminate thread.";
+ else
+ qCWarning(lcQpaDialogs) << __FUNCTION__ << "Thread terminated.";
+ }
+ delete m_thread;
+ m_thread = 0;
+ }
+}
+
+template <class BaseClass>
QWindowsNativeDialogBase *QWindowsDialogHelperBase<BaseClass>::nativeDialog() const
{
if (m_nativeDialog.isNull()) {
@@ -559,7 +579,6 @@ void QWindowsDialogThread::run()
{
qCDebug(lcQpaDialogs) << '>' << __FUNCTION__;
m_dialog->exec(m_owner);
- deleteLater();
qCDebug(lcQpaDialogs) << '<' << __FUNCTION__;
}
@@ -587,6 +606,7 @@ bool QWindowsDialogHelperBase<BaseClass>::show(Qt::WindowFlags,
// a subsequent call to exec() may follow. So, start an idle timer
// which will start the dialog thread. If exec() is then called, the
// timer is stopped and dialog->exec() is called directly.
+ cleanupThread();
if (modal) {
m_timerId = this->startTimer(0);
} else {
@@ -599,8 +619,9 @@ template <class BaseClass>
void QWindowsDialogHelperBase<BaseClass>::startDialogThread()
{
Q_ASSERT(!m_nativeDialog.isNull());
- QWindowsDialogThread *thread = new QWindowsDialogThread(m_nativeDialog, m_ownerWindow);
- thread->start();
+ Q_ASSERT(!m_thread);
+ m_thread = new QWindowsDialogThread(m_nativeDialog, m_ownerWindow);
+ m_thread->start();
stopTimer();
}