From 66603985f2de74ac5f3bd5d259f0e65f710f62d7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 11 Feb 2012 01:33:55 +0100 Subject: Fix ref counted window close handling. Instead of refcounting QWindow visibility, we ask the Application subclass whether quitting is appropriate. Task-Id: QTBUG-24120 Change-Id: Idd19cc1a3e5742fddded89c7638aaaa5e47c568d Reviewed-by: Bradley T. Hughes Reviewed-by: Robin Burchell --- src/corelib/kernel/qcoreapplication.cpp | 10 ++++++++-- src/corelib/kernel/qcoreapplication_p.h | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index cf3ae1b7c5..80e42336d6 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1506,8 +1506,14 @@ void QCoreApplicationPrivate::ref() void QCoreApplicationPrivate::deref() { - if (!quitLockRef.deref() && in_exec && quitLockRefEnabled) - QCoreApplication::postEvent(qApp, new QEvent(QEvent::Quit)); + if (!quitLockRef.deref()) + maybeQuit(); +} + +void QCoreApplicationPrivate::maybeQuit() +{ + if (quitLockRef.load() == 0 && in_exec && quitLockRefEnabled && shouldQuit()) + QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(QEvent::Quit)); } /*! diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 861a046f16..112b313129 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -92,6 +92,10 @@ public: QAtomicInt quitLockRef; void ref(); void deref(); + virtual bool shouldQuit() { + return true; + } + void maybeQuit(); static QThread *theMainThread; static QThread *mainThread(); -- cgit v1.2.3