QmlProject: Delay the opening of the fake project

There are cases e.g. when restarting QDS when the correct
.qmlproject will be opened anyway.

Task-number: QDS-13495
Change-Id: I04e13d148484c3afa8e08fe2a43eb700c615720a
Reviewed-by: Burak Hancerli <burak.hancerli@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2024-08-29 14:11:52 +02:00
parent 32181cdb96
commit 0dd40a41d6

View File

@@ -409,10 +409,16 @@ void QmlProjectPlugin::initialize()
[](Core::IDocument *document) { [](Core::IDocument *document) {
if (!ProjectManager::startupProject() if (!ProjectManager::startupProject()
&& document->filePath().completeSuffix() == "ui.qml") { && document->filePath().completeSuffix() == "ui.qml") {
const Utils::FilePath fileName = Utils::FilePath::fromString( QTimer::singleShot(1000, [document]() {
document->filePath().toString() + Constants::fakeProjectName); if (ProjectManager::startupProject())
auto result = ProjectExplorer::ProjectExplorerPlugin::openProjects({fileName}); return;
QTC_ASSERT(result.project(), return);
const Utils::FilePath fileName = Utils::FilePath::fromString(
document->filePath().toString() + Constants::fakeProjectName);
auto result = ProjectExplorer::ProjectExplorerPlugin::openProjects(
{fileName});
QTC_ASSERT(result.project(), return);
});
} }
}); });