QmlDesigner.ImportManager: Catch exception

Something might go wrong during the rewrite
and we should catch this instead of just crashing.

Change-Id: Ic8ac6637d8c1f0c8aad86161386c0ee2e2e53fd6
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
Thomas Hartmann
2013-10-30 15:23:55 +01:00
parent 3227397a76
commit 08493bf78c

View File

@@ -30,6 +30,9 @@
#include "importmanagerview.h" #include "importmanagerview.h"
#include "importswidget.h" #include "importswidget.h"
#include <rewritingexception.h>
#include <QMessageBox>
namespace QmlDesigner { namespace QmlDesigner {
@@ -244,14 +247,24 @@ void ImportManagerView::scriptFunctionsChanged(const ModelNode &/*node*/, const
void ImportManagerView::removeImport(const Import &import) void ImportManagerView::removeImport(const Import &import)
{ {
try {
if (model()) if (model())
model()->changeImports(QList<Import>(), QList<Import>() << import); model()->changeImports(QList<Import>(), QList<Import>() << import);
}
catch (RewritingException &e) {
QMessageBox::warning(0, "Error", e.description());
}
} }
void ImportManagerView::addImport(const Import &import) void ImportManagerView::addImport(const Import &import)
{ {
try {
if (model()) if (model())
model()->changeImports(QList<Import>() << import, QList<Import>()); model()->changeImports(QList<Import>() << import, QList<Import>());
}
catch (RewritingException &e) {
QMessageBox::warning(0, "Error", e.description());
}
} }
} // namespace QmlDesigner } // namespace QmlDesigner