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>
This commit is contained in:
Jarek Kobus
2021-01-27 11:50:15 +01:00
parent 9acde4f261
commit 59718d7c4e

View File

@@ -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;