diff --git a/src/plugins/qmldesigner/libs/designercore/model/model.cpp b/src/plugins/qmldesigner/libs/designercore/model/model.cpp index d9e5bc9deb3..4f4dfeed7fd 100644 --- a/src/plugins/qmldesigner/libs/designercore/model/model.cpp +++ b/src/plugins/qmldesigner/libs/designercore/model/model.cpp @@ -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 &view : std::as_const(m_viewList)) diff --git a/tests/unit/tests/unittests/model/model-test.cpp b/tests/unit/tests/unittests/model/model-test.cpp index edd2539e7fe..15d2bb86aa8 100644 --- a/tests/unit/tests/unittests/model/model-test.cpp +++ b/tests/unit/tests/unittests/model/model-test.cpp @@ -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