From b17b7a9c89d40c596e93161d873b003c44bbe8e1 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Tue, 9 Feb 2016 13:23:23 +0100 Subject: [PATCH] Asynchronous rescan on device change. --- src/modules/partition/gui/ChoicePage.cpp | 21 +++++++++++++++++++-- src/modules/partition/gui/ChoicePage.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index ed19eb2d9..9ca187af5 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -306,11 +306,28 @@ ChoicePage::applyDeviceChoice() if ( m_core->isDirty() ) { - m_core->revertAllDevices(); + ScanningDialog::run( QtConcurrent::run( [ = ] + { + QMutexLocker locker( &m_coreMutex ); + m_core->revertAllDevices(); + } ), + [ this ] + { + continueApplyDeviceChoice(); + }, + this ); + } + else + { + continueApplyDeviceChoice(); } +} - Device* currd = selectedDevice(); +void +ChoicePage::continueApplyDeviceChoice() +{ + Device* currd = selectedDevice(); // The device should only be nullptr immediately after a PCM reset. // applyDeviceChoice() will be called again momentarily as soon as we handle the diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 7dd6e024c..deff203c3 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -81,6 +81,7 @@ private: QComboBox* createBootloaderComboBox( QWidget* parentButton ); Device* selectedDevice(); void applyDeviceChoice(); + void continueApplyDeviceChoice(); void updateDeviceStatePreview(); void applyActionChoice( ChoicePage::Choice choice ); void updateActionChoicePreview( ChoicePage::Choice choice );