CMakePM: Fix crash in findLinkAt

Fixes: QTCREATORBUG-29715
Change-Id: I4db919c8858631beb573789d1888b3dbee606c50
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Cristian Adam
2023-10-06 17:55:57 +02:00
parent ad680902b2
commit 399e12c973

View File

@@ -310,7 +310,7 @@ void CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
if (auto project = ProjectTree::currentProject()) {
buffer.replace("${CMAKE_SOURCE_DIR}", project->projectDirectory().path());
if (auto bs = ProjectTree::currentBuildSystem()) {
if (auto bs = ProjectTree::currentBuildSystem(); bs->buildConfiguration()) {
buffer.replace("${CMAKE_BINARY_DIR}", bs->buildConfiguration()->buildDirectory().path());
// Get the path suffix from current source dir to project source dir and apply it
@@ -327,7 +327,7 @@ void CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
.path());
// Check if the symbols is a user defined function or macro
const CMakeBuildSystem *cbs = static_cast<const CMakeBuildSystem *>(bs);
if (const auto cbs = qobject_cast<const CMakeBuildSystem *>(bs)) {
// Strip variable coating
if (buffer.startsWith("${") && buffer.endsWith("}"))
buffer = buffer.mid(2, buffer.size() - 3);
@@ -361,6 +361,7 @@ void CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
}
}
}
}
// TODO: Resolve more variables
// Resolve local variables and functions