VariableChooser: Avoid null pointer access

The code makes an effort to qobject_cast a pointer and check it, yet it
accesses another pointer to do its thing.

If the currentWidget is a QPlainTextEdit, this simply crashes.

Amends: da3b83589b

Change-Id: Ie79fa233b04c392fd5aa72cd512fcd0f0d829659
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Alessandro Portale
2020-08-31 22:39:57 +02:00
parent 6477a07654
commit 947392cde9

View File

@@ -469,8 +469,8 @@ void VariableChooserPrivate::updateButtonGeometry()
int margin = buttonMargin();
int rightPadding = 0;
if (const auto scrollArea = qobject_cast<const QAbstractScrollArea*>(current)) {
rightPadding = m_textEdit->verticalScrollBar()->isVisible() ?
m_textEdit->verticalScrollBar()->width() : 0;
rightPadding = scrollArea->verticalScrollBar()->isVisible() ?
scrollArea->verticalScrollBar()->width() : 0;
}
m_iconButton->setGeometry(current->rect().adjusted(
current->width() - (margin + 4), 0,