QmlDesigner: Update local path module if file url is changed

Change-Id: I9197148879b694fef46d44a530d8534177b26271
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2024-10-24 15:35:30 +02:00
parent 447c377267
commit eab20da684
2 changed files with 14 additions and 0 deletions

View File

@@ -285,6 +285,8 @@ void ModelPrivate::setFileUrl(const QUrl &fileUrl)
m_sourceId = pathCache->sourceId(SourcePath{path});
auto found = std::find(path.rbegin(), path.rend(), u'/').base();
m_localPath = Utils::PathString{QStringView{path.begin(), std::prev(found)}};
auto imports = createStorageImports(m_imports, m_localPath, *projectStorage, m_sourceId);
projectStorage->synchronizeDocumentImports(std::move(imports), m_sourceId);
}
for (const QPointer<AbstractView> &view : std::as_const(m_viewList))

View File

@@ -1438,4 +1438,16 @@ TEST_F(Model_FileUrl, do_not_notify_if_there_is_no_change)
model.setFileUrl(fileUrl);
}
TEST_F(Model_FileUrl, updated_local_path_module)
{
auto localPathModuleId = projectStorageMock.moduleId("/path", ModuleKind::PathLibrary);
EXPECT_CALL(projectStorageMock,
synchronizeDocumentImports(Contains(IsImport(localPathModuleId, barSourceId, -1, -1)),
barSourceId));
model.setFileUrl(barFilePathUrl);
}
} // namespace