From e49b0670c844b7a9e3f7113e724dbc72965f52a3 Mon Sep 17 00:00:00 2001
From: Ulf Hermann <ulf.hermann@qt.io>
Date: Mon, 30 May 2016 17:38:10 +0200
Subject: [PATCH] QmlJS: Don't crash if the type stack is empty

Change-Id: If4e0155e8167f3edee1890dee5fd8b19623bba17
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
---
 src/libs/qmljs/qmljscheck.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp
index 0199539517b..e5fd12d6b97 100644
--- a/src/libs/qmljs/qmljscheck.cpp
+++ b/src/libs/qmljs/qmljscheck.cpp
@@ -1551,7 +1551,8 @@ bool Check::visit(CallExpression *ast)
     // We have to allow the qsTr function for translation.
     bool isTranslationFunction = (name == QLatin1String("qsTr") || name == QLatin1String("qsTrId"));
     // allow adding connections with the help of the qt quick designer ui
-    bool isDirectInConnectionsScope = m_typeStack.last() == QLatin1String("Connections");
+    bool isDirectInConnectionsScope =
+            (!m_typeStack.isEmpty() && m_typeStack.last() == QLatin1String("Connections"));
     if (!isTranslationFunction && !isDirectInConnectionsScope)
         addMessage(ErrFunctionsNotSupportedInQmlUi, location);
 
-- 
GitLab