[partition] Simplify flags calculations
- factor out the flags-we-want from the flags-we-already-have - the use of ->activeFlags() meant that the state on *disk* was being compared with the flags-we-want; if a partition was re-edited, then you couldn't change the flags back to the state-on-disk (eg. enable a flag, then change your mind and disable it). - set the flags before refreshing the partition, because the refresh checks for EFI bootability and that needs the new flags, not the old ones.
This commit is contained in:
parent
949e33f1e8
commit
85bb8c27b3
@ -147,6 +147,9 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||
: FileSystem::typeForName( m_ui->fileSystemComboBox->currentText() );
|
||||
}
|
||||
|
||||
const auto resultFlags = newFlags();
|
||||
const auto currentFlags = PartitionInfo::flags( m_partition );
|
||||
|
||||
if ( partResizedMoved )
|
||||
{
|
||||
if ( m_ui->formatRadioButton->isChecked() )
|
||||
@ -157,20 +160,20 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||
fsType,
|
||||
newFirstSector,
|
||||
newLastSector,
|
||||
newFlags() );
|
||||
resultFlags );
|
||||
PartitionInfo::setMountPoint( newPartition, PartitionInfo::mountPoint( m_partition ) );
|
||||
PartitionInfo::setFormat( newPartition, true );
|
||||
|
||||
core->deletePartition( m_device, m_partition );
|
||||
core->createPartition( m_device, newPartition );
|
||||
core->setPartitionFlags( m_device, newPartition, newFlags() );
|
||||
core->setPartitionFlags( m_device, newPartition, resultFlags );
|
||||
}
|
||||
else
|
||||
{
|
||||
core->resizePartition( m_device, m_partition, newFirstSector, newLastSector );
|
||||
if ( m_partition->activeFlags() != newFlags() )
|
||||
if ( currentFlags != resultFlags )
|
||||
{
|
||||
core->setPartitionFlags( m_device, m_partition, newFlags() );
|
||||
core->setPartitionFlags( m_device, m_partition, resultFlags );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -183,9 +186,9 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||
if ( m_partition->fileSystem().type() == fsType )
|
||||
{
|
||||
core->formatPartition( m_device, m_partition );
|
||||
if ( m_partition->activeFlags() != newFlags() )
|
||||
if ( currentFlags != resultFlags )
|
||||
{
|
||||
core->setPartitionFlags( m_device, m_partition, newFlags() );
|
||||
core->setPartitionFlags( m_device, m_partition, resultFlags );
|
||||
}
|
||||
}
|
||||
else // otherwise, we delete and recreate the partition with new fs type
|
||||
@ -196,22 +199,22 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||
fsType,
|
||||
m_partition->firstSector(),
|
||||
m_partition->lastSector(),
|
||||
newFlags() );
|
||||
resultFlags );
|
||||
PartitionInfo::setMountPoint( newPartition, PartitionInfo::mountPoint( m_partition ) );
|
||||
PartitionInfo::setFormat( newPartition, true );
|
||||
|
||||
core->deletePartition( m_device, m_partition );
|
||||
core->createPartition( m_device, newPartition );
|
||||
core->setPartitionFlags( m_device, newPartition, newFlags() );
|
||||
core->setPartitionFlags( m_device, newPartition, resultFlags );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
core->refreshPartition( m_device, m_partition );
|
||||
if ( m_partition->activeFlags() != newFlags() )
|
||||
if ( currentFlags != resultFlags )
|
||||
{
|
||||
core->setPartitionFlags( m_device, m_partition, newFlags() );
|
||||
core->setPartitionFlags( m_device, m_partition, resultFlags );
|
||||
}
|
||||
core->refreshPartition( m_device, m_partition );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user