Avoid homePartitionPath going out of scope.

This commit is contained in:
Teo Mrnjavac 2016-07-22 09:55:55 +02:00
parent 90bb64fb17
commit e6f9714f84

View File

@ -655,13 +655,13 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
if ( !current.isValid() ) if ( !current.isValid() )
return; return;
QString homePartitionPath; QString* homePartitionPath = new QString();
bool doReuseHomePartition = m_reuseHomeCheckBox->isChecked(); bool doReuseHomePartition = m_reuseHomeCheckBox->isChecked();
// NOTE: using by-ref captures because we need to write homePartitionPath and // NOTE: using by-ref captures because we need to write homePartitionPath and
// doReuseHomePartition *after* the device revert, for later use. // doReuseHomePartition *after* the device revert, for later use.
ScanningDialog::run( QtConcurrent::run( ScanningDialog::run( QtConcurrent::run(
[ this, current, &homePartitionPath, &doReuseHomePartition ] [ this, current ]( QString* homePartitionPath, bool doReuseHomePartition )
{ {
QMutexLocker locker( &m_coreMutex ); QMutexLocker locker( &m_coreMutex );
@ -732,11 +732,11 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
{ {
// Find out is the selected partition has a rootfs. If yes, then make the // Find out is the selected partition has a rootfs. If yes, then make the
// m_reuseHomeCheckBox visible and set its text to something meaningful. // m_reuseHomeCheckBox visible and set its text to something meaningful.
homePartitionPath.clear(); homePartitionPath->clear();
foreach ( const OsproberEntry& osproberEntry, m_core->osproberEntries() ) foreach ( const OsproberEntry& osproberEntry, m_core->osproberEntries() )
if ( osproberEntry.path == partPath ) if ( osproberEntry.path == partPath )
homePartitionPath = osproberEntry.homePath; *homePartitionPath = osproberEntry.homePath;
if ( homePartitionPath.isEmpty() ) if ( homePartitionPath->isEmpty() )
doReuseHomePartition = false; doReuseHomePartition = false;
PartitionActions::doReplacePartition( m_core, PartitionActions::doReplacePartition( m_core,
@ -744,10 +744,10 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
selectedPartition, selectedPartition,
m_encryptWidget->passphrase() ); m_encryptWidget->passphrase() );
Partition* homePartition = KPMHelpers::findPartitionByPath( { selectedDevice() }, Partition* homePartition = KPMHelpers::findPartitionByPath( { selectedDevice() },
homePartitionPath ); *homePartitionPath );
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
if ( homePartition ) if ( homePartition && doReuseHomePartition )
{ {
PartitionInfo::setMountPoint( homePartition, "/home" ); PartitionInfo::setMountPoint( homePartition, "/home" );
gs->insert( "reuseHome", true ); gs->insert( "reuseHome", true );
@ -758,10 +758,11 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
} }
} }
} }
} ), }, homePartitionPath, doReuseHomePartition ),
[&] [ = ]
{ {
m_reuseHomeCheckBox->setVisible( !homePartitionPath.isEmpty() ); m_reuseHomeCheckBox->setVisible( !homePartitionPath->isEmpty() );
delete homePartitionPath;
if ( m_isEfi ) if ( m_isEfi )
setupEfiSystemPartitionSelector(); setupEfiSystemPartitionSelector();