diff options
author | Robert Griebl <robert.griebl@qt.io> | 2020-03-12 17:58:13 +0100 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2020-03-12 17:58:13 +0100 |
commit | e2fc7241a2e684d90c01229cf3767420a149ebfe (patch) | |
tree | a39c5e2424d03e8d5f98c53d98229938e4643813 | |
parent | 4b34b5999ad2d3e81ae6c618ae6b942bb879f4d6 (diff) | |
parent | 03471c798ae7b398c9943e9f059aeb934a1216dd (diff) | |
download | qtapplicationmanager-e2fc7241a2e684d90c01229cf3767420a149ebfe.tar.gz |
Merge remote-tracking branch 'gerrit/5.13' into 5.14
Change-Id: I6f0940de367b9b3901d05ee61d994a50c4f2ca8b
-rw-r--r-- | src/common-lib/crashhandler.cpp | 3 | ||||
-rw-r--r-- | src/manager-lib/applicationmanager.cpp | 14 | ||||
-rw-r--r-- | src/manager-lib/qmlinprocessruntime.cpp | 14 |
3 files changed, 17 insertions, 14 deletions
diff --git a/src/common-lib/crashhandler.cpp b/src/common-lib/crashhandler.cpp index 91aa2040..a87c7385 100644 --- a/src/common-lib/crashhandler.cpp +++ b/src/common-lib/crashhandler.cpp @@ -43,6 +43,7 @@ #include <inttypes.h> #if defined(QT_QML_LIB) +# include <QPointer> # include <QQmlEngine> # include <QtQml/private/qv4engine_p.h> #endif @@ -82,7 +83,7 @@ static size_t demangleBufferSize; static QByteArray *backtraceLineOut; static QByteArray *backtraceLineTmp; -static QQmlEngine *qmlEngine; +static QPointer<QQmlEngine> qmlEngine; void CrashHandler::setCrashActionConfiguration(const QVariantMap &config) diff --git a/src/manager-lib/applicationmanager.cpp b/src/manager-lib/applicationmanager.cpp index 0911126f..661c7ea3 100644 --- a/src/manager-lib/applicationmanager.cpp +++ b/src/manager-lib/applicationmanager.cpp @@ -782,8 +782,6 @@ bool ApplicationManager::startApplicationInternal(const QString &appId, const QS else if (!app->documentUrl().isNull()) runtime->openDocument(app->documentUrl(), documentMimeType); - emitActivated(app); - qCDebug(LogSystem) << "Starting application" << app->id() << "in container" << containerId << "using runtime" << runtimeManager->identifier(); if (!documentUrl.isEmpty()) @@ -791,7 +789,9 @@ bool ApplicationManager::startApplicationInternal(const QString &appId, const QS if (inProcess) { bool ok = runtime->start(); - if (!ok) + if (ok) + emitActivated(app); + else runtime->deleteLater(); return ok; } else { @@ -799,11 +799,13 @@ bool ApplicationManager::startApplicationInternal(const QString &appId, const QS // Using a state-machine would be one option, but then we would need that state-machine // object plus the per-app state. Relying on 2 lambdas is the easier choice for now. - auto doStartInContainer = [app, attachRuntime, runtime]() -> bool { + auto doStartInContainer = [this, app, attachRuntime, runtime]() -> bool { bool successfullyStarted = attachRuntime ? runtime->attachApplicationToQuickLauncher(app) : runtime->start(); - if (!successfullyStarted) - runtime->deleteLater(); // ~Runtime() will clean app->m_runtime + if (successfullyStarted) + emitActivated(app); + else + runtime->deleteLater(); // ~Runtime() will clean app->nonAliased()->m_runtime return successfullyStarted; }; diff --git a/src/manager-lib/qmlinprocessruntime.cpp b/src/manager-lib/qmlinprocessruntime.cpp index 1a8160fe..d935623e 100644 --- a/src/manager-lib/qmlinprocessruntime.cpp +++ b/src/manager-lib/qmlinprocessruntime.cpp @@ -156,7 +156,7 @@ bool QmlInProcessRuntime::start() // We are running each application in it's own, separate Qml context. // This way, we can export an unique ApplicationInterface object for each app - QQmlContext *appContext = new QQmlContext(m_inProcessQmlEngine->rootContext()); + QQmlContext *appContext = new QQmlContext(m_inProcessQmlEngine->rootContext(), this); m_applicationIf = new QmlInProcessApplicationInterface(this); appContext->setContextProperty(qSL("ApplicationInterface"), m_applicationIf); connect(m_applicationIf, &QmlInProcessApplicationInterface::quitAcknowledged, @@ -167,16 +167,17 @@ bool QmlInProcessRuntime::start() QObject *obj = component->beginCreate(appContext); - QMetaObject::invokeMethod(this, [component, appContext, obj, this]() { + QMetaObject::invokeMethod(this, [component, obj, this]() { component->completeCreate(); + delete component; if (!obj) { qCCritical(LogSystem) << "could not load" << m_app->info()->absoluteCodeFilePath() << ": no root object"; - delete obj; - delete appContext; - delete m_applicationIf; - m_applicationIf = nullptr; finish(3, Am::NormalExit); } else { + if (state() == Am::ShuttingDown) { + delete obj; + return; + } #if !defined(AM_HEADLESS) if (!qobject_cast<QmlInProcessApplicationManagerWindow*>(obj)) { QQuickItem *item = qobject_cast<QQuickItem*>(obj); @@ -192,7 +193,6 @@ bool QmlInProcessRuntime::start() openDocument(m_document, QString()); setState(Am::Running); } - delete component; }, Qt::QueuedConnection); return true; } |