summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@nokia.com>2010-09-30 13:51:05 +0200
committerThomas Hartmann <Thomas.Hartmann@nokia.com>2010-09-30 17:43:18 +0200
commit2d5049645c502b20c2a8c4c2ce800319d067cbd2 (patch)
tree9f90979c0a2af556cfc3e395c9fcbfdde2e90675
parent4428d8c3cbd79cab97fa9bad25dd06d824858b5b (diff)
downloadqt-creator-2d5049645c502b20c2a8c4c2ce800319d067cbd2.tar.gz
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
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
index d59cdaa304..acda0ca8c5 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
@@ -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());
}
}