diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 7b7657f5f..953f125a4 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -442,28 +442,7 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice ) watcher->deleteLater(); } ); - auto doReplace = [ this, current ] - { - cDebug() << "begin doReplace"; - QMutexLocker( &( ChoicePage::m_coreMutex ) ); - - if ( m_core->isDirty() ) - { - m_core->revertDevice( selectedDevice() ); - } - // 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 ); - cDebug() << "end doReplace"; - }; - - QFuture< void > future = QtConcurrent::run( doReplace ); + QFuture< void > future = QtConcurrent::run( this, &ChoicePage::doReplaceSelectedPartition, current ); watcher->setFuture( future ); } ); break; @@ -475,6 +454,29 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice ) } +void +ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) +{ + cDebug() << "begin doReplace"; + QMutexLocker locker( &m_coreMutex ); + + if ( m_core->isDirty() ) + { + m_core->revertDevice( selectedDevice() ); + } + // 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 ); + cDebug() << "end doReplace"; +} + + /** * @brief ChoicePage::updateDeviceStatePreview clears and rebuilds the contents of the * preview widget for the current on-disk state. This also triggers a rescan in the diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index ac8668c06..ce7f82331 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -76,6 +76,7 @@ private: ExpandableRadioButton* createEraseButton(); Device* selectedDevice(); void applyDeviceChoice(); + void doReplaceSelectedPartition( const QModelIndex& current ); void updateDeviceStatePreview(); void applyActionChoice( ChoicePage::Choice choice ); void updateActionChoicePreview( ChoicePage::Choice choice );