From 830aeb8010a7c74c97c75f893a5aaf6614a5c31f Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Wed, 1 Sep 2021 14:59:17 +0200 Subject: [PATCH] CompilationDatabasePM: Fix crash at loading project If rootPath is empty, QtCreator will crash. Fixes: QTCREATORBUG-26126 Change-Id: Iac0d29d84d7203c0ec2ac8f5e3035816f52d7cdc Reviewed-by: Christian Kandeler --- .../compilationdatabaseproject.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp index de6d366f98c..966364b4b4f 100644 --- a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp +++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp @@ -440,8 +440,13 @@ Utils::FilePath CompilationDatabaseProject::rootPathFromSettings() const #ifdef WITH_TESTS return Utils::FilePath::fromString(projectDirectory().fileName()); #else - return Utils::FilePath::fromString( + auto rootPath = Utils::FilePath::fromString( namedSettings(ProjectExplorer::Constants::PROJECT_ROOT_PATH_KEY).toString()); + + if (rootPath.isEmpty()) + rootPath = Utils::FilePath::fromString(projectDirectory().fileName()); + + return rootPath; #endif }