From 07e1f78ca854c6ead70878142f8b81a43b8b0731 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 7 Aug 2015 09:13:55 +0200 Subject: [PATCH] Editors/Function hint: Guard against potential crashes Change-Id: I285fe66a2ef9fd9543150dbbec5da6a83657ae73 Task-number: QTCREATORBUG-14875 Reviewed-by: David Schulz --- .../codeassist/functionhintproposalwidget.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp index e6f19ee6db0..925881a4516 100644 --- a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp +++ b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -201,7 +202,8 @@ bool FunctionHintProposalWidget::eventFilter(QObject *obj, QEvent *e) d->m_escapePressed = true; e->accept(); } - if (d->m_model->size() > 1) { + QTC_CHECK(d->m_model); + if (d->m_model && d->m_model->size() > 1) { QKeyEvent *ke = static_cast(e); if (ke->key() == Qt::Key_Up) { previousPage(); @@ -220,10 +222,13 @@ bool FunctionHintProposalWidget::eventFilter(QObject *obj, QEvent *e) emit explicitlyAborted(); return false; } else if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) { - if (d->m_model->size() > 1) + QTC_CHECK(d->m_model); + if (d->m_model && d->m_model->size() > 1) return false; } - d->m_assistant->notifyChange(); + QTC_CHECK(d->m_assistant); + if (d->m_assistant) + d->m_assistant->notifyChange(); } break; case QEvent::WindowDeactivate: