From 564c0c1b940912579912ce923bd6010acb23c4d0 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 24 Feb 2020 11:12:54 +0100 Subject: [PATCH] QmlDesigner: Fix annotationeditor You need a QPointer here to avoid potential double-free. A normal pointer is not reset to nullptr when the widget gets cleaned via the widget tree, so if (widget) widget->deleteLater() does not work with a normal pointer. Change-Id: Icd352b8767b91c4ea0ad045a56857fa651f200f0 Reviewed-by: Thomas Hartmann --- .../components/annotationeditor/annotationeditor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.cpp b/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.cpp index 46a98a07479..cd32560d444 100644 --- a/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.cpp +++ b/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.cpp @@ -137,14 +137,16 @@ void AnnotationEditor::removeFullAnnotation() if (!m_modelNode.customId().isNull()) { dialogTitle = m_modelNode.customId(); } - QMessageBox *deleteDialog = new QMessageBox(Core::ICore::dialogParent()); + QPointer deleteDialog = new QMessageBox(Core::ICore::dialogParent()); deleteDialog->setWindowTitle(dialogTitle); deleteDialog->setText(tr("Delete this annotation?")); deleteDialog->setStandardButtons(QMessageBox::Yes | QMessageBox::No); deleteDialog->setDefaultButton(QMessageBox::Yes); int result = deleteDialog->exec(); - if (deleteDialog) deleteDialog->deleteLater(); + + if (deleteDialog) + deleteDialog->deleteLater(); if (result == QMessageBox::Yes) { m_modelNode.removeCustomId();