Commit 2d504964 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner: crashfix see QTCREATORBUG-2507

Task-number: QTCREATORBUG-2507

There might be files without an import for Qt
States require "Qt"
I also added try {} catch blocks to the state editor,
to avoid issues like this.

Reviewed-by: Kai Koehne
parent 4428d8c3
......@@ -30,9 +30,11 @@
#include "stateseditorview.h"
#include "stateseditormodel.h"
#include <customnotifications.h>
#include <rewritingexception.h>
#include <QPainter>
#include <QTimerEvent>
#include <QMessageBox>
#include <QDebug>
#include <math.h>
......@@ -114,7 +116,12 @@ void StatesEditorView::createState(const QString &name)
if (debug)
qDebug() << __FUNCTION__ << name;
stateRootNode().states().addState(name);
try {
model()->addImport(Import::createLibraryImport("Qt", "4.7"));
stateRootNode().states().addState(name);
} catch (RewritingException &e) {
QMessageBox::warning(0, "Error", e.description());
}
}
void StatesEditorView::removeState(int index)
......@@ -128,14 +135,18 @@ void StatesEditorView::removeState(int index)
setCurrentState(0);
m_thumbnailsToUpdate.removeAt(index);
m_modelStates.removeAll(state);
state.destroy();
try {
m_modelStates.removeAll(state);
state.destroy();
m_thumbnailsToUpdate.removeAt(index);
m_editorModel->removeState(index);
m_editorModel->removeState(index);
int newIndex = (index < m_modelStates.count()) ? index : m_modelStates.count() - 1;
setCurrentState(newIndex);
int newIndex = (index < m_modelStates.count()) ? index : m_modelStates.count() - 1;
setCurrentState(newIndex);
} catch (RewritingException &e) {
QMessageBox::warning(0, "Error", e.description());
}
}
void StatesEditorView::renameState(int index, const QString &newName)
......@@ -146,12 +157,17 @@ void StatesEditorView::renameState(int index, const QString &newName)
Q_ASSERT(index > 0 && index < m_modelStates.size());
QmlModelState state = m_modelStates.at(index);
Q_ASSERT(state.isValid());
if (state.name() != newName) {
// Jump to base state for the change
QmlModelState oldState = currentState();
setCurrentStateSilent(0);
state.setName(newName);
setCurrentState(m_modelStates.indexOf(oldState));
try {
if (state.name() != newName) {
// Jump to base state for the change
QmlModelState oldState = currentState();
setCurrentStateSilent(0);
state.setName(newName);
setCurrentState(m_modelStates.indexOf(oldState));
}
} catch (RewritingException &e) {
QMessageBox::warning(0, "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