summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan de Groot <groot@kde.org>2019-02-11 19:03:09 -0500
committerAdriaan de Groot <groot@kde.org>2019-02-11 19:03:09 -0500
commitdff5afe2275bd7c2bc1eca3ce216ff4b4866fb0c (patch)
treed9abfb43c36fadb085e2a0fc305063b816bf2a51
parentb9fa0398c0d286d98869b0f07a6078ed8148c2cd (diff)
[partition] Reduce refreshes when reverting
-rw-r--r--src/modules/partition/core/PartitionCoreModule.cpp9
-rw-r--r--src/modules/partition/core/PartitionCoreModule.h7
2 files changed, 11 insertions, 5 deletions
diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp
index 16e7c7f34..07cb0fcfd 100644
--- a/src/modules/partition/core/PartitionCoreModule.cpp
+++ b/src/modules/partition/core/PartitionCoreModule.cpp
@@ -880,7 +880,7 @@ PartitionCoreModule::revertAllDevices()
}
}
- revertDevice( ( *it )->device.data() );
+ revertDevice( ( *it )->device.data(), false );
++it;
}
@@ -889,7 +889,7 @@ PartitionCoreModule::revertAllDevices()
void
-PartitionCoreModule::revertDevice( Device* dev )
+PartitionCoreModule::revertDevice( Device* dev, bool individualRevert )
{
QMutexLocker locker( &m_revertMutex );
DeviceInfo* devInfo = infoForDevice( dev );
@@ -915,7 +915,8 @@ PartitionCoreModule::revertDevice( Device* dev )
m_bootLoaderModel->init( devices );
- refreshAfterModelChange();
+ if ( individualRevert )
+ refreshAfterModelChange();
emit deviceReverted( newDev );
}
@@ -931,7 +932,7 @@ PartitionCoreModule::asyncRevertDevice( Device* dev, std::function< void() > cal
watcher->deleteLater();
} );
- QFuture< void > future = QtConcurrent::run( this, &PartitionCoreModule::revertDevice, dev );
+ QFuture< void > future = QtConcurrent::run( this, &PartitionCoreModule::revertDevice, dev, true );
watcher->setFuture( future );
}
diff --git a/src/modules/partition/core/PartitionCoreModule.h b/src/modules/partition/core/PartitionCoreModule.h
index 52cb47a59..c48c1562c 100644
--- a/src/modules/partition/core/PartitionCoreModule.h
+++ b/src/modules/partition/core/PartitionCoreModule.h
@@ -191,7 +191,12 @@ public:
void revert(); // full revert, thread safe, calls doInit
void revertAllDevices(); // convenience function, calls revertDevice
- void revertDevice( Device* dev ); // rescans a single Device and updates DeviceInfo
+ /** @brief rescans a single Device and updates DeviceInfo
+ *
+ * When @p individualRevert is true, calls refreshAfterModelChange(),
+ * used to reduce number of refreshes when calling revertAllDevices().
+ */
+ void revertDevice( Device* dev, bool individualRevert=true );
void asyncRevertDevice( Device* dev, std::function< void() > callback ); //like revertDevice, but asynchronous
void clearJobs(); // only clear jobs, the Device* states are preserved