qmldesigner: Avoid crash of TextToModelMerger::getQMLSingletons()

When m_scopeChain is invalid (due to an invalid ui file)
getQMLSingletons would trigger a crash. Catch this case
and return early (an error message would then be displayed).

Fixes: QTCREATORBUG-24587
Change-Id: I80c70d8e7f1c88b14c53d3daebf957dc1e6089ee
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Fawzi Mohamed
2020-10-01 12:42:26 +02:00
parent 2e39132deb
commit 2f584585e3

View File

@@ -2179,6 +2179,9 @@ QSet<QPair<QString, QString> > TextToModelMerger::qrcMapping() const
QList<QmlTypeData> TextToModelMerger::getQMLSingletons() const QList<QmlTypeData> TextToModelMerger::getQMLSingletons() const
{ {
QList<QmlTypeData> list; QList<QmlTypeData> list;
if (!m_scopeChain || !m_scopeChain->document())
return list;
const QmlJS::Imports *imports = m_scopeChain->context()->imports( const QmlJS::Imports *imports = m_scopeChain->context()->imports(
m_scopeChain->document().data()); m_scopeChain->document().data());