mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #13427 from ctrlaltdavid/21897
Stop desktop app window's QML source from running when window is closed
This commit is contained in:
commit
1f4346d221
3 changed files with 31 additions and 0 deletions
|
@ -286,6 +286,13 @@ void OffscreenSurface::loadInternal(const QUrl& qmlSource,
|
|||
if (QThread::currentThread() != thread()) {
|
||||
qFatal("Called load on a non-surface thread");
|
||||
}
|
||||
|
||||
// For desktop toolbar mode window: stop script when window is closed.
|
||||
if (qmlSource.isEmpty()) {
|
||||
getSurfaceContext()->engine()->quit();
|
||||
return;
|
||||
}
|
||||
|
||||
// Synchronous loading may take a while; restart the deadlock timer
|
||||
QMetaObject::invokeMethod(qApp, "updateHeartbeat", Qt::DirectConnection);
|
||||
|
||||
|
|
|
@ -648,6 +648,26 @@ void TabletProxy::loadQMLSource(const QVariant& path, bool resizable) {
|
|||
}
|
||||
}
|
||||
|
||||
void TabletProxy::stopQMLSource() {
|
||||
// For desktop toolbar mode dialogs.
|
||||
if (!_toolbarMode || !_desktopWindow) {
|
||||
qCDebug(uiLogging) << "tablet cannot clear QML because not desktop toolbar mode";
|
||||
return;
|
||||
}
|
||||
|
||||
auto root = _desktopWindow->asQuickItem();
|
||||
if (root) {
|
||||
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, ""));
|
||||
if (!_currentPathLoaded.toString().isEmpty()) {
|
||||
emit screenChanged(QVariant("QML"), "");
|
||||
}
|
||||
_currentPathLoaded = "";
|
||||
_state = State::Home;
|
||||
} else {
|
||||
qCDebug(uiLogging) << "tablet cannot clear QML because _desktopWindow is null";
|
||||
}
|
||||
}
|
||||
|
||||
bool TabletProxy::pushOntoStack(const QVariant& path) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
bool result = false;
|
||||
|
@ -719,6 +739,7 @@ void TabletProxy::loadHomeScreen(bool forceOntoHomeScreen) {
|
|||
// close desktop window
|
||||
if (_desktopWindow->asQuickItem()) {
|
||||
QMetaObject::invokeMethod(_desktopWindow->asQuickItem(), "setShown", Q_ARG(const QVariant&, QVariant(false)));
|
||||
stopQMLSource(); // Stop the currently loaded QML running.
|
||||
}
|
||||
}
|
||||
_state = State::Home;
|
||||
|
|
|
@ -443,6 +443,9 @@ protected:
|
|||
bool _showRunningScripts { false };
|
||||
|
||||
TabletButtonListModel _buttons;
|
||||
|
||||
private:
|
||||
void stopQMLSource();
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(TabletProxy*);
|
||||
|
|
Loading…
Reference in a new issue