forked from qt-creator/qt-creator
QmlDesigner: Ensure that all paths are normalized
Change-Id: I9e5f9a3c568a85242a499f6fe64d4b3e68ae28bf Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -63,14 +63,24 @@ ProjectExplorer::Target *activeTarget(ProjectExplorer::Project *project)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString resourcePath(const QString &relativePath)
|
||||||
|
{
|
||||||
|
return Core::ICore::resourcePath(relativePath).cleanPath().path();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cacheResourcePath(const QString &relativePath)
|
||||||
|
{
|
||||||
|
return Core::ICore::cacheResourcePath(relativePath).cleanPath().path();
|
||||||
|
}
|
||||||
|
|
||||||
QString previewDefaultImagePath()
|
QString previewDefaultImagePath()
|
||||||
{
|
{
|
||||||
return Core::ICore::resourcePath("qmldesigner/welcomepage/images/newThumbnail.png").toUrlishString();
|
return resourcePath("qmldesigner/welcomepage/images/newThumbnail.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString previewBrokenImagePath()
|
QString previewBrokenImagePath()
|
||||||
{
|
{
|
||||||
return Core::ICore::resourcePath("qmldesigner/welcomepage/images/noPreview.png").toUrlishString();
|
return resourcePath("qmldesigner/welcomepage/images/noPreview.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
::QmlProjectManager::QmlBuildSystem *getQmlBuildSystem(const ::ProjectExplorer::Target *target)
|
::QmlProjectManager::QmlBuildSystem *getQmlBuildSystem(const ::ProjectExplorer::Target *target)
|
||||||
@@ -128,8 +138,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sqlite::Database database{Utils::PathString{
|
Sqlite::Database database{Utils::PathString{cacheResourcePath("imagecache-v2.db")},
|
||||||
Core::ICore::cacheResourcePath("imagecache-v2.db").toUrlishString()},
|
|
||||||
Sqlite::JournalMode::Wal,
|
Sqlite::JournalMode::Wal,
|
||||||
Sqlite::LockingMode::Normal};
|
Sqlite::LockingMode::Normal};
|
||||||
ImageCacheStorage<Sqlite::Database> storage{database};
|
ImageCacheStorage<Sqlite::Database> storage{database};
|
||||||
@@ -160,8 +169,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sqlite::Database database{Utils::PathString{
|
Sqlite::Database database{Utils::PathString{cacheResourcePath("previewcache.db")},
|
||||||
Core::ICore::cacheResourcePath("previewcache.db").toUrlishString()},
|
|
||||||
Sqlite::JournalMode::Wal,
|
Sqlite::JournalMode::Wal,
|
||||||
Sqlite::LockingMode::Normal};
|
Sqlite::LockingMode::Normal};
|
||||||
ImageCacheStorage<Sqlite::Database> storage{database};
|
ImageCacheStorage<Sqlite::Database> storage{database};
|
||||||
@@ -188,7 +196,7 @@ Sqlite::JournalMode projectStorageJournalMode()
|
|||||||
{
|
{
|
||||||
auto qt = QtSupport::QtKitAspect::qtVersion(target->kit());
|
auto qt = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||||
if (qt)
|
if (qt)
|
||||||
return qt->qmlPath().path();
|
return qt->qmlPath().cleanPath().path();
|
||||||
|
|
||||||
return QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
|
return QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
|
||||||
}
|
}
|
||||||
@@ -197,7 +205,7 @@ Sqlite::JournalMode projectStorageJournalMode()
|
|||||||
{
|
{
|
||||||
auto qt = QtSupport::QtKitAspect::qtVersion(project->activeKit());
|
auto qt = QtSupport::QtKitAspect::qtVersion(project->activeKit());
|
||||||
if (qt)
|
if (qt)
|
||||||
return qt->qmlPath().path();
|
return qt->qmlPath().cleanPath().path();
|
||||||
|
|
||||||
return QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
|
return QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
|
||||||
}
|
}
|
||||||
@@ -206,7 +214,7 @@ class ProjectStorageData
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProjectStorageData(const ::ProjectExplorer::Project *project, PathCacheType &pathCache)
|
ProjectStorageData(const ::ProjectExplorer::Project *project, PathCacheType &pathCache)
|
||||||
: database{project->projectDirectory().pathAppended("projectstorage.db").toUrlishString(),
|
: database{project->projectDirectory().pathAppended("projectstorage.db").cleanPath().path(),
|
||||||
projectStorageJournalMode()}
|
projectStorageJournalMode()}
|
||||||
, errorNotifier{pathCache}
|
, errorNotifier{pathCache}
|
||||||
, fileSystem{pathCache}
|
, fileSystem{pathCache}
|
||||||
@@ -214,7 +222,8 @@ public:
|
|||||||
, qmlDocumentParser{storage, pathCache}
|
, qmlDocumentParser{storage, pathCache}
|
||||||
, pathWatcher{pathCache, fileStatusCache, &updater}
|
, pathWatcher{pathCache, fileStatusCache, &updater}
|
||||||
, projectPartId{ProjectPartId::create(
|
, projectPartId{ProjectPartId::create(
|
||||||
pathCache.directoryPathId(Utils::PathString{project->projectDirectory().path()})
|
pathCache
|
||||||
|
.directoryPathId(Utils::PathString{project->projectDirectory().cleanPath().path()})
|
||||||
.internalId())}
|
.internalId())}
|
||||||
, qtPartId{ProjectPartId::create(
|
, qtPartId{ProjectPartId::create(
|
||||||
pathCache.directoryPathId(Utils::PathString{qmlPath(project)}).internalId())}
|
pathCache.directoryPathId(Utils::PathString{qmlPath(project)}).internalId())}
|
||||||
@@ -399,7 +408,7 @@ namespace {
|
|||||||
{
|
{
|
||||||
::QmlProjectManager::QmlBuildSystem *buildSystem = getQmlBuildSystem(target);
|
::QmlProjectManager::QmlBuildSystem *buildSystem = getQmlBuildSystem(target);
|
||||||
|
|
||||||
return buildSystem->canonicalProjectDir().path();
|
return buildSystem->canonicalProjectDir().cleanPath().path();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[maybe_unused]] void qtQmldirPaths(::ProjectExplorer::Target *target, QStringList &qmldirPaths)
|
[[maybe_unused]] void qtQmldirPaths(::ProjectExplorer::Target *target, QStringList &qmldirPaths)
|
||||||
@@ -460,16 +469,16 @@ namespace {
|
|||||||
QString propertyEditorResourcesPath()
|
QString propertyEditorResourcesPath()
|
||||||
{
|
{
|
||||||
#ifdef SHARE_QML_PATH
|
#ifdef SHARE_QML_PATH
|
||||||
if (qEnvironmentVariableIsSet("LOAD_QML_FROM_SOURCE")) {
|
if (qEnvironmentVariableIsSet("LOAD_QML_FROM_SOURCE"))
|
||||||
return QLatin1String(SHARE_QML_PATH) + "/propertyEditorQmlSources";
|
return (Utils::FilePath{SHARE_QML_PATH}.cleanPath() / "propertyEditorQmlSources").path();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return Core::ICore::resourcePath("qmldesigner/propertyEditorQmlSources").toUrlishString();
|
return resourcePath("qmldesigner/propertyEditorQmlSources");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString qtCreatorItemLibraryPath()
|
QString qtCreatorItemLibraryPath()
|
||||||
{
|
{
|
||||||
return Core::ICore::resourcePath("qmldesigner/itemLibrary").toUrlishString();
|
return resourcePath("qmldesigner/itemLibrary");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -511,7 +520,8 @@ void QmlDesignerProjectManager::generatePreview()
|
|||||||
|
|
||||||
if (qmlBuildSystem) {
|
if (qmlBuildSystem) {
|
||||||
m_previewImageCacheData->collector.setTarget(m_projectData->activeTarget);
|
m_previewImageCacheData->collector.setTarget(m_projectData->activeTarget);
|
||||||
m_previewImageCacheData->factory.generate(qmlBuildSystem->mainFilePath().toUrlishString().toUtf8());
|
m_previewImageCacheData->factory.generate(
|
||||||
|
qmlBuildSystem->mainFilePath().cleanPath().path().toUtf8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user