summaryrefslogtreecommitdiffstats
path: root/src/xml
diff options
context:
space:
mode:
Diffstat (limited to 'src/xml')
-rw-r--r--src/xml/dom/qdom.cpp88
-rw-r--r--src/xml/sax/qxml.cpp90
-rw-r--r--src/xml/sax/qxml.h5
-rw-r--r--src/xml/xml.pro2
4 files changed, 94 insertions, 91 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index f079851..cd9f37e 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -512,8 +512,8 @@ public:
bool setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn);
// Attributes
- QDomDocumentTypePrivate* doctype() { return type; };
- QDomImplementationPrivate* implementation() { return impl; };
+ QDomDocumentTypePrivate* doctype() { return type.data(); };
+ QDomImplementationPrivate* implementation() { return impl.data(); };
QDomElementPrivate* documentElement();
// Factories
@@ -537,8 +537,8 @@ public:
void clear();
// Variables
- QDomImplementationPrivate* impl;
- QDomDocumentTypePrivate* type;
+ QScopedSharedPointer<QDomImplementationPrivate> impl;
+ QScopedSharedPointer<QDomDocumentTypePrivate> type;
void saveDocument(QTextStream& stream, const int indent, QDomNode::EncodingPolicy encUsed) const;
@@ -3059,7 +3059,7 @@ QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate()
QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate* p)
{
- QDomNamedNodeMapPrivate* m = new QDomNamedNodeMapPrivate(p);
+ QScopedPointer<QDomNamedNodeMapPrivate> m(new QDomNamedNodeMapPrivate(p));
m->readonly = readonly;
m->appendToParent = appendToParent;
@@ -3072,7 +3072,7 @@ QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate* p)
// we are no longer interested in ownership
m->ref.deref();
- return m;
+ return m.take();
}
void QDomNamedNodeMapPrivate::clearMap()
@@ -3498,13 +3498,18 @@ QDomDocumentTypePrivate::~QDomDocumentTypePrivate()
void QDomDocumentTypePrivate::init()
{
entities = new QDomNamedNodeMapPrivate(this);
- notations = new QDomNamedNodeMapPrivate(this);
- publicId.clear();
- systemId.clear();
- internalSubset.clear();
-
- entities->setAppendToParent(true);
- notations->setAppendToParent(true);
+ QT_TRY {
+ notations = new QDomNamedNodeMapPrivate(this);
+ publicId.clear();
+ systemId.clear();
+ internalSubset.clear();
+
+ entities->setAppendToParent(true);
+ notations->setAppendToParent(true);
+ } QT_CATCH(...) {
+ delete entities;
+ QT_RETHROW;
+ }
}
QDomNodePrivate* QDomDocumentTypePrivate::cloneNode(bool deep)
@@ -6146,8 +6151,8 @@ QDomDocumentPrivate::QDomDocumentPrivate()
: QDomNodePrivate(0),
nodeListTime(1)
{
- impl = new QDomImplementationPrivate;
- type = new QDomDocumentTypePrivate(this, this);
+ impl.reset(new QDomImplementationPrivate);
+ type.reset(new QDomDocumentTypePrivate(this, this));
name = QLatin1String("#document");
}
@@ -6156,8 +6161,8 @@ QDomDocumentPrivate::QDomDocumentPrivate(const QString& aname)
: QDomNodePrivate(0),
nodeListTime(1)
{
- impl = new QDomImplementationPrivate;
- type = new QDomDocumentTypePrivate(this, this);
+ impl.reset(new QDomImplementationPrivate);
+ type.reset(new QDomDocumentTypePrivate(this, this));
type->name = aname;
name = QLatin1String("#document");
@@ -6167,12 +6172,11 @@ QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentTypePrivate* dt)
: QDomNodePrivate(0),
nodeListTime(1)
{
- impl = new QDomImplementationPrivate;
+ impl.reset(new QDomImplementationPrivate);
if (dt != 0) {
- type = dt;
- type->ref.ref();
+ type.assign(dt);
} else {
- type = new QDomDocumentTypePrivate(this, this);
+ type.reset(new QDomDocumentTypePrivate(this, this));
}
name = QLatin1String("#document");
@@ -6182,31 +6186,19 @@ QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentPrivate* n, bool deep)
: QDomNodePrivate(n, deep),
nodeListTime(1)
{
- impl = n->impl->clone();
- // Reference count is down to 0, so we set it to 1 here.
- impl->ref.ref();
- type = (QDomDocumentTypePrivate*)n->type->cloneNode();
+ impl.assign(n->impl->clone());
+ type.assign((QDomDocumentTypePrivate*)n->type->cloneNode());
type->setParent(this);
- // Reference count is down to 0, so we set it to 1 here.
- type->ref.ref();
}
QDomDocumentPrivate::~QDomDocumentPrivate()
{
- if (!impl->ref.deref())
- delete impl;
- if (!type->ref.deref())
- delete type;
}
void QDomDocumentPrivate::clear()
{
- if (!impl->ref.deref())
- delete impl;
- if (!type->ref.deref())
- delete type;
- impl = 0;
- type = 0;
+ impl.assign(0);
+ type.assign(0);
QDomNodePrivate::clear();
}
@@ -6227,8 +6219,8 @@ bool QDomDocumentPrivate::setContent(QXmlInputSource *source, bool namespaceProc
bool QDomDocumentPrivate::setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn)
{
clear();
- impl = new QDomImplementationPrivate;
- type = new QDomDocumentTypePrivate(this, this);
+ impl.reset(new QDomImplementationPrivate);
+ type.reset(new QDomDocumentTypePrivate(this, this));
bool namespaceProcessing = reader->feature(QLatin1String("http://xml.org/sax/features/namespaces"))
&& !reader->feature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"));
@@ -7446,20 +7438,22 @@ bool QDomHandler::characters(const QString& ch)
if (node == doc)
return false;
- QDomNodePrivate *n;
+ QScopedPointer<QDomNodePrivate> n;
if (cdata) {
- n = doc->createCDATASection(ch);
+ n.reset(doc->createCDATASection(ch));
} else if (!entityName.isEmpty()) {
- QDomEntityPrivate* e = new QDomEntityPrivate(doc, 0, entityName,
- QString(), QString(), QString());
+ QScopedPointer<QDomEntityPrivate> e(new QDomEntityPrivate(doc, 0, entityName,
+ QString(), QString(), QString()));
e->value = ch;
- doc->doctype()->appendChild(e);
- n = doc->createEntityReference(entityName);
+ doc->doctype()->appendChild(e.data());
+ e.take();
+ n.reset(doc->createEntityReference(entityName));
} else {
- n = doc->createTextNode(ch);
+ n.reset(doc->createTextNode(ch));
}
n->setLocation(locator->lineNumber(), locator->columnNumber());
- node->appendChild(n);
+ node->appendChild(n.data());
+ n.take();
return true;
}
diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp
index b8af8d1..d7ac5c5 100644
--- a/src/xml/sax/qxml.cpp
+++ b/src/xml/sax/qxml.cpp
@@ -272,10 +272,11 @@ class QXmlDefaultHandlerPrivate
class QXmlSimpleReaderPrivate
{
+public:
+ ~QXmlSimpleReaderPrivate();
private:
// functions
- QXmlSimpleReaderPrivate();
- ~QXmlSimpleReaderPrivate();
+ QXmlSimpleReaderPrivate(QXmlSimpleReader *reader);
void initIncrementalParsing();
// used to determine if elements are correctly nested
@@ -312,7 +313,9 @@ private:
// used for parsing of entity references
struct XmlRef {
- XmlRef(const QString &_name = QString(), const QString &_value = QString())
+ XmlRef()
+ : index(0) {}
+ XmlRef(const QString &_name, const QString &_value)
: name(_name), value(_value), index(0) {}
bool isEmpty() const { return index == value.length(); }
QChar next() { return value.at(index++); }
@@ -358,7 +361,7 @@ private:
bool contentCharDataRead;
// helper classes
- QXmlLocator *locator;
+ QScopedPointer<QXmlLocator> locator;
QXmlNamespaceSupport namespaceSupport;
// error string
@@ -553,8 +556,8 @@ private:
QXmlParseException::QXmlParseException(const QString& name, int c, int l,
const QString& p, const QString& s)
+ : d(new QXmlParseExceptionPrivate)
{
- d = new QXmlParseExceptionPrivate;
d->msg = name;
d->column = c;
d->line = l;
@@ -565,9 +568,10 @@ QXmlParseException::QXmlParseException(const QString& name, int c, int l,
/*!
Creates a copy of \a other.
*/
-QXmlParseException::QXmlParseException(const QXmlParseException& other)
+QXmlParseException::QXmlParseException(const QXmlParseException& other) :
+ d(new QXmlParseExceptionPrivate(*other.d))
{
- d = new QXmlParseExceptionPrivate(*other.d);
+
}
/*!
@@ -575,7 +579,6 @@ QXmlParseException::QXmlParseException(const QXmlParseException& other)
*/
QXmlParseException::~QXmlParseException()
{
- delete d;
}
/*!
@@ -944,8 +947,9 @@ void QXmlNamespaceSupport::popContext()
*/
void QXmlNamespaceSupport::reset()
{
+ QXmlNamespaceSupportPrivate *newD = new QXmlNamespaceSupportPrivate;
delete d;
- d = new QXmlNamespaceSupportPrivate;
+ d = newD;
}
@@ -1276,18 +1280,23 @@ void QXmlInputSource::init()
{
d = new QXmlInputSourcePrivate;
- d->inputDevice = 0;
- d->inputStream = 0;
+ QT_TRY {
+ d->inputDevice = 0;
+ d->inputStream = 0;
- setData(QString());
+ setData(QString());
#ifndef QT_NO_TEXTCODEC
- d->encMapper = 0;
+ d->encMapper = 0;
#endif
- d->nextReturnedEndOfData = true; // first call to next() will call fetchData()
+ d->nextReturnedEndOfData = true; // first call to next() will call fetchData()
- d->encodingDeclBytes.clear();
- d->encodingDeclChars.clear();
- d->lookingForEncodingDecl = true;
+ d->encodingDeclBytes.clear();
+ d->encodingDeclChars.clear();
+ d->lookingForEncodingDecl = true;
+ } QT_CATCH(...) {
+ delete(d);
+ QT_RETHROW;
+ }
}
/*!
@@ -2731,9 +2740,24 @@ inline void QXmlSimpleReaderPrivate::refClear()
refValueLen = 0; refArrayPos = 0;
}
-QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate()
+QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate(QXmlSimpleReader *reader)
{
+ q_ptr = reader;
parseStack = 0;
+
+ locator.reset(new QXmlSimpleReaderLocator(reader));
+ entityRes = 0;
+ dtdHnd = 0;
+ contentHnd = 0;
+ errorHnd = 0;
+ lexicalHnd = 0;
+ declHnd = 0;
+
+ // default feature settings
+ useNamespaces = true;
+ useNamespacePrefixes = false;
+ reportWhitespaceCharData = true;
+ reportEntities = false;
}
QXmlSimpleReaderPrivate::~QXmlSimpleReaderPrivate()
@@ -2743,8 +2767,10 @@ QXmlSimpleReaderPrivate::~QXmlSimpleReaderPrivate()
void QXmlSimpleReaderPrivate::initIncrementalParsing()
{
- delete parseStack;
- parseStack = new QStack<ParseState>;
+ if( parseStack )
+ parseStack->clear();
+ else
+ parseStack = new QStack<ParseState>;
}
/*********************************************
@@ -3111,25 +3137,8 @@ static NameChar determineNameChar(QChar ch)
*/
QXmlSimpleReader::QXmlSimpleReader()
+ : d_ptr(new QXmlSimpleReaderPrivate(this))
{
- d_ptr = new QXmlSimpleReaderPrivate();
- Q_D(QXmlSimpleReader);
- d->q_ptr = this;
-
- d->locator = new QXmlSimpleReaderLocator(this);
-
- d->entityRes = 0;
- d->dtdHnd = 0;
- d->contentHnd = 0;
- d->errorHnd = 0;
- d->lexicalHnd = 0;
- d->declHnd = 0;
-
- // default feature settings
- d->useNamespaces = true;
- d->useNamespacePrefixes = false;
- d->reportWhitespaceCharData = true;
- d->reportEntities = false;
}
/*!
@@ -3137,9 +3146,6 @@ QXmlSimpleReader::QXmlSimpleReader()
*/
QXmlSimpleReader::~QXmlSimpleReader()
{
- Q_D(QXmlSimpleReader);
- delete d->locator;
- delete d;
}
/*!
@@ -3422,7 +3428,7 @@ bool QXmlSimpleReader::parse(const QXmlInputSource *input, bool incremental)
// call the handler
if (d->contentHnd) {
- d->contentHnd->setDocumentLocator(d->locator);
+ d->contentHnd->setDocumentLocator(d->locator.data());
if (!d->contentHnd->startDocument()) {
d->reportParseError(d->contentHnd->errorString());
d->tags.clear();
diff --git a/src/xml/sax/qxml.h b/src/xml/sax/qxml.h
index d116304..e5f6d12 100644
--- a/src/xml/sax/qxml.h
+++ b/src/xml/sax/qxml.h
@@ -47,6 +47,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qlist.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -203,7 +204,7 @@ public:
QString message() const;
private:
- QXmlParseExceptionPrivate *d;
+ QScopedPointer<QXmlParseExceptionPrivate> d;
};
@@ -272,7 +273,7 @@ public:
private:
Q_DISABLE_COPY(QXmlSimpleReader)
Q_DECLARE_PRIVATE(QXmlSimpleReader)
- QXmlSimpleReaderPrivate* d_ptr;
+ QScopedPointer<QXmlSimpleReaderPrivate> d_ptr;
friend class QXmlSimpleReaderLocator;
};
diff --git a/src/xml/xml.pro b/src/xml/xml.pro
index 0c7133c..8d1bf68 100644
--- a/src/xml/xml.pro
+++ b/src/xml/xml.pro
@@ -18,3 +18,5 @@ win32-borland {
include(dom/dom.pri)
include(sax/sax.pri)
include(stream/stream.pri)
+
+symbian:TARGET.UID3=0x2001B2E0