From 877e4cd4cf7f581a0a92eb2adb6f95695b186104 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Fri, 6 Sep 2019 13:12:50 +0200 Subject: Fix canceling installations Canceling an update left the app in an inconsistent state. There is still a known issues: canceling the update of an already updated built-in app will revert back to the original app. This will be fixed in 5.14 Also downgrading a built-in app didn't work as expected (the app would be blocked, the icon etc. wouldn't be updated). Change-Id: I6c72e7f87e993a6839e97ceb6cea443f07e1fd77 Reviewed-by: Robert Griebl --- src/manager-lib/application.cpp | 16 +-- src/manager-lib/application.h | 4 +- src/manager-lib/applicationmanager.cpp | 27 ++-- tests/qml/installer/apps/builtin.app/app1.qml | 46 +++++++ tests/qml/installer/apps/builtin.app/icon1.png | Bin 0 -> 1486 bytes tests/qml/installer/apps/builtin.app/info.yaml | 10 ++ tests/qml/installer/appv1.pkg | Bin 10240 -> 10240 bytes tests/qml/installer/appv2.pkg | Bin 10240 -> 10240 bytes tests/qml/installer/builtinv2.pkg | Bin 0 -> 10240 bytes tests/qml/installer/install-apps/appv1/app1.qml | 44 +++++++ tests/qml/installer/install-apps/appv1/icon1.png | Bin 0 -> 1486 bytes tests/qml/installer/install-apps/appv1/info.yaml | 10 ++ tests/qml/installer/install-apps/appv2/app2.qml | 44 +++++++ tests/qml/installer/install-apps/appv2/icon2.png | Bin 0 -> 1486 bytes tests/qml/installer/install-apps/appv2/info.yaml | 10 ++ .../qml/installer/install-apps/builtinv2/app2.qml | 46 +++++++ .../qml/installer/install-apps/builtinv2/icon2.png | Bin 0 -> 1486 bytes .../qml/installer/install-apps/builtinv2/info.yaml | 10 ++ tests/qml/installer/tst_installer.qml | 140 ++++++++++++++++++--- 19 files changed, 365 insertions(+), 42 deletions(-) create mode 100644 tests/qml/installer/apps/builtin.app/app1.qml create mode 100644 tests/qml/installer/apps/builtin.app/icon1.png create mode 100644 tests/qml/installer/apps/builtin.app/info.yaml create mode 100644 tests/qml/installer/builtinv2.pkg create mode 100644 tests/qml/installer/install-apps/appv1/app1.qml create mode 100644 tests/qml/installer/install-apps/appv1/icon1.png create mode 100644 tests/qml/installer/install-apps/appv1/info.yaml create mode 100644 tests/qml/installer/install-apps/appv2/app2.qml create mode 100644 tests/qml/installer/install-apps/appv2/icon2.png create mode 100644 tests/qml/installer/install-apps/appv2/info.yaml create mode 100644 tests/qml/installer/install-apps/builtinv2/app2.qml create mode 100644 tests/qml/installer/install-apps/builtinv2/icon2.png create mode 100644 tests/qml/installer/install-apps/builtinv2/info.yaml diff --git a/src/manager-lib/application.cpp b/src/manager-lib/application.cpp index 4eff6990..e4cb7292 100644 --- a/src/manager-lib/application.cpp +++ b/src/manager-lib/application.cpp @@ -417,25 +417,20 @@ QVector AbstractApplication::fromApplicationInfoVector( // There's already another ApplicationInfo with the same id. It's probably an update for a // built-in app, in which case we use the same Application instance to hold both // ApplicationInfo instances. - bool merged = false; - if (!otherAbsApp->isAlias()) { auto otherApp = static_cast(otherAbsApp); auto fullAppInfo = static_cast(appInfo); if (otherApp->isBuiltIn() && !fullAppInfo->isBuiltIn() && !otherApp->updatedInfo()) { otherApp->setUpdatedInfo(static_cast(appInfo)); - merged = true; } else if (!otherApp->isBuiltIn() && fullAppInfo->isBuiltIn() && !otherApp->updatedInfo()) { auto currentBaseInfo = otherApp->takeBaseInfo(); otherApp->setBaseInfo(static_cast(appInfo)); otherApp->setUpdatedInfo(currentBaseInfo); - merged = true; } + } else { + qCWarning(LogSystem) << "Found a second application with id" << appInfo->id() + << "which is not an update for a built-in one. Ignoring it."; } - - if (!merged) - qCWarning(LogSystem).nospace() << "Found a second application with id " - << appInfo->id() << " which is not an update for a built-in one. Ignoring it."; } else { app.reset(new Application(static_cast(appInfo))); } @@ -564,6 +559,11 @@ void Application::setUpdatedInfo(ApplicationInfo* info) emit bulkChange(); } +ApplicationInfo *Application::takeUpdatedInfo() +{ + return m_updatedInfo.take(); +} + void Application::setState(State state) { if (m_state != state) { diff --git a/src/manager-lib/application.h b/src/manager-lib/application.h index 673cdfe5..b5c62338 100644 --- a/src/manager-lib/application.h +++ b/src/manager-lib/application.h @@ -201,9 +201,11 @@ public: removed when requested. */ void setBaseInfo(ApplicationInfo*); + AbstractApplicationInfo *baseInfo() const { return m_info.data(); } + ApplicationInfo *takeBaseInfo(); void setUpdatedInfo(ApplicationInfo*); ApplicationInfo *updatedInfo() const { return m_updatedInfo.data(); } - ApplicationInfo *takeBaseInfo(); + ApplicationInfo *takeUpdatedInfo(); void setState(State); void setProgress(qreal); diff --git a/src/manager-lib/applicationmanager.cpp b/src/manager-lib/applicationmanager.cpp index b2745ecb..dc6071d9 100644 --- a/src/manager-lib/applicationmanager.cpp +++ b/src/manager-lib/applicationmanager.cpp @@ -1203,16 +1203,10 @@ bool ApplicationManager::startingApplicationInstallation(ApplicationInfo *info) if (!blockApplication(app->id())) return false; - if (app->isBuiltIn()) { - // overlay the existing base info - // we will rollback to the base one if this update is removed. - app->setUpdatedInfo(newInfo.take()); - } else { - // overwrite the existing base info - // we're not keeping track of the original. so removing the updated base version removes the - // application entirely. - app->setBaseInfo(newInfo.take()); - } + // There is still an issue with "shadowing" built-in apps (which will be properly fixed in 5.14): + // As the updatedInfo might be used already (by an already updated built-in app), we cannot revert back any + // more to the previous version. Canceling the update will therefore revert back to the original app. + app->setUpdatedInfo(newInfo.take()); app->setState(Application::BeingUpdated); app->setProgress(0); emitDataChanged(app); @@ -1290,8 +1284,11 @@ bool ApplicationManager::finishedApplicationInstall(const QString &id) case Application::Installed: return false; - case Application::BeingInstalled: - case Application::BeingUpdated: { + case Application::BeingUpdated: + if (!static_cast(app->baseInfo())->isBuiltIn()) + app->setBaseInfo(app->takeUpdatedInfo()); + Q_FALLTHROUGH(); + case Application::BeingInstalled: { // The Application object has been updated right at the start of the installation/update. // Now's the time to update the InstallationReport that was written by the installer. QFile irfile(QDir(app->nonAliasedInfo()->manifestDir()).absoluteFilePath(qSL("installation-report.yaml"))); @@ -1316,6 +1313,8 @@ bool ApplicationManager::finishedApplicationInstall(const QString &id) app->setUpdatedInfo(nullptr); app->setState(Application::Installed); registerMimeTypes(); + emitDataChanged(app); + unblockApplication(id); break; case Application::BeingRemoved: { int row = d->apps.indexOf(app); @@ -1361,11 +1360,13 @@ bool ApplicationManager::canceledApplicationInstall(const QString &id) break; } case Application::BeingUpdated: + app->setUpdatedInfo(nullptr); + Q_FALLTHROUGH(); case Application::BeingDowngraded: case Application::BeingRemoved: app->setState(Application::Installed); app->setProgress(0); - emitDataChanged(app, QVector { IsUpdating }); + emitDataChanged(app); unblockApplication(id); break; diff --git a/tests/qml/installer/apps/builtin.app/app1.qml b/tests/qml/installer/apps/builtin.app/app1.qml new file mode 100644 index 00000000..c18b5421 --- /dev/null +++ b/tests/qml/installer/apps/builtin.app/app1.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Luxoft Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtApplicationManager.Application 2.0 + +ApplicationManagerWindow { + color: "green" +} diff --git a/tests/qml/installer/apps/builtin.app/icon1.png b/tests/qml/installer/apps/builtin.app/icon1.png new file mode 100644 index 00000000..c1397153 Binary files /dev/null and b/tests/qml/installer/apps/builtin.app/icon1.png differ diff --git a/tests/qml/installer/apps/builtin.app/info.yaml b/tests/qml/installer/apps/builtin.app/info.yaml new file mode 100644 index 00000000..9320306b --- /dev/null +++ b/tests/qml/installer/apps/builtin.app/info.yaml @@ -0,0 +1,10 @@ +formatVersion: 1 +formatType: am-application +--- +id: 'builtin.app' +version: 'v1' +icon: 'icon1.png' +code: 'app1.qml' +runtime: 'qml' +name: + en: 'Builtin Installation Test App v1' diff --git a/tests/qml/installer/appv1.pkg b/tests/qml/installer/appv1.pkg index d2c5355f..416cf018 100644 Binary files a/tests/qml/installer/appv1.pkg and b/tests/qml/installer/appv1.pkg differ diff --git a/tests/qml/installer/appv2.pkg b/tests/qml/installer/appv2.pkg index 5eb1a5b2..d3a15de5 100644 Binary files a/tests/qml/installer/appv2.pkg and b/tests/qml/installer/appv2.pkg differ diff --git a/tests/qml/installer/builtinv2.pkg b/tests/qml/installer/builtinv2.pkg new file mode 100644 index 00000000..b32c2422 Binary files /dev/null and b/tests/qml/installer/builtinv2.pkg differ diff --git a/tests/qml/installer/install-apps/appv1/app1.qml b/tests/qml/installer/install-apps/appv1/app1.qml new file mode 100644 index 00000000..4934be54 --- /dev/null +++ b/tests/qml/installer/install-apps/appv1/app1.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Luxoft Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.4 + +Item {} diff --git a/tests/qml/installer/install-apps/appv1/icon1.png b/tests/qml/installer/install-apps/appv1/icon1.png new file mode 100644 index 00000000..c1397153 Binary files /dev/null and b/tests/qml/installer/install-apps/appv1/icon1.png differ diff --git a/tests/qml/installer/install-apps/appv1/info.yaml b/tests/qml/installer/install-apps/appv1/info.yaml new file mode 100644 index 00000000..2c04ec5d --- /dev/null +++ b/tests/qml/installer/install-apps/appv1/info.yaml @@ -0,0 +1,10 @@ +formatVersion: 1 +formatType: am-application +--- +id: 'test.install.app' +version: 'v1' +icon: 'icon1.png' +code: 'app1.qml' +runtime: 'qml' +name: + en: 'Installation Test App Version 1' diff --git a/tests/qml/installer/install-apps/appv2/app2.qml b/tests/qml/installer/install-apps/appv2/app2.qml new file mode 100644 index 00000000..0e1798c3 --- /dev/null +++ b/tests/qml/installer/install-apps/appv2/app2.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Luxoft Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.4 + +Rectangle {} diff --git a/tests/qml/installer/install-apps/appv2/icon2.png b/tests/qml/installer/install-apps/appv2/icon2.png new file mode 100644 index 00000000..c1397153 Binary files /dev/null and b/tests/qml/installer/install-apps/appv2/icon2.png differ diff --git a/tests/qml/installer/install-apps/appv2/info.yaml b/tests/qml/installer/install-apps/appv2/info.yaml new file mode 100644 index 00000000..f7e2f96a --- /dev/null +++ b/tests/qml/installer/install-apps/appv2/info.yaml @@ -0,0 +1,10 @@ +formatVersion: 1 +formatType: am-application +--- +id: 'test.install.app' +version: 'v2' +icon: 'icon2.png' +code: 'app2.qml' +runtime: 'qml' +name: + en: 'Installation Test App Version 2' diff --git a/tests/qml/installer/install-apps/builtinv2/app2.qml b/tests/qml/installer/install-apps/builtinv2/app2.qml new file mode 100644 index 00000000..b65b03ce --- /dev/null +++ b/tests/qml/installer/install-apps/builtinv2/app2.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Luxoft Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.4 + +Rectangle { + color: "red" +} diff --git a/tests/qml/installer/install-apps/builtinv2/icon2.png b/tests/qml/installer/install-apps/builtinv2/icon2.png new file mode 100644 index 00000000..c1397153 Binary files /dev/null and b/tests/qml/installer/install-apps/builtinv2/icon2.png differ diff --git a/tests/qml/installer/install-apps/builtinv2/info.yaml b/tests/qml/installer/install-apps/builtinv2/info.yaml new file mode 100644 index 00000000..3e90f151 --- /dev/null +++ b/tests/qml/installer/install-apps/builtinv2/info.yaml @@ -0,0 +1,10 @@ +formatVersion: 1 +formatType: am-application +--- +id: 'builtin.app' +version: 'v2' +icon: 'icon2.png' +code: 'app2.qml' +runtime: 'qml' +name: + en: 'Builtin Installation Test App v2' diff --git a/tests/qml/installer/tst_installer.qml b/tests/qml/installer/tst_installer.qml index 8bfcc246..01bb7a32 100644 --- a/tests/qml/installer/tst_installer.qml +++ b/tests/qml/installer/tst_installer.qml @@ -49,12 +49,21 @@ TestCase { name: "Installer" when: windowShown + property var stateList: [] + property int spyTimeout: 5000 * AmTest.timeoutFactor + SignalSpy { id: taskFinishedSpy target: ApplicationInstaller signalName: "taskFinished" } + SignalSpy { + id: taskFailedSpy + target: ApplicationInstaller + signalName: "taskFailed" + } + SignalSpy { id: taskStateChangedSpy target: ApplicationInstaller @@ -67,27 +76,34 @@ TestCase { signalName: "taskRequestingInstallationAcknowledge" } - property var stateList: [] - property int spyTimeout: 5000 * AmTest.timeoutFactor + SignalSpy { +        id: applicationChangedSpy +        target: ApplicationManager +        signalName: "applicationChanged" +    } - function test_states() { - // App could potentially be installed already. Remove it. + + function init() { + // Remove previous installations if (ApplicationInstaller.removePackage("test.install.app", false, true)) { taskFinishedSpy.wait(spyTimeout); compare(taskFinishedSpy.count, 1); taskFinishedSpy.clear(); } + } - ApplicationManager.applicationAdded.connect(function(appId) { - var app = ApplicationManager.application(appId); - stateList.push(app.state) + function test_states() { + ApplicationManager.applicationAdded.connect(function(id) { + var app = ApplicationManager.application(id); + stateList.push(app.state); app.stateChanged.connect(function(state) { - compare(state, app.state) - stateList.push(state) - }) - }) + compare(state, app.state); + stateList.push(state); + }); + }); - var id = ApplicationInstaller.startPackageInstallation("internal-0", "appv1.pkg") + taskStateChangedSpy.clear(); + var id = ApplicationInstaller.startPackageInstallation("internal-0", "appv1.pkg"); taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); compare(taskRequestingInstallationAcknowledgeSpy.count, 1); compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id); @@ -101,23 +117,24 @@ TestCase { taskFinishedSpy.clear(); compare(stateList.length, 2); - compare(stateList[0], ApplicationObject.BeingInstalled) - compare(stateList[1], ApplicationObject.Installed) - stateList = [] + compare(stateList[0], ApplicationObject.BeingInstalled); + compare(stateList[1], ApplicationObject.Installed); + stateList = []; id = ApplicationInstaller.startPackageInstallation("internal-0", "appv2.pkg") taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); compare(taskRequestingInstallationAcknowledgeSpy.count, 1); compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id); + taskRequestingInstallationAcknowledgeSpy.clear(); ApplicationInstaller.acknowledgePackageInstallation(id); taskFinishedSpy.wait(spyTimeout); compare(taskFinishedSpy.count, 1); taskFinishedSpy.clear(); - compare(stateList[0], ApplicationObject.BeingUpdated) - compare(stateList[1], ApplicationObject.Installed) - stateList = [] + compare(stateList[0], ApplicationObject.BeingUpdated); + compare(stateList[1], ApplicationObject.Installed); + stateList = []; id = ApplicationInstaller.removePackage(appId, false, false); @@ -125,8 +142,8 @@ TestCase { compare(taskFinishedSpy.count, 1); taskFinishedSpy.clear(); - compare(stateList[0], ApplicationObject.BeingRemoved) - stateList = [] + compare(stateList[0], ApplicationObject.BeingRemoved); + stateList = []; // Cannot compare app.state any more, since app might already be dead verify(taskStateChangedSpy.count > 10); @@ -144,4 +161,87 @@ TestCase { for (var i = 0; i < taskStates.length; i++) compare(taskStateChangedSpy.signalArguments[i][1], taskStates[i], "- index: " + i); } + + function test_cancel_update() { + var id = ApplicationInstaller.startPackageInstallation("internal-0", "appv1.pkg") + taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); + compare(taskRequestingInstallationAcknowledgeSpy.count, 1); + compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id); + var appId = taskRequestingInstallationAcknowledgeSpy.signalArguments[0][1].id + compare(appId, "test.install.app"); + taskRequestingInstallationAcknowledgeSpy.clear(); + ApplicationInstaller.acknowledgePackageInstallation(id); + + taskFinishedSpy.wait(spyTimeout); + taskFinishedSpy.clear(); + + var app = ApplicationManager.application(appId); + compare(app.icon.toString().slice(-9), "icon1.png") + compare(app.version, "v1"); + + id = ApplicationInstaller.startPackageInstallation("internal-0", "appv2.pkg") + taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); + appId = taskRequestingInstallationAcknowledgeSpy.signalArguments[0][1].id + compare(appId, "test.install.app"); + taskRequestingInstallationAcknowledgeSpy.clear(); + ApplicationInstaller.cancelTask(id); + + taskFailedSpy.wait(spyTimeout); + taskFailedSpy.clear(); + + compare(app.icon.toString().slice(-9), "icon1.png") + compare(app.version, "v1"); + } + + function test_cancel_builtin_update() { + taskStateChangedSpy.clear() + var app = ApplicationManager.application("builtin.app"); + verify(app.builtIn); + compare(app.icon.toString().slice(-9), "icon1.png") + compare(app.version, "v1"); + + var id = ApplicationInstaller.startPackageInstallation("internal-0", "builtinv2.pkg") + taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); + compare(taskRequestingInstallationAcknowledgeSpy.count, 1); + compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id); + taskRequestingInstallationAcknowledgeSpy.clear(); + ApplicationInstaller.cancelTask(id); + + taskFailedSpy.wait(spyTimeout); + taskFailedSpy.clear(); + + verify(app.builtIn); + compare(app.icon.toString().slice(-9), "icon1.png") + compare(app.version, "v1"); + } + + function test_builtin_update_downgrade() { + taskStateChangedSpy.clear() + var id = ApplicationInstaller.startPackageInstallation("internal-0", "builtinv2.pkg") + taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); + compare(taskRequestingInstallationAcknowledgeSpy.count, 1); + compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id); + taskRequestingInstallationAcknowledgeSpy.clear(); + ApplicationInstaller.acknowledgePackageInstallation(id); + + taskFinishedSpy.wait(spyTimeout); + compare(ApplicationManager.get("builtin.app").version, "v2"); + taskFinishedSpy.clear(); + applicationChangedSpy.clear(); + + // remvove is a downgrade + verify(ApplicationInstaller.removePackage("builtin.app", false, true)); + taskFinishedSpy.wait(spyTimeout); + compare(taskFinishedSpy.count, 1); + taskFinishedSpy.clear(); + + compare(applicationChangedSpy.count, 5); + compare(applicationChangedSpy.signalArguments[3][0], "builtin.app"); + compare(applicationChangedSpy.signalArguments[3][1], []); + compare(applicationChangedSpy.signalArguments[4][1], ["isBlocked"]); + + var appmodel = ApplicationManager.get("builtin.app"); + verify(!appmodel.isBlocked); + compare(appmodel.version, "v1"); + } } -- cgit v1.2.1 From d835bb2e738c658cda134d85c1eff8a54cfc279d Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Wed, 18 Sep 2019 11:35:10 +0200 Subject: Fix logging output The messagePattern given in the am-config.yaml is set as env variable QT_MESSAGE_PATTERN. However this might be too late for the System UI (the env variable is evaluated by Qt before it is set by appman), so the pattern will be set explicitly with qSetMessagePattern. Change-Id: Ie8c9858feb600cd2b03ed5d6f77874235e0a05df Reviewed-by: Dominik Holland --- src/common-lib/logging.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/common-lib/logging.cpp b/src/common-lib/logging.cpp index f14629d0..24cc003d 100644 --- a/src/common-lib/logging.cpp +++ b/src/common-lib/logging.cpp @@ -334,11 +334,10 @@ void Logging::setFilterRules(const QStringList &rules) void Logging::setMessagePattern(const QString &pattern) { - if (!pattern.isEmpty()) { - if (!s_messagePatternDefined) { - qputenv("QT_MESSAGE_PATTERN", pattern.toLocal8Bit()); - s_messagePatternDefined = true; - } + if (!pattern.isEmpty() && !s_messagePatternDefined) { + qputenv("QT_MESSAGE_PATTERN", pattern.toLocal8Bit()); // pass on to application processes, however for the + qSetMessagePattern(pattern); // System UI this might be too late, so set pattern explicitly here. + s_messagePatternDefined = true; } } -- cgit v1.2.1 From 3cdf38084a6c905b3ddc65cd87d912eb656e9b7f Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Tue, 8 Oct 2019 17:05:27 +0200 Subject: Fix quoting in system-ui docs Change-Id: Ifb641df2440db29c0970a636cab970754de6efdf Reviewed-by: Dominik Holland --- doc/systemui.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/systemui.qdoc b/doc/systemui.qdoc index 5d413d51..ff800067 100644 --- a/doc/systemui.qdoc +++ b/doc/systemui.qdoc @@ -104,7 +104,7 @@ One example of a simple System UI is the one written for the "Hello World!" Syst \quotefromfile ../examples/applicationmanager/hello-world/system-ui.qml \skipto Item { -\printuntil window: model.window } } } } +\printuntil \section2 Notifications -- cgit v1.2.1 From f73ca6c1fa06d83fb44c7f56189c659b29db0ea0 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Tue, 8 Oct 2019 17:09:21 +0200 Subject: doc: Add C++ headers and source files to the list of example fileextensions This fixes the file listing in the custom-appman example and also makes sure that the example is properly listed in the QtCreator example panel. Change-Id: I2dd5e72ac3c93a410aa6f9229b18504add8db821 Reviewed-by: Robert Griebl --- doc/applicationmanager-project.qdocconf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/applicationmanager-project.qdocconf b/doc/applicationmanager-project.qdocconf index 144da1e9..d4446bd4 100644 --- a/doc/applicationmanager-project.qdocconf +++ b/doc/applicationmanager-project.qdocconf @@ -9,7 +9,7 @@ includepaths = -I . sources.fileextensions = "*.cpp *.qdoc *.mm *.qml" headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx" -examples.fileextensions = "*.qml *.yaml" +examples.fileextensions = "*.cpp *.h *.qml *.yaml" examples.imageextensions = "*.png *.jpg *.gif" headerdirs += \ -- cgit v1.2.1 From e056b469c5421117bcb05fb54ccd2973b7a7c81f Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Wed, 6 Nov 2019 13:50:14 +0100 Subject: am-app: Return with a warning if the appman-packager is not available Currently every project which uses the am-app feature fails with an error if the appman-packager exectuable is not available. Instead check for the executable before and return early with a warning. Change-Id: I6725d6d801baa3a60bbe381b3b42fe680dcbff3e Reviewed-by: Robert Griebl --- qmake-features/am-app.prf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qmake-features/am-app.prf b/qmake-features/am-app.prf index fe2f590a..0ca6d1fd 100644 --- a/qmake-features/am-app.prf +++ b/qmake-features/am-app.prf @@ -11,6 +11,10 @@ AM_MANIFEST_PATH = $$absolute_path($$AM_MANIFEST, $$_PRO_FILE_PWD_) # Call the appman-packager to convert the yaml to JSON to parse it here qtPrepareTool(APPMAN_PACKAGER, appman-packager, , system) +!exists($$APPMAN_PACKAGER): { + warning("Couldn't add the 'package' step, due to the missing appman-packager binary") + return() +} JSON = $$system($$APPMAN_PACKAGER yaml-to-json -i1 $$system_quote($$AM_MANIFEST_PATH)) parseJson(JSON, INFO)| error("Failed to parse appman-packager output.") -- cgit v1.2.1 From a334d8cca02be61891d87f38c9e530ee226b3ffd Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Fri, 8 Nov 2019 12:38:51 +0100 Subject: Bump module version to 5.13.2 Change-Id: Ibb9acd12252d7a5489b6ccf7919d1ba938eb62e8 Fixes: AUTOSUITE-1330 Reviewed-by: Robert Griebl --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index 8257f184..ce2794aa 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,6 +1,6 @@ load(qt_build_config) -MODULE_VERSION = 5.13.1 +MODULE_VERSION = 5.13.2 SOURCE_DIR=$$PWD BUILD_DIR=$$shadowed($$PWD) -- cgit v1.2.1 From 161bd31824126ee38a33b9267347440af09cabd8 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Thu, 10 Oct 2019 13:43:46 +0200 Subject: Fix error string in sudo client The client error string was not updated when the server was called directly (short-circuite). Change-Id: Ie4ed81008f16eb89e3397a195f4864300abfa18b Reviewed-by: Robert Griebl --- src/installer-lib/sudo.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/installer-lib/sudo.cpp b/src/installer-lib/sudo.cpp index a9d661fe..b7e5578b 100644 --- a/src/installer-lib/sudo.cpp +++ b/src/installer-lib/sudo.cpp @@ -349,8 +349,11 @@ QByteArray SudoClient::call(const QByteArray &msg) { QMutexLocker locker(&m_mutex); - if (m_shortCircuit) - return m_shortCircuit->receive(msg); + if (m_shortCircuit) { + const QByteArray res = m_shortCircuit->receive(msg); + m_errorString = m_shortCircuit->lastError(); + return res; + } #ifdef Q_OS_LINUX if (m_socket >= 0) { -- cgit v1.2.1 From 3bc48291f9443e435f20755d8ddc62ba0b13d40c Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Mon, 11 Nov 2019 14:56:45 +0100 Subject: Don't build appman-packager and appman-uploader when cross compiling Both tools are native tools and are not supposed to be cross-compiled. To support the yocto SDK creation the tools can be forced to be build by using the 'tools-only' config option. Change-Id: I89e34b3bb18b59dde1a807949eb41d1ba535da7b Reviewed-by: Robert Griebl --- src/src.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/src.pro b/src/src.pro index 63e95d48..590b5811 100644 --- a/src/src.pro +++ b/src/src.pro @@ -113,7 +113,7 @@ SUBDIRS = \ tools_launcher_qml \ } -!android:SUBDIRS += \ +!cross_compile | tools-only:SUBDIRS += \ tools_packager \ tools_uploader \ -- cgit v1.2.1 From 7092e708a37979ed197c79f4f3d46858b92d001c Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Fri, 18 Oct 2019 12:30:42 +0200 Subject: Fix issues in ProcessStatus - Moved smaps parsing to dedicated thread - Made memory reporting optional - Support CPU loads greater than 1.0 Task-number: AUTOSUITE-1310 Change-Id: Ic7e647a5270b1be2e3ec19c5122dd29156ea0a88 Reviewed-by: Robert Griebl --- src/manager-lib/processstatus.cpp | 66 +++++++++++++++++++++++++++++++++------ src/manager-lib/processstatus.h | 11 ++++++- src/monitor-lib/processreader.cpp | 56 +++++++++++++++++---------------- src/monitor-lib/processreader.h | 4 +++ 4 files changed, 100 insertions(+), 37 deletions(-) diff --git a/src/manager-lib/processstatus.cpp b/src/manager-lib/processstatus.cpp index 6b23a853..bc05f834 100644 --- a/src/manager-lib/processstatus.cpp +++ b/src/manager-lib/processstatus.cpp @@ -125,25 +125,53 @@ \endtable */ +/*! + \qmlsignal ProcessStatus::memoryReportingChanged(memoryVirtual, memoryRss, memoryPss) + + This signal is emitted after \l{ProcessStatus::update()}{update()} has been called and the + memory usage values have been refreshed. The arguments are key-value pairs with the keys listed + in the table \l{supported-keys}{above}. +*/ + + QT_USE_NAMESPACE_AM QThread *ProcessStatus::m_workerThread = nullptr; +int ProcessStatus::m_instanceCount = 0; ProcessStatus::ProcessStatus(QObject *parent) : QObject(parent) { - if (!m_workerThread) { + if (m_instanceCount == 0) { m_workerThread = new QThread; m_workerThread->start(); } + ++m_instanceCount; + + m_reader = new ProcessReader; + m_reader->moveToThread(m_workerThread); - m_reader.reset(new ProcessReader); - connect(m_reader.data(), &ProcessReader::updated, this, [this]() { + connect(m_reader, &ProcessReader::updated, this, [this]() { emit cpuLoadChanged(); fetchMemoryReadings(); + emit memoryReportingChanged(m_memoryVirtual, m_memoryRss, m_memoryPss); m_pendingUpdate = false; }); - connect(this, &ProcessStatus::processIdChanged, m_reader.data(), &ProcessReader::setProcessId); + connect(this, &ProcessStatus::processIdChanged, m_reader, &ProcessReader::setProcessId); + connect(this, &ProcessStatus::memoryReportingEnabledChanged, m_reader, &ProcessReader::enableMemoryReporting); +} + +ProcessStatus::~ProcessStatus() +{ + m_reader->deleteLater(); + + --m_instanceCount; + if (m_instanceCount == 0) { + m_workerThread->quit(); + m_workerThread->wait(); + delete m_workerThread; + m_workerThread = nullptr; + } } /*! @@ -155,7 +183,7 @@ void ProcessStatus::update() { if (!m_pendingUpdate) { m_pendingUpdate = true; - QMetaObject::invokeMethod(m_reader.data(), &ProcessReader::update); + QMetaObject::invokeMethod(m_reader, &ProcessReader::update); } } @@ -250,8 +278,7 @@ qint64 ProcessStatus::processId() const */ qreal ProcessStatus::cpuLoad() { - quint32 value = m_reader->cpuLoad.load(); - return ((qreal)value) / ((qreal)std::numeric_limits::max()); + return m_reader->cpuLoad.load() / ProcessReader::cpuLoadFactor; } void ProcessStatus::fetchMemoryReadings() @@ -266,8 +293,6 @@ void ProcessStatus::fetchMemoryReadings() m_memoryPss[qSL("total")] = quint64(m_reader->totalPss.load()) << 10; m_memoryPss[qSL("text")] = quint64(m_reader->textPss.load()) << 10; m_memoryPss[qSL("heap")] = quint64(m_reader->heapPss.load()) << 10; - - emit memoryReportingChanged(m_memoryVirtual, m_memoryRss, m_memoryPss); } /*! @@ -324,6 +349,29 @@ QVariantMap ProcessStatus::memoryPss() const return m_memoryPss; } +/*! + \qmlproperty bool ProcessStatus::memoryReportingEnabled + + A boolean value that determines whether the memory properties are refreshed each time + \l{ProcessStatus::update()}{update()} is called. The default value is \c true. In your System + UI, the process of determining memory consumption adds additional load to the CPU, affecting + the \c cpuLoad value. If \c cpuLoad needs to be kept accurate, consider disabling memory + reporting. +*/ + +bool ProcessStatus::isMemoryReportingEnabled() const +{ + return m_memoryReportingEnabled; +} + +void ProcessStatus::setMemoryReportingEnabled(bool enabled) +{ + if (enabled != m_memoryReportingEnabled) { + m_memoryReportingEnabled = enabled; + emit memoryReportingEnabledChanged(m_memoryReportingEnabled); + } +} + /*! \qmlproperty list ProcessStatus::roleNames \readonly diff --git a/src/manager-lib/processstatus.h b/src/manager-lib/processstatus.h index b233aced..282ad13f 100644 --- a/src/manager-lib/processstatus.h +++ b/src/manager-lib/processstatus.h @@ -66,9 +66,12 @@ class ProcessStatus : public QObject Q_PROPERTY(QVariantMap memoryVirtual READ memoryVirtual NOTIFY memoryReportingChanged) Q_PROPERTY(QVariantMap memoryRss READ memoryRss NOTIFY memoryReportingChanged) Q_PROPERTY(QVariantMap memoryPss READ memoryPss NOTIFY memoryReportingChanged) + Q_PROPERTY(bool memoryReportingEnabled READ isMemoryReportingEnabled WRITE setMemoryReportingEnabled + NOTIFY memoryReportingEnabledChanged) Q_PROPERTY(QStringList roleNames READ roleNames CONSTANT) public: ProcessStatus(QObject *parent = nullptr); + ~ProcessStatus(); QStringList roleNames() const; @@ -84,12 +87,16 @@ public: QVariantMap memoryRss() const; QVariantMap memoryPss() const; + bool isMemoryReportingEnabled() const; + void setMemoryReportingEnabled(bool enabled); + signals: void applicationIdChanged(const QString &applicationId); void processIdChanged(qint64 processId); void cpuLoadChanged(); void memoryReportingChanged(const QVariantMap &memoryVirtual, const QVariantMap &memoryRss, const QVariantMap &memoryPss); + void memoryReportingEnabledChanged(bool enabled); private slots: void onRunStateChanged(Am::RunState state); @@ -104,12 +111,14 @@ private: QVariantMap m_memoryVirtual; QVariantMap m_memoryRss; QVariantMap m_memoryPss; + bool m_memoryReportingEnabled = true; QPointer m_application; bool m_pendingUpdate = false; - QScopedPointer m_reader; + ProcessReader *m_reader; static QThread *m_workerThread; + static int m_instanceCount; }; QT_END_NAMESPACE_AM diff --git a/src/monitor-lib/processreader.cpp b/src/monitor-lib/processreader.cpp index b89e9b3c..e8b760a9 100644 --- a/src/monitor-lib/processreader.cpp +++ b/src/monitor-lib/processreader.cpp @@ -50,14 +50,6 @@ # include #endif -namespace { - static uint parseValue(const char *pl) { - while (*pl && (*pl < '0' || *pl > '9')) - pl++; - return static_cast(strtoul(pl, nullptr, 10)); - } -} - QT_USE_NAMESPACE_AM void ProcessReader::setProcessId(qint64 pid) @@ -67,32 +59,36 @@ void ProcessReader::setProcessId(qint64 pid) openCpuLoad(); } +void ProcessReader::enableMemoryReporting(bool enabled) +{ + m_memoryReportingEnabled = enabled; + if (!m_memoryReportingEnabled) + zeroMemory(); +} + void ProcessReader::update() { - // read cpu - { - qreal cpuLoadFloat = readCpuLoad(); - quint32 value = ((qreal)std::numeric_limits::max()) * cpuLoadFloat; - cpuLoad.store(value); - } + cpuLoad.store(static_cast(cpuLoadFactor * readCpuLoad())); - { - if (!readMemory()) { - totalVm.store(0); - totalRss.store(0); - totalPss.store(0); - textVm.store(0); - textRss.store(0); - textPss.store(0); - heapVm.store(0); - heapRss.store(0); - heapPss.store(0); - } - } + if (m_memoryReportingEnabled && !readMemory()) + zeroMemory(); emit updated(); } +void ProcessReader::zeroMemory() +{ + totalVm.store(0); + totalRss.store(0); + totalPss.store(0); + textVm.store(0); + textRss.store(0); + textPss.store(0); + heapVm.store(0); + heapRss.store(0); + heapPss.store(0); +} + #if defined(Q_OS_LINUX) void ProcessReader::openCpuLoad() @@ -144,6 +140,12 @@ bool ProcessReader::readMemory() return readSmaps(smapsFile); } +static uint parseValue(const char *pl) { + while (*pl && (*pl < '0' || *pl > '9')) + pl++; + return static_cast(strtoul(pl, nullptr, 10)); +} + bool ProcessReader::readSmaps(const QByteArray &smapsFile) { quint32 _totalVm = 0; diff --git a/src/monitor-lib/processreader.h b/src/monitor-lib/processreader.h index e135101c..9d63790f 100644 --- a/src/monitor-lib/processreader.h +++ b/src/monitor-lib/processreader.h @@ -60,6 +60,7 @@ class ProcessReader : public QObject { public slots: void update(); void setProcessId(qint64 pid); + void enableMemoryReporting(bool enabled); signals: void updated(); @@ -81,11 +82,13 @@ public: // it's public solely for testing purposes bool readSmaps(const QByteArray &smapsFile); #endif + static constexpr qreal cpuLoadFactor = 1000000.0; private: void openCpuLoad(); qreal readCpuLoad(); bool readMemory(); + void zeroMemory(); #if defined(Q_OS_LINUX) QScopedPointer m_statReader; @@ -94,6 +97,7 @@ private: quint64 m_lastCpuUsage = 0.0; qint64 m_pid = 0; + bool m_memoryReportingEnabled = true; }; QT_END_NAMESPACE_AM -- cgit v1.2.1 From fda6ab921c8b90214f41ea8508c0f86ed5e45106 Mon Sep 17 00:00:00 2001 From: Mostafa Emami Date: Wed, 20 Nov 2019 15:48:07 +0100 Subject: Change P2P dbus address Privatization of /tmp through mount namespaces (tmpfs) and bind mount the P2P sockets per tools with static definition, like systemd, requires a statically known path deeper than simply /tmp Change-Id: I422a04753a84c27127ffd8d5e5c7ace5797d46c1 Reviewed-by: Robert Griebl --- src/manager-lib/nativeruntime.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/manager-lib/nativeruntime.cpp b/src/manager-lib/nativeruntime.cpp index 3c1865b6..408efa3e 100644 --- a/src/manager-lib/nativeruntime.cpp +++ b/src/manager-lib/nativeruntime.cpp @@ -105,8 +105,9 @@ NativeRuntime::NativeRuntime(AbstractContainer *container, Application *app, Nat , m_isQuickLauncher(app == nullptr) , m_startedViaLauncher(manager->identifier() != qL1S("native")) { + QDir().mkdir(qSL("/tmp/dbus-qtam")); QString dbusAddress = QUuid::createUuid().toString().mid(1,36); - m_applicationInterfaceServer = new QDBusServer(qSL("unix:path=/tmp/dbus-qtam-") + dbusAddress, this); + m_applicationInterfaceServer = new QDBusServer(qSL("unix:path=/tmp/dbus-qtam/dbus-qtam-") + dbusAddress, this); connect(m_applicationInterfaceServer, &QDBusServer::newConnection, this, [this](const QDBusConnection &connection) { -- cgit v1.2.1 From 0c69e083ac5f5e97c9da09bdf1bd979dbe87ea93 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Tue, 14 Jan 2020 12:30:55 +0100 Subject: Update demangle buffer Function __cxa_demangle will reallocate the output buffer, if it is too short. To avoid a potential dangling buffer (pointer), it is always updated. Increased the initial buffer size, as well. Change-Id: I11f331e51fa28f940d4843740c0b0137d8d47dc4 Reviewed-by: Robert Griebl --- src/common-lib/crashhandler.cpp | 10 +++++----- .../crash/apps/tld.test.crash/terminator2/qmlterminator2.cpp | 7 ++++++- tests/qml/crash/tst_crash.qml | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/common-lib/crashhandler.cpp b/src/common-lib/crashhandler.cpp index 1ec8a83f..480dca9a 100644 --- a/src/common-lib/crashhandler.cpp +++ b/src/common-lib/crashhandler.cpp @@ -145,7 +145,7 @@ static void initBacktrace() getOutputInformation(&useAnsiColor, nullptr, nullptr); - demangleBufferSize = 512; + demangleBufferSize = 768; demangleBuffer = static_cast(malloc(demangleBufferSize)); UnixSignalHandler::instance()->install(UnixSignalHandler::RawSignalHandler, @@ -171,7 +171,7 @@ static void initBacktrace() const char *typeName = type->name(); if (typeName) { int status; - abi::__cxa_demangle(typeName, demangleBuffer, &demangleBufferSize, &status); + demangleBuffer = abi::__cxa_demangle(typeName, demangleBuffer, &demangleBufferSize, &status); if (status == 0 && *demangleBuffer) { typeName = demangleBuffer; } @@ -271,7 +271,7 @@ static void printCrashInfo(PrintDestination dest, const char *why, int stackFram int level = static_cast(data)->level; if (symname) { int status; - abi::__cxa_demangle(symname, demangleBuffer, &demangleBufferSize, &status); + demangleBuffer = abi::__cxa_demangle(symname, demangleBuffer, &demangleBufferSize, &status); if (status == 0 && *demangleBuffer) printBacktraceLine(level, demangleBuffer, pc); @@ -286,7 +286,7 @@ static void printCrashInfo(PrintDestination dest, const char *why, int stackFram const char *function) -> int { if (function) { int status; - abi::__cxa_demangle(function, demangleBuffer, &demangleBufferSize, &status); + demangleBuffer = abi::__cxa_demangle(function, demangleBuffer, &demangleBufferSize, &status); printBacktraceLine(static_cast(data)->level, (status == 0 && *demangleBuffer) ? demangleBuffer : function, @@ -344,7 +344,7 @@ static void printCrashInfo(PrintDestination dest, const char *why, int stackFram *end = 0; int status; - abi::__cxa_demangle(function, demangleBuffer, &demangleBufferSize, &status); + demangleBuffer = abi::__cxa_demangle(function, demangleBuffer, &demangleBufferSize, &status); if (status == 0 && *demangleBuffer) { printMsg(" %3d: %s [+%s]", i, demangleBuffer, offset + 1); diff --git a/tests/qml/crash/apps/tld.test.crash/terminator2/qmlterminator2.cpp b/tests/qml/crash/apps/tld.test.crash/terminator2/qmlterminator2.cpp index 64210f63..05e73934 100644 --- a/tests/qml/crash/apps/tld.test.crash/terminator2/qmlterminator2.cpp +++ b/tests/qml/crash/apps/tld.test.crash/terminator2/qmlterminator2.cpp @@ -47,6 +47,11 @@ void TerminatorPlugin::registerTypes(const char *uri) } +static void abortWithVeryLongSymbolNameOnTheStack800CharactersLong_CallMeIshmaelSomeYearsAgoNeverMindHowLongPreciselyHavingLittleOrNoMoneyInMyPurseAndNothingParticularToInterestMeOnShoreIThoughIWouldSailAboutALittlAndSeeTheWateryPartOfTheWorldItIsAWayIHaveOfDrivingOffTheSpleenAndRegulatingTheCirculationWhenenverIFindMyselfGrowingGrimAboutTheMouthWheneverItIsADampDrizzlyNovemberInMySoulWheneverIFindMyselfInvoluntarilyPausingBeforeCoffinWarehousesAndBringingUpTheRearOfEveryFuneralIMeetAndEspeciallyWheneverMyHyposGetSuchAnUpperHandOfMeThatItRequiresAStrongMoralPrincipleToPreventMeFromDeliberatelySteppingIntoTheStreetAndMethodicallyKnockingPeoplesHatsOffThenIAccountItHighTimeToGetToSeaAsSoonAsICanThisIsMySubstituteForPistolAndBallWithAPhilosophicalFlourishCatoThrowsHimselfUponHisSwordIQuietlyTakeToTheShip() +{ + ::abort(); +} + void Terminator::accessIllegalMemory() const { *(int*)1 = 42; @@ -76,7 +81,7 @@ void Terminator::divideByZero() const void Terminator::abort() const { - ::abort(); + abortWithVeryLongSymbolNameOnTheStack800CharactersLong_CallMeIshmaelSomeYearsAgoNeverMindHowLongPreciselyHavingLittleOrNoMoneyInMyPurseAndNothingParticularToInterestMeOnShoreIThoughIWouldSailAboutALittlAndSeeTheWateryPartOfTheWorldItIsAWayIHaveOfDrivingOffTheSpleenAndRegulatingTheCirculationWhenenverIFindMyselfGrowingGrimAboutTheMouthWheneverItIsADampDrizzlyNovemberInMySoulWheneverIFindMyselfInvoluntarilyPausingBeforeCoffinWarehousesAndBringingUpTheRearOfEveryFuneralIMeetAndEspeciallyWheneverMyHyposGetSuchAnUpperHandOfMeThatItRequiresAStrongMoralPrincipleToPreventMeFromDeliberatelySteppingIntoTheStreetAndMethodicallyKnockingPeoplesHatsOffThenIAccountItHighTimeToGetToSeaAsSoonAsICanThisIsMySubstituteForPistolAndBallWithAPhilosophicalFlourishCatoThrowsHimselfUponHisSwordIQuietlyTakeToTheShip(); } void Terminator::raise(int sig) const diff --git a/tests/qml/crash/tst_crash.qml b/tests/qml/crash/tst_crash.qml index 89ae9a9b..8360652b 100644 --- a/tests/qml/crash/tst_crash.qml +++ b/tests/qml/crash/tst_crash.qml @@ -66,10 +66,10 @@ TestCase { return [ { tag: "gracefully" }, { tag: "illegalMemory" }, { tag: "illegalMemoryInThread" }, - { tag: "unhandledException" } ]; + { tag: "unhandledException" }, + { tag: "abort" } ]; //{ tag: "stackOverflow" }, //{ tag: "divideByZero" }, - //{ tag: "abort" }, //{ tag: "raise" } ]; } -- cgit v1.2.1