forked from qt-creator/qt-creator
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:
committed by
Thomas Hartmann
parent
d22815f208
commit
564c0c1b94
@@ -137,14 +137,16 @@ void AnnotationEditor::removeFullAnnotation()
|
|||||||
if (!m_modelNode.customId().isNull()) {
|
if (!m_modelNode.customId().isNull()) {
|
||||||
dialogTitle = m_modelNode.customId();
|
dialogTitle = m_modelNode.customId();
|
||||||
}
|
}
|
||||||
QMessageBox *deleteDialog = new QMessageBox(Core::ICore::dialogParent());
|
QPointer<QMessageBox> deleteDialog = new QMessageBox(Core::ICore::dialogParent());
|
||||||
deleteDialog->setWindowTitle(dialogTitle);
|
deleteDialog->setWindowTitle(dialogTitle);
|
||||||
deleteDialog->setText(tr("Delete this annotation?"));
|
deleteDialog->setText(tr("Delete this annotation?"));
|
||||||
deleteDialog->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
deleteDialog->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||||
deleteDialog->setDefaultButton(QMessageBox::Yes);
|
deleteDialog->setDefaultButton(QMessageBox::Yes);
|
||||||
|
|
||||||
int result = deleteDialog->exec();
|
int result = deleteDialog->exec();
|
||||||
if (deleteDialog) deleteDialog->deleteLater();
|
|
||||||
|
if (deleteDialog)
|
||||||
|
deleteDialog->deleteLater();
|
||||||
|
|
||||||
if (result == QMessageBox::Yes) {
|
if (result == QMessageBox::Yes) {
|
||||||
m_modelNode.removeCustomId();
|
m_modelNode.removeCustomId();
|
||||||
|
Reference in New Issue
Block a user