Skip to content
Snippets Groups Projects
Commit b952d042 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

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: default avatarTim Jenssen <tim.jenssen@qt.io>
parent fa6caa3b
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@
#include "itemlibrarywidget.h"
#include <import.h>
#include <importmanagerview.h>
#include <rewriterview.h>
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<DocumentMessage> &errors, const QList<DocumentMessage> &)
{
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();
......
......@@ -50,6 +50,7 @@ public:
void modelAttached(Model *model) override;
void modelAboutToBeDetached(Model *model) override;
void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports) override;
void documentMessagesChanged(const QList<DocumentMessage> &errors, const QList<DocumentMessage> &warnings) override;
void setResourcePath(const QString &resourcePath);
......@@ -59,6 +60,7 @@ protected:
private:
QPointer<ItemLibraryWidget> m_widget;
ImportManagerView *m_importManagerView;
bool m_hasErrors = false;
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment