From b952d0420e1fe2b128934d59d9f47f14d337cbf6 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 25 Apr 2017 11:58:57 +0200 Subject: [PATCH] QmlDesigner: Update item library if error is fixed If the document has an error (e.g. incomplete type information), then it is required to update the item library if this error is fixed. Change-Id: Iee9629879a0d3ee4bbc76dc0701f023e3c12f394 Reviewed-by: Tim Jenssen --- .../components/itemlibrary/itemlibraryview.cpp | 11 +++++++++++ .../components/itemlibrary/itemlibraryview.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp index 4f354746d65..02b76df1761 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp @@ -27,6 +27,7 @@ #include "itemlibrarywidget.h" #include #include +#include namespace QmlDesigner { @@ -69,6 +70,7 @@ void ItemLibraryView::modelAttached(Model *model) m_widget->setModel(model); updateImports(); model->attachView(m_importManagerView); + m_hasErrors = !rewriterView()->errors().isEmpty(); } void ItemLibraryView::modelAboutToBeDetached(Model *model) @@ -93,6 +95,15 @@ void ItemLibraryView::setResourcePath(const QString &resourcePath) m_widget->setResourcePath(resourcePath); } +void ItemLibraryView::documentMessagesChanged(const QList &errors, const QList &) +{ + if (m_hasErrors && errors.isEmpty()) + /* For some reason we have to call update from the event loop */ + QTimer::singleShot(0, m_widget, &ItemLibraryWidget::updateModel); + + m_hasErrors = !errors.isEmpty(); +} + void ItemLibraryView::updateImports() { m_widget->updateModel(); diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.h index 6391d7bc4f8..b2259c33102 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.h +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.h @@ -50,6 +50,7 @@ public: void modelAttached(Model *model) override; void modelAboutToBeDetached(Model *model) override; void importsChanged(const QList &addedImports, const QList &removedImports) override; + void documentMessagesChanged(const QList &errors, const QList &warnings) override; void setResourcePath(const QString &resourcePath); @@ -59,6 +60,7 @@ protected: private: QPointer m_widget; ImportManagerView *m_importManagerView; + bool m_hasErrors = false; }; }