From b767f0b18fa9f74afb1ac4c8f66767f9cf151817 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 17 Dec 2015 16:14:01 +0100 Subject: [PATCH] Select partition to replace from the current DeviceModel. --- src/modules/partition/gui/ChoicePage.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index f66165148..9ab4691d8 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -36,6 +36,7 @@ #include "utils/Logger.h" #include "utils/Retranslator.h" #include "Branding.h" +#include "core/KPMHelpers.h" #include @@ -438,9 +439,15 @@ ChoicePage::applyActionChoice( Device* currentDevice, ChoicePage::Choice choice if ( m_core->isDirty() ) m_core->clearJobs(); - PartitionActions::doReplacePartition( m_core, - selectedDevice(), - ( Partition* )( current.data( PartitionModel::PartitionPtrRole ).value< void* >() ) ); + // 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 ); } ); case NoChoice: