From 83072da8b0fc50bd05a8a19ee2c3be413f6ec50a Mon Sep 17 00:00:00 2001
From: Christian Kamm <christian.d.kamm@nokia.com>
Date: Mon, 30 May 2011 12:56:24 +0200
Subject: [PATCH] QmlJS: Fix potential linking problem.

Don't use plugin from libs/qmljs.

Change-Id: Ia345c567cd1f244ab2191017810ef3eeb91fe0e4
Reviewed-on: http://codereview.qt.nokia.com/213
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
---
 src/libs/qmljs/qmljsinterpreter.cpp          | 16 +++++++---------
 src/libs/qmljs/qmljsinterpreter.h            |  5 +++--
 src/plugins/qmljstools/qmljsmodelmanager.cpp | 11 ++++++++++-
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp
index 722838a0930..0a4c56c2ff5 100644
--- a/src/libs/qmljs/qmljsinterpreter.cpp
+++ b/src/libs/qmljs/qmljsinterpreter.cpp
@@ -40,7 +40,6 @@
 #include "parser/qmljsast_p.h"
 
 #include <languageutils/fakemetaobject.h>
-#include <coreplugin/messagemanager.h>
 
 #include <QtCore/QFile>
 #include <QtCore/QDir>
@@ -1581,10 +1580,9 @@ const Value *Function::invoke(const Activation *activation) const
 QHash<QString, FakeMetaObject::ConstPtr> CppQmlTypesLoader::builtinObjects;
 QHash<QString, QList<LanguageUtils::ComponentVersion> > CppQmlTypesLoader::builtinPackages;
 
-void CppQmlTypesLoader::loadQmlTypes(const QFileInfoList &qmlTypeFiles)
+void CppQmlTypesLoader::loadQmlTypes(const QFileInfoList &qmlTypeFiles, QStringList *errors, QStringList *warnings)
 {
     QHash<QString, FakeMetaObject::ConstPtr> newObjects;
-    Core::MessageManager *messageManager = Core::MessageManager::instance();
 
     foreach (const QFileInfo &qmlTypeFile, qmlTypeFiles) {
         QString error, warning;
@@ -1601,14 +1599,14 @@ void CppQmlTypesLoader::loadQmlTypes(const QFileInfoList &qmlTypeFiles)
             error = file.errorString();
         }
         if (!error.isEmpty()) {
-            messageManager->printToOutputPane(
-                        TypeDescriptionReader::tr("Errors while loading qmltypes from %1:\n%2").arg(
-                            qmlTypeFile.absoluteFilePath(), error));
+            errors->append(TypeDescriptionReader::tr(
+                               "Errors while loading qmltypes from %1:\n%2").arg(
+                               qmlTypeFile.absoluteFilePath(), error));
         }
         if (!warning.isEmpty()) {
-            messageManager->printToOutputPane(
-                        TypeDescriptionReader::tr("Warnings while loading qmltypes from %1:\n%2").arg(
-                            qmlTypeFile.absoluteFilePath(), warning));
+            warnings->append(TypeDescriptionReader::tr(
+                                 "Warnings while loading qmltypes from %1:\n%2").arg(
+                                 qmlTypeFile.absoluteFilePath(), error));
         }
     }
 
diff --git a/src/libs/qmljs/qmljsinterpreter.h b/src/libs/qmljs/qmljsinterpreter.h
index b644b9dad19..8402e0af1fe 100644
--- a/src/libs/qmljs/qmljsinterpreter.h
+++ b/src/libs/qmljs/qmljsinterpreter.h
@@ -615,9 +615,10 @@ class QMLJS_EXPORT CppQmlTypesLoader
 {
 public:
     /** Loads a set of qmltypes files into the builtin objects list
-        and prints any errors to the General Messages pane
+        and returns errors and warnings
     */
-    static void loadQmlTypes(const QFileInfoList &qmltypesFiles);
+    static void loadQmlTypes(const QFileInfoList &qmltypesFiles,
+                             QStringList *errors, QStringList *warnings);
 
     static QHash<QString, LanguageUtils::FakeMetaObject::ConstPtr> builtinObjects;
     static QHash<QString, QList<LanguageUtils::ComponentVersion> > builtinPackages;
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index 6a48b6fea9c..411dc0364a0 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -38,6 +38,7 @@
 #include <coreplugin/editormanager/editormanager.h>
 #include <coreplugin/progressmanager/progressmanager.h>
 #include <coreplugin/mimedatabase.h>
+#include <coreplugin/messagemanager.h>
 #include <cplusplus/ModelManagerInterface.h>
 #include <cplusplus/CppDocument.h>
 #include <cplusplus/TypeOfExpression.h>
@@ -118,7 +119,15 @@ void ModelManager::loadQmlTypeDescriptions(const QString &resourcePath)
                 QDir::Files,
                 QDir::Name);
 
-    Interpreter::CppQmlTypesLoader::loadQmlTypes(qmlTypesFiles);
+    QStringList errors;
+    QStringList warnings;
+    Interpreter::CppQmlTypesLoader::loadQmlTypes(qmlTypesFiles, &errors, &warnings);
+
+    Core::MessageManager *messageManager = Core::MessageManager::instance();
+    foreach (const QString &error, errors)
+        messageManager->printToOutputPane(error);
+    foreach (const QString &warning, warnings)
+        messageManager->printToOutputPane(warning);
 
     // disabled for now: Prefer the xml file until the type dumping functionality
     // has been moved into Qt.
-- 
GitLab