From 3adab135d7aa4c560d29d39964f3ba4afa5abf94 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 26 Jun 2019 13:44:25 +0200 Subject: Fix crashes when trying to start blocked apps Cherry-picked from dev: 6be19e2 Task-number: AUTOSUITE-1079 Change-Id: I11fb811af92d782815659ce41c50008f9b336a71 Reviewed-by: Robert Griebl --- src/manager-lib/applicationmanager.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/manager-lib/applicationmanager.cpp b/src/manager-lib/applicationmanager.cpp index 370b45e3..b2745ecb 100644 --- a/src/manager-lib/applicationmanager.cpp +++ b/src/manager-lib/applicationmanager.cpp @@ -1039,7 +1039,12 @@ bool ApplicationManager::openUrl(const QString &urlStr) if (!apps.isEmpty()) { if (!isSignalConnected(QMetaMethod::fromSignal(&ApplicationManager::openUrlRequested))) { // If the System-UI does not react to the signal, then just use the first match. - startApplicationInternal(apps.constFirst(), urlStr, mimeTypeName); + try { + startApplicationInternal(apps.constFirst(), urlStr, mimeTypeName); + } catch (const Exception &e) { + qCWarning(LogSystem) << "openUrl for" << urlStr << "requested app" << apps.constFirst()->id() + << "which could not be started:" << e.errorString(); + } } else { ApplicationManagerPrivate::OpenUrlRequest req { QUuid::createUuid().toString(), @@ -1096,7 +1101,12 @@ void ApplicationManager::acknowledgeOpenUrlRequest(const QString &requestId, con for (auto it = d->openUrlRequests.begin(); it != d->openUrlRequests.end(); ++it) { if (it->requestId == requestId) { if (it->possibleAppIds.contains(appId)) { - startApplicationInternal(application(appId), it->urlStr, it->mimeTypeName); + try { + startApplicationInternal(application(appId), it->urlStr, it->mimeTypeName); + } catch (const Exception &e) { + qCWarning(LogSystem) << "acknowledgeOpenUrlRequest for" << it->urlStr << "requested app" + << appId << "which could not be started:" << e.errorString(); + } } else { qCWarning(LogSystem) << "acknowledgeOpenUrlRequest for" << it->urlStr << "requested app" << appId << "which is not one of the registered possibilities:" @@ -1374,7 +1384,7 @@ void ApplicationManager::startSingleAppAndQuitWhenStopped() AbstractApplication *app = d->apps[0]; - if (!startApplicationInternal(app)) { + if (!startApplication(app->id())) { QMetaObject::invokeMethod(qApp, "shutDown", Qt::DirectConnection, Q_ARG(int, 1)); } else { connect(this, &ApplicationManager::applicationRunStateChanged, [app](const QString &id, Am::RunState runState) { @@ -1657,7 +1667,7 @@ void ApplicationManager::addApplication(AbstractApplication *app) connect (&app->requests, &ApplicationRequests::startRequested, this, [this, app](const QString &documentUrl) { - startApplicationInternal(app, documentUrl); + startApplication(app->id(), documentUrl); }); connect (&app->requests, &ApplicationRequests::debugRequested, -- cgit v1.2.3