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.cpp85
-rw-r--r--src/xml/sax/qxml.h5
-rw-r--r--src/xml/xml.pro2
4 files changed, 91 insertions, 89 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index da0e31b..0e23f05 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;
@@ -3060,7 +3060,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;
@@ -3073,7 +3073,7 @@ QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate* p)
// we are no longer interested in ownership
m->ref.deref();
- return m;
+ return m.take();
}
void QDomNamedNodeMapPrivate::clearMap()
@@ -3499,13 +3499,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)
@@ -6147,8 +6152,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");
}
@@ -6157,8 +6162,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");
@@ -6168,12 +6173,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");
@@ -6183,31 +6187,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();
}
@@ -6228,8 +6220,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"));
@@ -7447,20 +7439,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 db50f01..8ad9f77 100644
--- a/src/xml/sax/qxml.cpp
+++ b/src/xml/sax/qxml.cpp
@@ -262,10 +262,11 @@ class QXmlDefaultHandlerPrivate
class QXmlSimpleReaderPrivate
{
+public:
+ ~QXmlSimpleReaderPrivate();
private:
// functions
- QXmlSimpleReaderPrivate();
- ~QXmlSimpleReaderPrivate();
+ QXmlSimpleReaderPrivate(QXmlSimpleReader *reader);
void initIncrementalParsing();
// used to determine if elements are correctly nested
@@ -302,7 +303,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++); }
@@ -348,7 +351,7 @@ private:
bool contentCharDataRead;
// helper classes
- QXmlLocator *locator;
+ QScopedPointer<QXmlLocator> locator;
QXmlNamespaceSupport namespaceSupport;
// error string
@@ -543,8 +546,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;
@@ -557,7 +560,6 @@ QXmlParseException::QXmlParseException(const QString& name, int c, int l,
*/
QXmlParseException::~QXmlParseException()
{
- delete d;
}
/*!
@@ -926,8 +928,9 @@ void QXmlNamespaceSupport::popContext()
*/
void QXmlNamespaceSupport::reset()
{
+ QXmlNamespaceSupportPrivate *newD = new QXmlNamespaceSupportPrivate;
delete d;
- d = new QXmlNamespaceSupportPrivate;
+ d = newD;
}
@@ -1258,18 +1261,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;
+ }
}
/*!
@@ -2713,9 +2721,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()
@@ -2725,8 +2748,10 @@ QXmlSimpleReaderPrivate::~QXmlSimpleReaderPrivate()
void QXmlSimpleReaderPrivate::initIncrementalParsing()
{
- delete parseStack;
- parseStack = new QStack<ParseState>;
+ if( parseStack )
+ parseStack->clear();
+ else
+ parseStack = new QStack<ParseState>;
}
/*********************************************
@@ -3099,25 +3124,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;
}
/*!
@@ -3125,9 +3133,6 @@ QXmlSimpleReader::QXmlSimpleReader()
*/
QXmlSimpleReader::~QXmlSimpleReader()
{
- Q_D(QXmlSimpleReader);
- delete d->locator;
- delete d;
}
/*!
@@ -3410,7 +3415,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 e0165d3..8e3eb25 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
@@ -202,7 +203,7 @@ public:
QString message() const;
private:
- QXmlParseExceptionPrivate *d;
+ QScopedPointer<QXmlParseExceptionPrivate> d;
};
@@ -271,7 +272,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