Commit b4ca0434 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: Setting import paths for fallback puppet

Setting the import paths from the code model for the fallback puppet
is complicated, since we have to remove the path to the Qt plugins
in e.g. qtbase/qml and we have to set the correct path
for the Qt plugins of Qt Creator.

Change-Id: I45cb8616566bb3db51c2c70d6dc418c7a2ab4dd1
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent d3b4acfa
......@@ -45,6 +45,7 @@
#include <qtsupport/qtsupportconstants.h>
#include <coreplugin/icore.h>
#include <utils/algorithm.h>
#include <utils/environment.h>
#include <utils/hostosinfo.h>
......@@ -363,6 +364,14 @@ QString PuppetCreator::qml2PuppetPath(PuppetType puppetType) const
return qmlPuppetDirectory(puppetType) + QStringLiteral("/qml2puppet") + QStringLiteral(QTC_HOST_EXE_SUFFIX);
}
static void filterOutQtBaseImportPath(QStringList *stringList)
{
Utils::erase(*stringList, [](const QString &string) {
QDir dir(string);
return dir.dirName() == "qml" && !dir.entryInfoList(QStringList("QtQuick.2"), QDir::Dirs).isEmpty();
});
}
QProcessEnvironment PuppetCreator::processEnvironment() const
{
static const QString pathSep = Utils::HostOsInfo::pathListSeparator();
......@@ -391,6 +400,9 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
QStringList importPaths = m_model->importPaths();
/* For the fallback puppet we have to remove the path to the original qtbase plugins to avoid conflics */
if (m_availablePuppetType == FallbackPuppet)
filterOutQtBaseImportPath(&importPaths);
if (m_currentProject) {
for (const QString &fileName : m_currentProject->files(ProjectExplorer::Project::SourceFiles)) {
......@@ -406,9 +418,9 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
}
if (m_availablePuppetType == FallbackPuppet)
importPaths.append(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath));
if (m_availablePuppetType != FallbackPuppet)
environment.appendOrSet("QML2_IMPORT_PATH", importPaths.join(pathSep), pathSep);
importPaths.prepend(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath));
environment.appendOrSet("QML2_IMPORT_PATH", importPaths.join(pathSep), pathSep);
qCInfo(puppetStart) << Q_FUNC_INFO;
qCInfo(puppetStart) << "Puppet qrc mapping" << m_qrcMapping;
......
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