diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-12-11 09:44:50 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-12-11 20:39:54 +0000 |
commit | 123031b6efa9e95c787b2069fed6f6777a92dc13 (patch) | |
tree | 6aebb4d92f62ef55492a7d0a11355db68dd5abab /sources/shiboken2/ApiExtractor/typesystem.cpp | |
parent | be44e04d6ab219ba70decbe6f7f8e33293c49418 (diff) |
shiboken: Make warning about non-existing templates fatal
It should abort as it will usually result in broken code.
Change-Id: I81d930c4516b0ee97dec985525fab8140fdce3dc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/typesystem.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/typesystem.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp index e82221a40..ff4f74d8c 100644 --- a/sources/shiboken2/ApiExtractor/typesystem.cpp +++ b/sources/shiboken2/ApiExtractor/typesystem.cpp @@ -3053,23 +3053,20 @@ QString fixCppTypeName(const QString &name) QString TemplateInstance::expandCode() const { TemplateEntry *templateEntry = TypeDatabase::instance()->findTemplate(m_name); - if (templateEntry) { - typedef QHash<QString, QString>::const_iterator ConstIt; - QString code = templateEntry->code(); - for (ConstIt it = replaceRules.begin(), end = replaceRules.end(); it != end; ++it) - code.replace(it.key(), it.value()); - while (!code.isEmpty() && code.at(code.size() - 1).isSpace()) - code.chop(1); - QString result = QLatin1String("// TEMPLATE - ") + m_name + QLatin1String(" - START"); - if (!code.startsWith(QLatin1Char('\n'))) - result += QLatin1Char('\n'); - result += code; - result += QLatin1String("\n// TEMPLATE - ") + m_name + QLatin1String(" - END"); - return result; - } - qCWarning(lcShiboken).noquote().nospace() - << "insert-template referring to non-existing template '" << m_name << '\''; - return QString(); + if (!templateEntry) + qFatal("<insert-template> referring to non-existing template '%s'.", qPrintable(m_name)); + + QString code = templateEntry->code(); + for (auto it = replaceRules.cbegin(), end = replaceRules.cend(); it != end; ++it) + code.replace(it.key(), it.value()); + while (!code.isEmpty() && code.at(code.size() - 1).isSpace()) + code.chop(1); + QString result = QLatin1String("// TEMPLATE - ") + m_name + QLatin1String(" - START"); + if (!code.startsWith(QLatin1Char('\n'))) + result += QLatin1Char('\n'); + result += code; + result += QLatin1String("\n// TEMPLATE - ") + m_name + QLatin1String(" - END"); + return result; } |