forked from qt-creator/qt-creator
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:
@@ -285,6 +285,8 @@ void ModelPrivate::setFileUrl(const QUrl &fileUrl)
|
|||||||
m_sourceId = pathCache->sourceId(SourcePath{path});
|
m_sourceId = pathCache->sourceId(SourcePath{path});
|
||||||
auto found = std::find(path.rbegin(), path.rend(), u'/').base();
|
auto found = std::find(path.rbegin(), path.rend(), u'/').base();
|
||||||
m_localPath = Utils::PathString{QStringView{path.begin(), std::prev(found)}};
|
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))
|
for (const QPointer<AbstractView> &view : std::as_const(m_viewList))
|
||||||
|
@@ -1438,4 +1438,16 @@ TEST_F(Model_FileUrl, do_not_notify_if_there_is_no_change)
|
|||||||
|
|
||||||
model.setFileUrl(fileUrl);
|
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
|
} // namespace
|
||||||
|
Reference in New Issue
Block a user