Commit de1d48e4 authored by David Schulz's avatar David Schulz
Browse files

Editor: Fix potential null pointer dereference in proposal widget.



Task-number: QTCREATORBUG-14875
Change-Id: I08dc2f2be9795bb4addcca1907cf13c30ebe6d9c
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent acb36c2c
...@@ -115,8 +115,6 @@ FunctionHintProposalWidget::FunctionHintProposalWidget() ...@@ -115,8 +115,6 @@ FunctionHintProposalWidget::FunctionHintProposalWidget()
connect(upArrow, SIGNAL(clicked()), SLOT(previousPage())); connect(upArrow, SIGNAL(clicked()), SLOT(previousPage()));
connect(downArrow, SIGNAL(clicked()), SLOT(nextPage())); connect(downArrow, SIGNAL(clicked()), SLOT(nextPage()));
qApp->installEventFilter(this);
setFocusPolicy(Qt::NoFocus); setFocusPolicy(Qt::NoFocus);
} }
...@@ -157,17 +155,16 @@ void FunctionHintProposalWidget::setIsSynchronized(bool) ...@@ -157,17 +155,16 @@ void FunctionHintProposalWidget::setIsSynchronized(bool)
void FunctionHintProposalWidget::showProposal(const QString &prefix) void FunctionHintProposalWidget::showProposal(const QString &prefix)
{ {
QTC_ASSERT(d->m_model && d->m_assistant, abort(); return; );
d->m_totalHints = d->m_model->size(); d->m_totalHints = d->m_model->size();
if (d->m_totalHints == 0) { QTC_ASSERT(d->m_totalHints != 0, abort(); return; );
abort();
return;
}
d->m_pager->setVisible(d->m_totalHints > 1); d->m_pager->setVisible(d->m_totalHints > 1);
d->m_currentHint = 0; d->m_currentHint = 0;
if (!updateAndCheck(prefix)) { QTC_ASSERT(updateAndCheck(prefix), abort(); return; );
abort();
return; qApp->installEventFilter(this);
}
d->m_popupFrame->show(); d->m_popupFrame->show();
} }
...@@ -185,6 +182,7 @@ void FunctionHintProposalWidget::abort() ...@@ -185,6 +182,7 @@ void FunctionHintProposalWidget::abort()
{ {
if (d->m_popupFrame->isVisible()) if (d->m_popupFrame->isVisible())
d->m_popupFrame->close(); d->m_popupFrame->close();
qApp->removeEventFilter(this);
deleteLater(); deleteLater();
} }
...@@ -240,8 +238,8 @@ bool FunctionHintProposalWidget::eventFilter(QObject *obj, QEvent *e) ...@@ -240,8 +238,8 @@ bool FunctionHintProposalWidget::eventFilter(QObject *obj, QEvent *e)
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick: case QEvent::MouseButtonDblClick:
case QEvent::Wheel: { case QEvent::Wheel:
QWidget *widget = qobject_cast<QWidget *>(obj); if (QWidget *widget = qobject_cast<QWidget *>(obj)) {
if (!d->m_popupFrame->isAncestorOf(widget)) { if (!d->m_popupFrame->isAncestorOf(widget)) {
abort(); abort();
} else if (e->type() == QEvent::Wheel) { } else if (e->type() == QEvent::Wheel) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment