QmlDesigner: Fix access to nullptr

We try to access projectStorageData but it does not exists. Now we
return a dummyProjectStorage() instead. Because it is never accessed if
we don't use the project storage we should be fine.

Change-Id: Ic36a27472e95012b29b15ad33d2abe01507d64b4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
(cherry picked from commit c940cc5466)
This commit is contained in:
Marco Bubke
2023-03-28 14:58:44 +02:00
committed by Tim Jenssen
parent 31d6daf209
commit 6c1692f042

View File

@@ -185,11 +185,11 @@ public:
std::unique_ptr<ProjectStorageData> createProjectStorageData(::ProjectExplorer::Project *project)
{
if (qEnvironmentVariableIsSet("QDS_ACTIVATE_PROJECT_STORAGE")) {
if constexpr (useProjectStorage()) {
return std::make_unique<ProjectStorageData>(project);
} else {
return {};
}
return {};
}
} // namespace
@@ -262,9 +262,21 @@ AsynchronousImageCache &QmlDesignerProjectManager::asynchronousImageCache()
return imageCacheData()->asynchronousImageCache;
}
namespace {
ProjectStorage<Sqlite::Database> *dummyProjectStorage()
{
return nullptr;
}
} // namespace
ProjectStorage<Sqlite::Database> &QmlDesignerProjectManager::projectStorage()
{
return m_projectData->projectStorageData->storage;
if constexpr (useProjectStorage()) {
return m_projectData->projectStorageData->storage;
} else {
return *dummyProjectStorage();
}
}
void QmlDesignerProjectManager::editorOpened(::Core::IEditor *) {}