[partition] When format is selected, clear out existing jobs
When editing a partition multiple times, do not leave jobs from previous edits around. Apply fresh jobs each time.
This commit is contained in:
parent
2ea5a2b5d5
commit
d640f17ddf
@ -166,6 +166,23 @@ struct PartitionCoreModule::DeviceInfo
|
||||
return Calamares::job_ptr( nullptr );
|
||||
}
|
||||
|
||||
/** @brief Take the jobs of any type that apply to @p partition */
|
||||
void takeJobs( Partition* partition )
|
||||
{
|
||||
for ( auto it = m_jobs.begin(); it != m_jobs.end(); )
|
||||
{
|
||||
PartitionJob* job = qobject_cast< PartitionJob* >( it->data() );
|
||||
if ( job && job->partition() == partition )
|
||||
{
|
||||
it = m_jobs.erase( it );
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Add a job of given type to the job list
|
||||
*/
|
||||
template < typename Job, typename... Args >
|
||||
@ -1144,6 +1161,17 @@ PartitionCoreModule::clearJobs()
|
||||
updateIsDirty();
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::clearJobs( Device* device, Partition* partition )
|
||||
{
|
||||
DeviceInfo* devInfo = infoForDevice( device );
|
||||
|
||||
if ( devInfo )
|
||||
{
|
||||
devInfo->takeJobs( partition );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PartitionCoreModule::isDirty()
|
||||
|
@ -218,6 +218,7 @@ public:
|
||||
void asyncRevertDevice( Device* dev, std::function< void() > callback ); //like revertDevice, but asynchronous
|
||||
|
||||
void clearJobs(); // only clear jobs, the Device* states are preserved
|
||||
void clearJobs( Device* device, Partition* partition ); // clears all jobs changing @p partition
|
||||
|
||||
bool isDirty(); // true if there are pending changes, otherwise false
|
||||
|
||||
|
@ -190,6 +190,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||
{
|
||||
if ( m_ui->formatRadioButton->isChecked() )
|
||||
{
|
||||
core->clearJobs( m_device, m_partition );
|
||||
Partition* newPartition = KPMHelpers::createNewPartition( m_partition->parent(),
|
||||
*m_device,
|
||||
m_partition->roles(),
|
||||
@ -224,6 +225,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||
// if the FS type is unchanged, we just format
|
||||
if ( m_partition->fileSystem().type() == fsType )
|
||||
{
|
||||
core->clearJobs( m_device, m_partition );
|
||||
core->formatPartition( m_device, m_partition );
|
||||
if ( currentFlags != resultFlags )
|
||||
{
|
||||
@ -234,6 +236,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||
}
|
||||
else // otherwise, we delete and recreate the partition with new fs type
|
||||
{
|
||||
core->clearJobs( m_device, m_partition );
|
||||
Partition* newPartition = KPMHelpers::createNewPartition( m_partition->parent(),
|
||||
*m_device,
|
||||
m_partition->roles(),
|
||||
|
Loading…
Reference in New Issue
Block a user