diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 324b74d99..fffcc264f 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -30,6 +30,7 @@ calamares_add_plugin( partition DeviceModel.cpp PartitionCoreModule.cpp PartitionInfo.cpp + PartitionJob.cpp PartitionModel.cpp PartitionPage.cpp PartitionViewStep.cpp diff --git a/src/modules/partition/CreatePartitionJob.cpp b/src/modules/partition/CreatePartitionJob.cpp index 4e5059435..f6ec2a01e 100644 --- a/src/modules/partition/CreatePartitionJob.cpp +++ b/src/modules/partition/CreatePartitionJob.cpp @@ -17,6 +17,7 @@ */ #include +#include #include @@ -36,8 +37,8 @@ #include CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition ) - : m_device( device ) - , m_partition( partition ) + : PartitionJob( partition ) + , m_device( device ) { } diff --git a/src/modules/partition/CreatePartitionJob.h b/src/modules/partition/CreatePartitionJob.h index 705724af6..bd3cee980 100644 --- a/src/modules/partition/CreatePartitionJob.h +++ b/src/modules/partition/CreatePartitionJob.h @@ -19,13 +19,13 @@ #ifndef CREATEPARTITIONJOB_H #define CREATEPARTITIONJOB_H -#include +#include class Device; class Partition; class FileSystem; -class CreatePartitionJob : public Calamares::Job +class CreatePartitionJob : public PartitionJob { Q_OBJECT public: @@ -39,14 +39,8 @@ public: return m_device; } - Partition* partition() const - { - return m_partition; - } - private: Device* m_device; - Partition* m_partition; }; #endif /* CREATEPARTITIONJOB_H */ diff --git a/src/modules/partition/DeletePartitionJob.cpp b/src/modules/partition/DeletePartitionJob.cpp index 1bb1e665e..b5f090494 100644 --- a/src/modules/partition/DeletePartitionJob.cpp +++ b/src/modules/partition/DeletePartitionJob.cpp @@ -30,8 +30,8 @@ #include DeletePartitionJob::DeletePartitionJob( Device* device, Partition* partition ) - : m_device( device ) - , m_partition( partition ) + : PartitionJob( partition ) + , m_device( device ) { } diff --git a/src/modules/partition/DeletePartitionJob.h b/src/modules/partition/DeletePartitionJob.h index 3225c461c..eb794ea0e 100644 --- a/src/modules/partition/DeletePartitionJob.h +++ b/src/modules/partition/DeletePartitionJob.h @@ -19,13 +19,13 @@ #ifndef DELETEPARTITIONJOB_H #define DELETEPARTITIONJOB_H -#include +#include class Device; class Partition; class FileSystem; -class DeletePartitionJob : public Calamares::Job +class DeletePartitionJob : public PartitionJob { Q_OBJECT public: @@ -39,14 +39,8 @@ public: return m_device; } - Partition* partition() const - { - return m_partition; - } - private: Device* m_device; - Partition* m_partition; FileSystem* m_fs; }; diff --git a/src/modules/partition/PartitionCoreModule.cpp b/src/modules/partition/PartitionCoreModule.cpp index dfe4d9302..1a91d60e8 100644 --- a/src/modules/partition/PartitionCoreModule.cpp +++ b/src/modules/partition/PartitionCoreModule.cpp @@ -257,6 +257,15 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition ) } else { + // Remove any PartitionJob on this partition + for ( auto it = jobs.begin(); it != jobs.end(); ) + { + PartitionJob* job = qobject_cast< PartitionJob* >( it->data() ); + if ( job && job->partition() == partition ) + it = jobs.erase( it ); + else + ++it; + } DeletePartitionJob* job = new DeletePartitionJob( device, partition ); job->updatePreview(); jobs << Calamares::job_ptr( job ); diff --git a/src/modules/partition/PartitionJob.cpp b/src/modules/partition/PartitionJob.cpp new file mode 100644 index 000000000..ec4ff3ee7 --- /dev/null +++ b/src/modules/partition/PartitionJob.cpp @@ -0,0 +1,23 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * + * Calamares 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. + * + * Calamares 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 Calamares. If not, see . + */ + +#include + +PartitionJob::PartitionJob( Partition* partition ) + : m_partition( partition ) +{} diff --git a/src/modules/partition/PartitionJob.h b/src/modules/partition/PartitionJob.h new file mode 100644 index 000000000..a7579ae06 --- /dev/null +++ b/src/modules/partition/PartitionJob.h @@ -0,0 +1,44 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * + * Calamares 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. + * + * Calamares 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 Calamares. If not, see . + */ + +#ifndef PARTITIONJOB_H +#define PARTITIONJOB_H + +#include + +class Partition; + +/** + * Base class for jobs which affect a partition + */ +class PartitionJob : public Calamares::Job +{ + Q_OBJECT +public: + PartitionJob( Partition* partition ); + + Partition* partition() const + { + return m_partition; + } + +protected: + Partition* m_partition; +}; + +#endif /* PARTITIONJOB_H */ diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index ac813127f..7eabad0a2 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -5,6 +5,8 @@ set( jobtests_SRCS ${PartitionModule_SOURCE_DIR}/CreatePartitionJob.cpp ${PartitionModule_SOURCE_DIR}/CreatePartitionTableJob.cpp ${PartitionModule_SOURCE_DIR}/DeletePartitionJob.cpp + ${PartitionModule_SOURCE_DIR}/PartitionInfo.cpp + ${PartitionModule_SOURCE_DIR}/PartitionJob.cpp ${PartitionModule_SOURCE_DIR}/PMUtils.cpp JobTests.cpp )