diff --git a/src/core/operationrunner.cpp b/src/core/operationrunner.cpp index d24617b..1880bf6 100644 --- a/src/core/operationrunner.cpp +++ b/src/core/operationrunner.cpp @@ -1,128 +1,121 @@ /************************************************************************* * Copyright (C) 2008 by Volker Lanz * * Copyright (C) 2016 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 3 of * * the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see .* *************************************************************************/ #include "core/operationrunner.h" #include "core/operationstack.h" #include "ops/operation.h" #include "util/report.h" #include #include #include /** Constructs an OperationRunner. @param ostack the OperationStack to act on */ OperationRunner::OperationRunner(QObject* parent, OperationStack& ostack) : QThread(parent), m_OperationStack(ostack), m_Report(nullptr), m_SuspendMutex(), m_Cancelling(false) { } /** Runs the operations in the OperationStack. */ void OperationRunner::run() { Q_ASSERT(m_Report); setCancelling(false); bool status = true; // Disable Plasma removable device automounting QStringList modules; QDBusConnection bus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, QStringLiteral("sessionBus")); QDBusInterface kdedInterface( QStringLiteral("org.kde.kded5"), QStringLiteral("/kded"), QStringLiteral("org.kde.kded5"), bus ); QDBusReply reply = kdedInterface.call( QStringLiteral("loadedModules") ); if ( reply.isValid() ) modules = reply.value(); QString automounterService = QStringLiteral("device_automounter"); bool automounter = modules.contains(automounterService); if (automounter) kdedInterface.call( QStringLiteral("unloadModule"), automounterService ); for (int i = 0; i < numOperations(); i++) { suspendMutex().lock(); + suspendMutex().unlock(); if (!status || isCancelling()) { - suspendMutex().unlock(); break; } Operation* op = operationStack().operations()[i]; op->setStatus(Operation::StatusRunning); emit opStarted(i + 1, op); connect(op, &Operation::progress, this, &OperationRunner::progressSub); status = op->execute(report()); op->preview(); disconnect(op, &Operation::progress, this, &OperationRunner::progressSub); emit opFinished(i + 1, op); - - suspendMutex().unlock(); - - // Sleep a little to give others a chance to suspend us. This should normally not be - // required -- is it possible that the compiler just optimizes our unlock/lock away - // if we don't sleep? - msleep(5); } if (automounter) kdedInterface.call( QStringLiteral("loadModule"), automounterService ); if (!status) emit error(); else if (isCancelling()) emit cancelled(); else emit finished(); } /** @return the number of Operations to run */ qint32 OperationRunner::numOperations() const { return operationStack().operations().size(); } /** @return the number of Jobs to run */ qint32 OperationRunner::numJobs() const { qint32 result = 0; for (const auto &op : operationStack().operations()) result += op->jobs().size(); return result; } /** @param op the number of the Operation to get a description for @return the Operation's description */ QString OperationRunner::description(qint32 op) const { Q_ASSERT(op >= 0); Q_ASSERT(op < operationStack().size()); return operationStack().operations()[op]->description(); } diff --git a/src/plugins/dummy/pmdummybackendplugin.json b/src/plugins/dummy/pmdummybackendplugin.json index c230985..5bb0fb6 100644 --- a/src/plugins/dummy/pmdummybackendplugin.json +++ b/src/plugins/dummy/pmdummybackendplugin.json @@ -1,46 +1,49 @@ { "KPlugin": { "Authors": [ { "Email": "vl@fidra.de", "Name": "Volker Lanz", "Name[x-test]": "xxVolker Lanzxx" } ], "Category": "BackendPlugin", "Description": "A KDE Partition Manager dummy backend for testing purposes.", "Description[ca@valencia]": "Un dorsal fals del gestor de particions del KDE amb la finalitat de fer proves.", "Description[ca]": "Un dorsal fals del gestor de particions del KDE amb la finalitat de fer proves.", "Description[de]": "Ein Dummy-Backend für die KDE-Partitionsverwaltung zu Testzwecken.", + "Description[es]": "Un motor de simulación para el gestor de particiones de KDE para hacer pruebas.", "Description[nl]": "Dummy backend van KDE-partitiebeheerder voor testdoeleinden", "Description[pt]": "Uma infra-estrutura de testes para o Gestor de Partições do KDE.", "Description[sk]": "Testovací program v pozadí KDE Správcu partícií", "Description[sv]": "Ett bakgrundsprogram till KDE:s partitionshanterare i testsyfte.", "Description[uk]": "Тестовий додаток сервера Керування розділами KDE.", "Description[x-test]": "xxA KDE Partition Manager dummy backend for testing purposes.xx", "EnabledByDefault": true, "Icon": "preferences-plugin", "Id": "pmdummybackendplugin", "License": "GPL", "Name": "KDE Partition Manager Dummy Backend", "Name[ca@valencia]": "Dorsal fals del gestor de particions del KDE", "Name[ca]": "Dorsal fals del gestor de particions del KDE", + "Name[cs]": "Podpůrná vrstva pro správce diskových oddílů pro KDE", "Name[de]": "KDE-Partitionsverwaltung Dummy-Backend", + "Name[es]": "Motor de simulación para el gestor de particiones de KDE", "Name[fi]": "KDE:n osionhallinnan valetaustaosa", "Name[fr]": "Moteur de test pour le gestionnaire de partitions de KDE", "Name[id]": "Backend Tiruan Pengelola Partisi KDE", "Name[it]": "Motore fittizio del gestore delle partizioni di KDE", "Name[nb]": "Attrapp-motor for KDE partisjonsbehandler", "Name[nl]": "Dummy backend van KDE-partitiebeheerder", "Name[pt]": "Infra-Estrutura de Testes para o Gestor de Partições do KDE", "Name[sk]": "Testovací program v pozadí KDE Správcu partícií", "Name[sv]": "KDE:s partitionshanterare bakgrundsprogram för test", "Name[uk]": "Тестовий додаток сервера Керування розділами KDE", "Name[x-test]": "xxKDE Partition Manager Dummy Backendxx", "ServiceTypes": [ "PartitionManager/Plugin" ], "Version": "1", "Website": "http://www.partitionmanager.org" } }