diff options
author | David Faure <david.faure@kdab.com> | 2014-06-22 13:57:26 +0200 |
---|---|---|
committer | David Faure <david.faure@kdab.com> | 2014-07-03 10:59:07 +0200 |
commit | aabe80ae2895a4d7f115486c1e5f0033f33b6959 (patch) | |
tree | 446241d8c3d808264c1858f50dadb4c367ee1fd1 /src/xml/sax | |
parent | e26fa6d2066d76b295a71956f67cccc7941c3f32 (diff) |
Make QDom/QXmlSimpleReader reentrant.
I moved the evil static bool to QXmlSimpleReaderPrivate, and used
it from QDom, when the reader instance is a QXmlSimpleReader
(if it's not, nothing happens, like before).
Task-number: QTBUG-40015
Change-Id: I54ba89db334d7b086379c4a6840cf0de23f77027
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/xml/sax')
-rw-r--r-- | src/xml/sax/qxml.cpp | 18 | ||||
-rw-r--r-- | src/xml/sax/qxml.h | 1 | ||||
-rw-r--r-- | src/xml/sax/qxml_p.h | 2 |
3 files changed, 10 insertions, 11 deletions
diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 7db8d5f503..50900c17f0 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -100,10 +100,6 @@ static const signed char cltDq = 12; // " static const signed char cltSq = 13; // ' static const signed char cltUnknown = 14; -// Hack for letting QDom know where the skipped entity occurred -// ### the use of this variable means the code isn't reentrant. -bool qt_xml_skipped_entity_in_content; - // character lookup table static const signed char charLookupTable[256]={ cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x00 - 0x07 @@ -3230,7 +3226,7 @@ bool QXmlSimpleReader::parse(const QXmlInputSource *input, bool incremental) return false; } } - qt_xml_skipped_entity_in_content = false; + d->skipped_entity_in_content = false; return d->parseBeginOrContinue(0, incremental); } @@ -7594,13 +7590,13 @@ bool QXmlSimpleReaderPrivate::processReference() } if (contentHnd) { - qt_xml_skipped_entity_in_content = parseReference_context == InContent; + skipped_entity_in_content = parseReference_context == InContent; if (!contentHnd->skippedEntity(reference)) { - qt_xml_skipped_entity_in_content = false; + skipped_entity_in_content = false; reportParseError(contentHnd->errorString()); return false; // error } - qt_xml_skipped_entity_in_content = false; + skipped_entity_in_content = false; } } } else if ((*itExtern).notation.isNull()) { @@ -7630,13 +7626,13 @@ bool QXmlSimpleReaderPrivate::processReference() } } if (skipIt && contentHnd) { - qt_xml_skipped_entity_in_content = true; + skipped_entity_in_content = true; if (!contentHnd->skippedEntity(reference)) { - qt_xml_skipped_entity_in_content = false; + skipped_entity_in_content = false; reportParseError(contentHnd->errorString()); return false; // error } - qt_xml_skipped_entity_in_content = false; + skipped_entity_in_content = false; } parseReference_charDataRead = false; } break; diff --git a/src/xml/sax/qxml.h b/src/xml/sax/qxml.h index 743f8702af..2f276f75c6 100644 --- a/src/xml/sax/qxml.h +++ b/src/xml/sax/qxml.h @@ -269,6 +269,7 @@ private: QScopedPointer<QXmlSimpleReaderPrivate> d_ptr; friend class QXmlSimpleReaderLocator; + friend class QDomHandler; }; // diff --git a/src/xml/sax/qxml_p.h b/src/xml/sax/qxml_p.h index 5babd98d13..1cb919a554 100644 --- a/src/xml/sax/qxml_p.h +++ b/src/xml/sax/qxml_p.h @@ -148,6 +148,8 @@ private: // used in QXmlSimpleReader::parseContent() to decide whether character // data was read bool contentCharDataRead; + // Hack for letting QDom know where the skipped entity occurred + bool skipped_entity_in_content; // helper classes QScopedPointer<QXmlLocator> locator; |