summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppelementevaluator.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2021-01-27 11:50:15 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2021-01-27 11:17:33 +0000
commit59718d7c4eaf78576a2aaafb9ff2732d4ab99a60 (patch)
treead649642374a0160f013c8f7781136c7d17ee839 /src/plugins/cpptools/cppelementevaluator.cpp
parent9acde4f261476477330c78b87b9a19c12eed7755 (diff)
downloadqt-creator-59718d7c4eaf78576a2aaafb9ff2732d4ab99a60.tar.gz
Check if the document ptr is not null
Avoid a crash when double click in hierarchy view after the session has been changed or when the filename changed. Change-Id: Iebd7a99c220737262c79ade43c4ee8d11dcc037f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cppelementevaluator.cpp')
-rw-r--r--src/plugins/cpptools/cppelementevaluator.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppelementevaluator.cpp b/src/plugins/cpptools/cppelementevaluator.cpp
index 5cfdddcf2c..9cb6c6f807 100644
--- a/src/plugins/cpptools/cppelementevaluator.cpp
+++ b/src/plugins/cpptools/cppelementevaluator.cpp
@@ -548,6 +548,9 @@ public:
QString &expression)
{
doc = snapshot.document(m_fileName);
+ if (doc.isNull())
+ return false;
+
expression = m_expression;
// Fetch the expression's code
@@ -729,6 +732,8 @@ Utils::Link CppElementEvaluator::linkFromExpression(const QString &expression, c
{
const Snapshot &snapshot = CppModelManager::instance()->snapshot();
Document::Ptr doc = snapshot.document(fileName);
+ if (doc.isNull())
+ return Utils::Link();
Scope *scope = doc->globalNamespace();
TypeOfExpression typeOfExpression;