forked from qt-creator/qt-creator
Editor: Fix potential crash in FunctionHintProposalWidget.
Task-number: QTCREATORBUG-15275 Change-Id: I8112312d3d27798665d7d28b41b9f2ad845cca14 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ struct FunctionHintProposalWidgetPrivate
|
|||||||
const QWidget *m_underlyingWidget;
|
const QWidget *m_underlyingWidget;
|
||||||
CodeAssistant *m_assistant;
|
CodeAssistant *m_assistant;
|
||||||
IFunctionHintProposalModel *m_model;
|
IFunctionHintProposalModel *m_model;
|
||||||
Utils::FakeToolTip *m_popupFrame;
|
QPointer<Utils::FakeToolTip> m_popupFrame;
|
||||||
QLabel *m_numberLabel;
|
QLabel *m_numberLabel;
|
||||||
QLabel *m_hintLabel;
|
QLabel *m_hintLabel;
|
||||||
QWidget *m_pager;
|
QWidget *m_pager;
|
||||||
@@ -180,9 +181,9 @@ void FunctionHintProposalWidget::closeProposal()
|
|||||||
|
|
||||||
void FunctionHintProposalWidget::abort()
|
void FunctionHintProposalWidget::abort()
|
||||||
{
|
{
|
||||||
|
qApp->removeEventFilter(this);
|
||||||
if (d->m_popupFrame->isVisible())
|
if (d->m_popupFrame->isVisible())
|
||||||
d->m_popupFrame->close();
|
d->m_popupFrame->close();
|
||||||
qApp->removeEventFilter(this);
|
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +241,7 @@ bool FunctionHintProposalWidget::eventFilter(QObject *obj, QEvent *e)
|
|||||||
case QEvent::MouseButtonDblClick:
|
case QEvent::MouseButtonDblClick:
|
||||||
case QEvent::Wheel:
|
case QEvent::Wheel:
|
||||||
if (QWidget *widget = qobject_cast<QWidget *>(obj)) {
|
if (QWidget *widget = qobject_cast<QWidget *>(obj)) {
|
||||||
if (!d->m_popupFrame->isAncestorOf(widget)) {
|
if (d->m_popupFrame && !d->m_popupFrame->isAncestorOf(widget)) {
|
||||||
abort();
|
abort();
|
||||||
} else if (e->type() == QEvent::Wheel) {
|
} else if (e->type() == QEvent::Wheel) {
|
||||||
if (static_cast<QWheelEvent*>(e)->delta() > 0)
|
if (static_cast<QWheelEvent*>(e)->delta() > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user