[partition] Lock the bootloader model during reset
- Try to avoid races between resetting the model and getting data from it for the UI.
This commit is contained in:
parent
b03d72952b
commit
752a922bde
@ -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();
|
||||
|
@ -19,8 +19,9 @@
|
||||
#ifndef BOOTLOADERMODEL_H
|
||||
#define BOOTLOADERMODEL_H
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <QList>
|
||||
#include <QMutex>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user