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 <thomas.hartmann@qt.io>
This commit is contained in:
Tobias Hunger
2020-02-24 11:12:54 +01:00
committed by Thomas Hartmann
parent d22815f208
commit 564c0c1b94

View File

@@ -137,14 +137,16 @@ void AnnotationEditor::removeFullAnnotation()
if (!m_modelNode.customId().isNull()) {
dialogTitle = m_modelNode.customId();
}
QMessageBox *deleteDialog = new QMessageBox(Core::ICore::dialogParent());
QPointer<QMessageBox> 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();