[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:
Adriaan de Groot 2019-04-01 07:36:18 -04:00
parent b03d72952b
commit 752a922bde
2 changed files with 18 additions and 4 deletions

View file

@ -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();