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>
This commit is contained in:
parent
7eddca359d
commit
91cde06296
@ -1260,18 +1260,30 @@ int QCoreApplication::exec()
|
|||||||
self->d_func()->aboutToQuitEmitted = false;
|
self->d_func()->aboutToQuitEmitted = false;
|
||||||
int returnCode = eventLoop.exec();
|
int returnCode = eventLoop.exec();
|
||||||
threadData->quitNow = false;
|
threadData->quitNow = false;
|
||||||
if (self) {
|
|
||||||
self->d_func()->in_exec = false;
|
if (self)
|
||||||
if (!self->d_func()->aboutToQuitEmitted)
|
self->d_func()->execCleanup();
|
||||||
emit self->aboutToQuit(QPrivateSignal());
|
|
||||||
self->d_func()->aboutToQuitEmitted = true;
|
|
||||||
sendPostedEvents(0, QEvent::DeferredDelete);
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnCode;
|
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.
|
Tells the application to exit with a return code.
|
||||||
|
|
||||||
|
@ -145,6 +145,8 @@ public:
|
|||||||
static inline void clearApplicationFilePath() { delete cachedApplicationFilePath; cachedApplicationFilePath = 0; }
|
static inline void clearApplicationFilePath() { delete cachedApplicationFilePath; cachedApplicationFilePath = 0; }
|
||||||
|
|
||||||
#ifndef QT_NO_QOBJECT
|
#ifndef QT_NO_QOBJECT
|
||||||
|
void execCleanup();
|
||||||
|
|
||||||
bool in_exec;
|
bool in_exec;
|
||||||
bool aboutToQuitEmitted;
|
bool aboutToQuitEmitted;
|
||||||
bool threadData_clean;
|
bool threadData_clean;
|
||||||
|
Loading…
Reference in New Issue
Block a user