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