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