diff --git a/src/modules/partition/core/BootLoaderModel.cpp b/src/modules/partition/core/BootLoaderModel.cpp index f0661d8b0..345cbad52 100644 --- a/src/modules/partition/core/BootLoaderModel.cpp +++ b/src/modules/partition/core/BootLoaderModel.cpp @@ -69,6 +69,16 @@ BootLoaderModel::update() { beginResetModel(); blockSignals( true ); + updateInternal(); + blockSignals( false ); + endResetModel(); +} + + +void +BootLoaderModel::updateInternal() +{ + QMutexLocker lock(&m_lock); clear(); createMbrItems(); @@ -113,14 +123,13 @@ BootLoaderModel::update() createBootLoaderItem( tr( "Do not install a boot loader" ), QString(), false ) ); } - blockSignals( false ); - endResetModel(); } QVariant BootLoaderModel::data( const QModelIndex& index, int role ) const { + QMutexLocker lock(&m_lock); if ( role == Qt::DisplayRole ) { QString displayRole = QStandardItemModel::data( index, Qt::DisplayRole ).toString(); diff --git a/src/modules/partition/core/BootLoaderModel.h b/src/modules/partition/core/BootLoaderModel.h index 27be18687..e59225e0e 100644 --- a/src/modules/partition/core/BootLoaderModel.h +++ b/src/modules/partition/core/BootLoaderModel.h @@ -19,8 +19,9 @@ #ifndef BOOTLOADERMODEL_H #define BOOTLOADERMODEL_H -#include #include +#include +#include class Device; @@ -51,10 +52,14 @@ public: QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; + using DeviceList = QList< Device* >; + private: - QList< Device* > m_devices; + DeviceList m_devices; + mutable QMutex m_lock; void createMbrItems(); + void updateInternal(); }; #endif /* BOOTLOADERMODEL_H */