diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-12 14:49:13 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-12 19:45:08 +0000 |
commit | a9b0e47ab53177887eed8594b456fe0f178f0f43 (patch) | |
tree | 3c76ebcf40f1775c49acc7e0fb729635cdb7e38c /sources | |
parent | 612bfd01e1e7698cb3a06d619cc7d7c7acd3d273 (diff) |
shiboken: Do not swallow XML parsing errors
Handler::parseFile() had some returns where the errors would be lost.
Add accessor for the errorString() to the Handler and output
in the calling function.
Task-number: PYSIDE-743
Change-Id: I42d2b88478e8ebfac7f590c2086046116e2add74
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/shiboken2/ApiExtractor/typedatabase.cpp | 5 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/typesystem.cpp | 7 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/typesystem_p.h | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 9529de40a..e494ba174 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -518,7 +518,10 @@ bool TypeDatabase::parseFile(QIODevice* device, bool generate) { QXmlStreamReader reader(device); Handler handler(this, generate); - return handler.parse(reader); + const bool result = handler.parse(reader); + if (!result) + qCWarning(lcShiboken, "%s", qPrintable(handler.errorString())); + return result; } PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString& name) const diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp index baaec6d30..f316de80a 100644 --- a/sources/shiboken2/ApiExtractor/typesystem.cpp +++ b/sources/shiboken2/ApiExtractor/typesystem.cpp @@ -210,11 +210,6 @@ static QString msgReaderError(const QXmlStreamReader &reader, const QString &wha return message; } -static QString msgReaderError(const QXmlStreamReader &reader) -{ - return msgReaderError(reader, reader.errorString()); -} - static QString msgInvalidVersion(const QStringRef &version, const QString &package = QString()) { QString result; @@ -238,7 +233,7 @@ bool Handler::parse(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::NoToken: case QXmlStreamReader::Invalid: - qCWarning(lcShiboken).noquote().nospace() << msgReaderError(reader); + m_error = msgReaderError(reader, reader.errorString()); return false; case QXmlStreamReader::StartElement: if (!startElement(reader.name(), reader.attributes())) { diff --git a/sources/shiboken2/ApiExtractor/typesystem_p.h b/sources/shiboken2/ApiExtractor/typesystem_p.h index 882cf3fab..cbca7a557 100644 --- a/sources/shiboken2/ApiExtractor/typesystem_p.h +++ b/sources/shiboken2/ApiExtractor/typesystem_p.h @@ -140,6 +140,8 @@ public: bool parse(QXmlStreamReader &reader); + QString errorString() const { return m_error; } + private: bool startElement(const QStringRef& localName, const QXmlStreamAttributes& atts); bool handleSmartPointerEntry(StackElement *element, |