forked from qt-creator/qt-creator
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:
@@ -30,6 +30,9 @@
|
||||
#include "importmanagerview.h"
|
||||
#include "importswidget.h"
|
||||
|
||||
#include <rewritingexception.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -244,14 +247,24 @@ void ImportManagerView::scriptFunctionsChanged(const ModelNode &/*node*/, const
|
||||
|
||||
void ImportManagerView::removeImport(const Import &import)
|
||||
{
|
||||
try {
|
||||
if (model())
|
||||
model()->changeImports(QList<Import>(), QList<Import>() << import);
|
||||
}
|
||||
catch (RewritingException &e) {
|
||||
QMessageBox::warning(0, "Error", e.description());
|
||||
}
|
||||
}
|
||||
|
||||
void ImportManagerView::addImport(const Import &import)
|
||||
{
|
||||
try {
|
||||
if (model())
|
||||
model()->changeImports(QList<Import>() << import, QList<Import>());
|
||||
}
|
||||
catch (RewritingException &e) {
|
||||
QMessageBox::warning(0, "Error", e.description());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Reference in New Issue
Block a user