Use asynchronous device revert.

main
Teo Mrnjavac 9 years ago
parent dbef198bac
commit cd8b7619d0

@ -273,7 +273,6 @@ ChoicePage::setupChoices()
if ( currd ) if ( currd )
{ {
applyActionChoice( currentChoice() ); applyActionChoice( currentChoice() );
updateActionChoicePreview( currentChoice() );
} }
} ); } );
} }
@ -437,27 +436,33 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice )
connect( m_beforePartitionBarsView->selectionModel(), &QItemSelectionModel::currentRowChanged, connect( m_beforePartitionBarsView->selectionModel(), &QItemSelectionModel::currentRowChanged,
this, [ this ]( const QModelIndex& current, const QModelIndex& previous ) this, [ this ]( const QModelIndex& current, const QModelIndex& previous )
{ {
auto doReplace = [=]
{
// We can't use the PartitionPtrRole because we need to make changes to the
// main DeviceModel, not the immutable copy.
QString partPath = current.data( PartitionModel::PartitionPathRole ).toString();
Partition* partition = KPMHelpers::findPartitionByPath( { selectedDevice() },
partPath );
if ( partition )
PartitionActions::doReplacePartition( m_core,
selectedDevice(),
partition );
};
if ( m_core->isDirty() ) if ( m_core->isDirty() )
{ {
m_core->revertDevice( selectedDevice() ); m_core->asyncRevertDevice( selectedDevice(), doReplace );
m_core->clearJobs(); m_core->clearJobs();
} }
else
// We can't use the PartitionPtrRole because we need to make changes to the doReplace();
// main DeviceModel, not the immutable copy.
QString partPath = current.data( PartitionModel::PartitionPathRole ).toString();
Partition* partition = KPMHelpers::findPartitionByPath( { selectedDevice() },
partPath );
if ( partition )
PartitionActions::doReplacePartition( m_core,
selectedDevice(),
partition );
} ); } );
break; break;
case NoChoice: case NoChoice:
case Manual: case Manual:
break; break;
} }
updateActionChoicePreview( currentChoice() );
} }

Loading…
Cancel
Save