mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3037 Guard pointer access
This commit is contained in:
parent
e370dee3b0
commit
e814272bea
@ -104,70 +104,73 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
m_comboBox->blockSignals(false);
|
m_comboBox->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attributes.showPreviousAndNextButtons)
|
if (!m_layout.isNull())
|
||||||
{
|
{
|
||||||
if (m_previousItemButton.isNull())
|
if (attributes.showPreviousAndNextButtons)
|
||||||
{
|
{
|
||||||
m_previousItemButton = new QToolButton(m_placeholder);
|
if (m_previousItemButton.isNull())
|
||||||
connect(m_previousItemButton, SIGNAL(clicked()), this, SLOT(slotPreviousButtonPressed()));
|
{
|
||||||
|
m_previousItemButton = new QToolButton(m_placeholder);
|
||||||
|
connect(m_previousItemButton, SIGNAL(clicked()), this, SLOT(slotPreviousButtonPressed()));
|
||||||
|
|
||||||
m_previousItemButton->setToolTip("Previous");
|
m_previousItemButton->setToolTip("Previous");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_nextItemButton.isNull())
|
if (m_nextItemButton.isNull())
|
||||||
{
|
{
|
||||||
m_nextItemButton = new QToolButton(m_placeholder);
|
m_nextItemButton = new QToolButton(m_placeholder);
|
||||||
connect(m_nextItemButton, SIGNAL(clicked()), this, SLOT(slotNextButtonPressed()));
|
connect(m_nextItemButton, SIGNAL(clicked()), this, SLOT(slotNextButtonPressed()));
|
||||||
|
|
||||||
m_nextItemButton->setToolTip("Next");
|
m_nextItemButton->setToolTip("Next");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_layout->insertWidget(1, m_previousItemButton);
|
m_layout->insertWidget(1, m_previousItemButton);
|
||||||
m_layout->insertWidget(2, m_nextItemButton);
|
m_layout->insertWidget(2, m_nextItemButton);
|
||||||
|
|
||||||
if (m_comboBox->count() == 0 || m_comboBox->currentIndex() <= 0)
|
if (m_comboBox->count() == 0 || m_comboBox->currentIndex() <= 0)
|
||||||
{
|
{
|
||||||
QIcon disabledIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp).pixmap(16, 16, QIcon::Disabled));
|
QIcon disabledIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp).pixmap(16, 16, QIcon::Disabled));
|
||||||
m_previousItemButton->setIcon(disabledIcon);
|
m_previousItemButton->setIcon(disabledIcon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_previousItemButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_comboBox->count() == 0 || m_comboBox->currentIndex() >= m_comboBox->count() - 1)
|
||||||
|
{
|
||||||
|
QIcon disabledIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown).pixmap(16, 16, QIcon::Disabled));
|
||||||
|
m_nextItemButton->setIcon(disabledIcon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_nextItemButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update button texts
|
||||||
|
if (!attributes.nextButtonText.isEmpty())
|
||||||
|
{
|
||||||
|
m_nextItemButton->setToolTip(attributes.nextButtonText);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!attributes.prevButtonText.isEmpty())
|
||||||
|
{
|
||||||
|
m_previousItemButton->setToolTip(attributes.prevButtonText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_previousItemButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp));
|
if (m_previousItemButton)
|
||||||
}
|
{
|
||||||
|
m_layout->removeWidget(m_previousItemButton);
|
||||||
|
m_previousItemButton->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
if (m_comboBox->count() == 0 || m_comboBox->currentIndex() >= m_comboBox->count() - 1)
|
if (m_nextItemButton)
|
||||||
{
|
{
|
||||||
QIcon disabledIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown).pixmap(16, 16, QIcon::Disabled));
|
m_layout->removeWidget(m_nextItemButton);
|
||||||
m_nextItemButton->setIcon(disabledIcon);
|
m_nextItemButton->deleteLater();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_nextItemButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update button texts
|
|
||||||
if (!attributes.nextButtonText.isEmpty())
|
|
||||||
{
|
|
||||||
m_nextItemButton->setToolTip(attributes.nextButtonText);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!attributes.prevButtonText.isEmpty())
|
|
||||||
{
|
|
||||||
m_previousItemButton->setToolTip(attributes.prevButtonText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_previousItemButton)
|
|
||||||
{
|
|
||||||
m_layout->removeWidget(m_previousItemButton);
|
|
||||||
m_previousItemButton->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_nextItemButton)
|
|
||||||
{
|
|
||||||
m_layout->removeWidget(m_nextItemButton);
|
|
||||||
m_nextItemButton->deleteLater();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user