[partition] More conservative handling of device pointers

- thanks @abucodonosor
This commit is contained in:
Adriaan de Groot 2019-02-11 17:45:23 -05:00
parent a6edb3ed34
commit 6316173f1b

View File

@ -165,9 +165,13 @@ PartitionPage::updateButtons()
if ( m_ui->deviceComboBox->currentIndex() >= 0 ) if ( m_ui->deviceComboBox->currentIndex() >= 0 )
{ {
Device* device = nullptr;
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 ); QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
auto device = m_core->deviceModel()->deviceForIndex( deviceIndex ); if ( deviceIndex.isValid() )
if ( device->type() != Device::Type::LVM_Device ) device = m_core->deviceModel()->deviceForIndex( deviceIndex );
if ( !device )
cWarning() << "Device for updateButtons is nullptr";
else if ( device->type() != Device::Type::LVM_Device )
{ {
createTable = true; createTable = true;