diff options
author | Jørn Bersvendsen <jornb87@gmail.com> | 2016-10-07 11:26:04 +0200 |
---|---|---|
committer | Fredrik Orderud <forderud@gmail.com> | 2016-10-10 17:44:56 +0000 |
commit | 91cde062968f97041bca8d2a30d13aa03b606c3d (patch) | |
tree | b5c8848d6e1545b07a730fd6ba1dbfa606bb89d5 /src | |
parent | 7eddca359dd30d1dcfabb519f60ac4be83eda02c (diff) |
Extracted cleanup from QCoreApplication::exec() into separate function
Not all Qt integration points can call QCoreApplication::exec(), in
particular, ActiveQt. When an ActiveQt server is loaded, it tries to
mimic the behavior of calling QCoreApplication::exec() by setting
QCoreApplicationPrivate::in_exec = true. However, when unloading the
DLL it is necessary to call the same clean-up (e.g. deferred delete)
that QCoreApplication::exec() does. Extracting the cleanup in a separate
function means implementation does not have to be duplicated.
Task-number: QTBUG-56172
Change-Id: I061f1c06f38881032ad7044416c12c91e536478a
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 26 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication_p.h | 2 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 8f56001604..adefea4f09 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1260,18 +1260,30 @@ int QCoreApplication::exec() self->d_func()->aboutToQuitEmitted = false; int returnCode = eventLoop.exec(); threadData->quitNow = false; - if (self) { - self->d_func()->in_exec = false; - if (!self->d_func()->aboutToQuitEmitted) - emit self->aboutToQuit(QPrivateSignal()); - self->d_func()->aboutToQuitEmitted = true; - sendPostedEvents(0, QEvent::DeferredDelete); - } + + if (self) + self->d_func()->execCleanup(); return returnCode; } +// Cleanup after eventLoop is done executing in QCoreApplication::exec(). +// This is for use cases in which QCoreApplication is instantiated by a +// library and not by an application executable, for example, Active X +// servers. + +void QCoreApplicationPrivate::execCleanup() +{ + threadData->quitNow = false; + in_exec = false; + if (!aboutToQuitEmitted) + emit q_func()->aboutToQuit(QCoreApplication::QPrivateSignal()); + aboutToQuitEmitted = true; + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); +} + + /*! Tells the application to exit with a return code. diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 445bae01b4..3601add098 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -145,6 +145,8 @@ public: static inline void clearApplicationFilePath() { delete cachedApplicationFilePath; cachedApplicationFilePath = 0; } #ifndef QT_NO_QOBJECT + void execCleanup(); + bool in_exec; bool aboutToQuitEmitted; bool threadData_clean; |