forked from qt-creator/qt-creator
Editor: Fix potential null pointer dereference in proposal widget.
Task-number: QTCREATORBUG-14875 Change-Id: I08dc2f2be9795bb4addcca1907cf13c30ebe6d9c Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -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)
|
|||||||
|
|
||||||
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()
|
|||||||
{
|
{
|
||||||
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)
|
|||||||
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user