Commit 081bbc44 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner: Handle missing type information



We always had the problem that the design mode might become
active while type information is still being loaded.
This causes an error message and the user had to trigger
a reload of the QML document.
Due to changes in the project management Qt Creator
starts reading the type information, once the first QML file
is opened.
This triggers the error far more frequently.

This patch fixes the issue by triggering a reaload after 1s,
if type information has not been read completely.
This fixes the issue.

Change-Id: I23ad011294044690fd582e808227c3ccde8bda54
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 7e6d88ed
......@@ -116,6 +116,8 @@ public:
void clearErrorAndWarnings();
void setErrors(const QList<DocumentMessage> &errors);
void setWarnings(const QList<DocumentMessage> &warnings);
void setIncompleteTypeInformation(bool b);
bool hasIncompleteTypeInformation() const;
void addError(const DocumentMessage &error);
void enterErrorState(const QString &errorMessage);
......@@ -195,6 +197,7 @@ private: //variables
QTimer m_amendTimer;
bool m_instantQmlTextUpdate = false;
std::function<void(bool)> m_setWidgetStatusCallback;
bool m_hasIncompleteTypeInformation = false;
};
} //QmlDesigner
......@@ -86,6 +86,11 @@ void RewriterView::modelAttached(Model *model)
if (!(m_errors.isEmpty() && m_warnings.isEmpty()))
notifyErrorsAndWarnings(m_errors);
if (hasIncompleteTypeInformation())
QTimer::singleShot(1000, this, [this, model](){
modelAttached(model);
});
}
void RewriterView::modelAboutToBeDetached(Model * /*model*/)
......@@ -465,6 +470,16 @@ void RewriterView::setWarnings(const QList<DocumentMessage> &warnings)
notifyErrorsAndWarnings(m_errors);
}
void RewriterView::setIncompleteTypeInformation(bool b)
{
m_hasIncompleteTypeInformation = b;
}
bool RewriterView::hasIncompleteTypeInformation() const
{
return m_hasIncompleteTypeInformation;
}
void RewriterView::setErrors(const QList<DocumentMessage> &errors)
{
m_errors = errors;
......
......@@ -928,6 +928,7 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
const QUrl url = m_rewriterView->model()->fileUrl();
setActive(true);
m_rewriterView->setIncompleteTypeInformation(false);
try {
Snapshot snapshot = m_rewriterView->textModifier()->qmljsSnapshot();
......@@ -1953,6 +1954,9 @@ void TextToModelMerger::setupComponent(const ModelNode &node)
void TextToModelMerger::collectLinkErrors(QList<DocumentMessage> *errors, const ReadingContext &ctxt)
{
foreach (const QmlJS::DiagnosticMessage &diagnosticMessage, ctxt.diagnosticLinkMessages()) {
if (diagnosticMessage.kind == QmlJS::Severity::ReadingTypeInfoWarning)
m_rewriterView->setIncompleteTypeInformation(true);
errors->append(DocumentMessage(diagnosticMessage, QUrl::fromLocalFile(m_document->fileName())));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment