[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();
|
beginResetModel();
|
||||||
blockSignals( true );
|
blockSignals( true );
|
||||||
|
updateInternal();
|
||||||
|
blockSignals( false );
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BootLoaderModel::updateInternal()
|
||||||
|
{
|
||||||
|
QMutexLocker lock(&m_lock);
|
||||||
clear();
|
clear();
|
||||||
createMbrItems();
|
createMbrItems();
|
||||||
|
|
||||||
@ -113,14 +123,13 @@ BootLoaderModel::update()
|
|||||||
createBootLoaderItem( tr( "Do not install a boot loader" ), QString(), false )
|
createBootLoaderItem( tr( "Do not install a boot loader" ), QString(), false )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
blockSignals( false );
|
|
||||||
endResetModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
BootLoaderModel::data( const QModelIndex& index, int role ) const
|
BootLoaderModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
|
QMutexLocker lock(&m_lock);
|
||||||
if ( role == Qt::DisplayRole )
|
if ( role == Qt::DisplayRole )
|
||||||
{
|
{
|
||||||
QString displayRole = QStandardItemModel::data( index, Qt::DisplayRole ).toString();
|
QString displayRole = QStandardItemModel::data( index, Qt::DisplayRole ).toString();
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
#ifndef BOOTLOADERMODEL_H
|
#ifndef BOOTLOADERMODEL_H
|
||||||
#define BOOTLOADERMODEL_H
|
#define BOOTLOADERMODEL_H
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
|
|
||||||
@ -51,10 +52,14 @@ public:
|
|||||||
|
|
||||||
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
|
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
|
||||||
|
|
||||||
|
using DeviceList = QList< Device* >;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList< Device* > m_devices;
|
DeviceList m_devices;
|
||||||
|
mutable QMutex m_lock;
|
||||||
|
|
||||||
void createMbrItems();
|
void createMbrItems();
|
||||||
|
void updateInternal();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BOOTLOADERMODEL_H */
|
#endif /* BOOTLOADERMODEL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user