Add asynchronous device revert.
This commit is contained in:
parent
019faf730c
commit
dbef198bac
@ -49,6 +49,8 @@
|
||||
#include <QStandardItemModel>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <QFutureWatcher>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
static bool
|
||||
hasRootPartition( Device* device )
|
||||
@ -505,6 +507,7 @@ PartitionCoreModule::revert()
|
||||
void
|
||||
PartitionCoreModule::revertDevice( Device* dev )
|
||||
{
|
||||
QMutexLocker locker( &m_revertMutex );
|
||||
DeviceInfo* devInfo = infoForDevice( dev );
|
||||
if ( !devInfo )
|
||||
return;
|
||||
@ -526,6 +529,18 @@ PartitionCoreModule::revertDevice( Device* dev )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PartitionCoreModule::asyncRevertDevice( Device* dev, std::function< void() > callback )
|
||||
{
|
||||
QFutureWatcher< void > watcher;
|
||||
connect( &watcher, &QFutureWatcher< void >::finished,
|
||||
callback );
|
||||
|
||||
QFuture< void > future = QtConcurrent::run( this, &PartitionCoreModule::revertDevice, dev );
|
||||
watcher.setFuture( future );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PartitionCoreModule::clearJobs()
|
||||
{
|
||||
|
@ -28,8 +28,11 @@
|
||||
|
||||
// Qt
|
||||
#include <QList>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
|
||||
#include <functional>
|
||||
|
||||
class BootLoaderModel;
|
||||
class CreatePartitionJob;
|
||||
class Device;
|
||||
@ -96,6 +99,7 @@ public:
|
||||
|
||||
void revert();
|
||||
void revertDevice( Device* dev );
|
||||
void asyncRevertDevice( Device* dev, std::function< void() > callback );
|
||||
|
||||
void clearJobs();
|
||||
|
||||
@ -159,6 +163,8 @@ private:
|
||||
Partition* findPartitionByMountPoint( const QString& mountPoint ) const;
|
||||
|
||||
OsproberEntryList m_osproberLines;
|
||||
|
||||
QMutex m_revertMutex;
|
||||
};
|
||||
|
||||
#endif /* PARTITIONCOREMODULE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user