Commit a4640e36 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner: fixes crash

Deleting an items might have a side effect that turns
the qml code invalid. (e. g. alias properties)

We catch this an show a proper error message.

Task-number: QTCREATORBUG-2973
Reviewed-by: Kai Koehne
parent d7216e84
......@@ -51,6 +51,7 @@
#include <nodelistproperty.h>
#include <toolbox.h>
#include <variantproperty.h>
#include <rewritingexception.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
......@@ -456,13 +457,17 @@ void DesignDocumentController::deleteSelected()
if (!m_d->model)
return;
if (m_d->formEditorView) {
RewriterTransaction transaction(m_d->formEditorView.data());
QList<ModelNode> toDelete = m_d->formEditorView->selectedModelNodes();
foreach (ModelNode node, toDelete) {
if (node.isValid() && !node.isRootNode() && QmlObjectNode(node).isValid())
QmlObjectNode(node).destroy();
try {
if (m_d->formEditorView) {
RewriterTransaction transaction(m_d->formEditorView.data());
QList<ModelNode> toDelete = m_d->formEditorView->selectedModelNodes();
foreach (ModelNode node, toDelete) {
if (node.isValid() && !node.isRootNode() && QmlObjectNode(node).isValid())
QmlObjectNode(node).destroy();
}
}
} catch (RewritingException &e) {
QMessageBox::warning(0, tr("Error"), e.description());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment