From e9d2312002723d10c0a1818a0a0f9ce79e8ba761 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Tue, 8 Mar 2016 16:25:43 +0100 Subject: [PATCH] PCM::createPartition now includes SetPartFlagsJob. Also remove outstanding SetPartFlagsJobs when deleting a new partition. --- .../partition/core/PartitionCoreModule.cpp | 21 ++++++++++++++++++- .../partition/core/PartitionCoreModule.h | 3 ++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index dd1b74426..d38025e8b 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -202,7 +202,9 @@ PartitionCoreModule::createPartitionTable( Device* device, PartitionTable::Table } void -PartitionCoreModule::createPartition( Device* device, Partition* partition ) +PartitionCoreModule::createPartition( Device *device, + Partition *partition, + PartitionTable::Flags flags ) { auto deviceInfo = infoForDevice( device ); Q_ASSERT( deviceInfo ); @@ -213,6 +215,12 @@ PartitionCoreModule::createPartition( Device* device, Partition* partition ) deviceInfo->jobs << Calamares::job_ptr( job ); + if ( flags != PartitionTable::FlagNone ) + { + SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags ); + deviceInfo->jobs << Calamares::job_ptr( fJob ); + } + refresh(); } @@ -241,6 +249,16 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition ) QList< Calamares::job_ptr >& jobs = deviceInfo->jobs; if ( partition->state() == Partition::StateNew ) { + // First remove matching SetPartFlagsJobs + for ( auto it = jobs.begin(); it != jobs.end(); ) + { + SetPartFlagsJob* job = qobject_cast< SetPartFlagsJob* >( it->data() ); + if ( job && job->partition() == partition ) + it = jobs.erase( it ); + else + ++it; + } + // Find matching CreatePartitionJob auto it = std::find_if( jobs.begin(), jobs.end(), [ partition ]( Calamares::job_ptr job ) { @@ -258,6 +276,7 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition ) cDebug() << "Failed to remove partition from preview"; return; } + device->partitionTable()->updateUnallocated( *device ); jobs.erase( it ); // The partition is no longer referenced by either a job or the device diff --git a/src/modules/partition/core/PartitionCoreModule.h b/src/modules/partition/core/PartitionCoreModule.h index 27924e2b5..88e6ca55c 100644 --- a/src/modules/partition/core/PartitionCoreModule.h +++ b/src/modules/partition/core/PartitionCoreModule.h @@ -81,7 +81,8 @@ public: void createPartitionTable( Device* device, PartitionTable::TableType type ); - void createPartition( Device* device, Partition* partition ); + void createPartition( Device* device, Partition* partition, + PartitionTable::Flags flags = PartitionTable::FlagNone ); void deletePartition( Device* device, Partition* partition );