PCM::createPartition now includes SetPartFlagsJob.
Also remove outstanding SetPartFlagsJobs when deleting a new partition.
This commit is contained in:
parent
3fa7318a37
commit
e9d2312002
@ -202,7 +202,9 @@ PartitionCoreModule::createPartitionTable( Device* device, PartitionTable::Table
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::createPartition( Device* device, Partition* partition )
|
PartitionCoreModule::createPartition( Device *device,
|
||||||
|
Partition *partition,
|
||||||
|
PartitionTable::Flags flags )
|
||||||
{
|
{
|
||||||
auto deviceInfo = infoForDevice( device );
|
auto deviceInfo = infoForDevice( device );
|
||||||
Q_ASSERT( deviceInfo );
|
Q_ASSERT( deviceInfo );
|
||||||
@ -213,6 +215,12 @@ PartitionCoreModule::createPartition( Device* device, Partition* partition )
|
|||||||
|
|
||||||
deviceInfo->jobs << Calamares::job_ptr( job );
|
deviceInfo->jobs << Calamares::job_ptr( job );
|
||||||
|
|
||||||
|
if ( flags != PartitionTable::FlagNone )
|
||||||
|
{
|
||||||
|
SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags );
|
||||||
|
deviceInfo->jobs << Calamares::job_ptr( fJob );
|
||||||
|
}
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,6 +249,16 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
|
|||||||
QList< Calamares::job_ptr >& jobs = deviceInfo->jobs;
|
QList< Calamares::job_ptr >& jobs = deviceInfo->jobs;
|
||||||
if ( partition->state() == Partition::StateNew )
|
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
|
// Find matching CreatePartitionJob
|
||||||
auto it = std::find_if( jobs.begin(), jobs.end(), [ partition ]( Calamares::job_ptr job )
|
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";
|
cDebug() << "Failed to remove partition from preview";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
device->partitionTable()->updateUnallocated( *device );
|
device->partitionTable()->updateUnallocated( *device );
|
||||||
jobs.erase( it );
|
jobs.erase( it );
|
||||||
// The partition is no longer referenced by either a job or the device
|
// The partition is no longer referenced by either a job or the device
|
||||||
|
@ -81,7 +81,8 @@ public:
|
|||||||
|
|
||||||
void createPartitionTable( Device* device, PartitionTable::TableType type );
|
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 );
|
void deletePartition( Device* device, Partition* partition );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user