QmlDesigner: Fix wizard deletion when dialog is rejected

Fixes: QDS-14945
Change-Id: I256b7566e7621dbba8fb90ce02085a46108ed829
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Shrief Gabr
2025-03-18 10:11:27 +02:00
parent bc6d93533c
commit a1fe7c6891

View File

@@ -89,10 +89,9 @@ QdsNewDialog::QdsNewDialog(QWidget *parent)
m_dialog->installEventFilter(this);
QObject::connect(&m_wizard, &WizardHandler::wizardCreationFailed, this, [this] {
// TODO: if the dialog itself could react on the error
// the would not be necessary
// TODO: if the dialog itself could react on the error this would not be necessary
QMessageBox::critical(m_dialog.get(), tr("New Project"), tr("Failed to initialize data."));
reject();
m_dialog->close();
});
}
@@ -101,9 +100,16 @@ bool QdsNewDialog::eventFilter(QObject *obj, QEvent *event)
if (obj != m_dialog.get())
return false;
if (event->type() == QEvent::Close
|| (event->type() == QEvent::KeyPress && static_cast<QKeyEvent *>(event)->key() == Qt::Key_Escape)) {
reject();
if (event->type() == QEvent::KeyPress
&& static_cast<QKeyEvent *>(event)->key() == Qt::Key_Escape) {
m_dialog->close();
return true;
}
if (event->type() == QEvent::Close) {
m_screenSizeModel->setBackendModel(nullptr);
m_styleModel->setSourceModel(nullptr);
m_wizard.destroyWizard();
return true;
}
@@ -407,10 +413,6 @@ void QdsNewDialog::accept()
void QdsNewDialog::reject()
{
m_screenSizeModel->setBackendModel(nullptr);
m_styleModel->setSourceModel(nullptr);
m_wizard.destroyWizard();
m_dialog->close();
}