diff options
Diffstat (limited to 'src/script')
24 files changed, 121 insertions, 142 deletions
diff --git a/src/script/qscriptable.cpp b/src/script/qscriptable.cpp index 5da9e95..455cc98 100644 --- a/src/script/qscriptable.cpp +++ b/src/script/qscriptable.cpp @@ -118,8 +118,6 @@ QScriptable::QScriptable() */ QScriptable::~QScriptable() { - delete d_ptr; - d_ptr = 0; } /*! diff --git a/src/script/qscriptable.h b/src/script/qscriptable.h index 1015a00..76a0496 100644 --- a/src/script/qscriptable.h +++ b/src/script/qscriptable.h @@ -46,6 +46,8 @@ #ifndef QT_NO_SCRIPT +#include <QtCore/qscopedpointer.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -73,7 +75,7 @@ public: QScriptValue argument(int index) const; private: - QScriptablePrivate *d_ptr; + QScopedPointer<QScriptablePrivate> d_ptr; Q_DISABLE_COPY(QScriptable) Q_DECLARE_PRIVATE(QScriptable) diff --git a/src/script/qscriptclass.cpp b/src/script/qscriptclass.cpp index a964d1b..1a0cdfe 100644 --- a/src/script/qscriptclass.cpp +++ b/src/script/qscriptclass.cpp @@ -457,8 +457,6 @@ QScriptClass::QScriptClass(QScriptEngine *engine, QScriptClassPrivate &dd) */ QScriptClass::~QScriptClass() { - delete d_ptr; - d_ptr = 0; } /*! diff --git a/src/script/qscriptclass.h b/src/script/qscriptclass.h index dec53e8..7070470 100644 --- a/src/script/qscriptclass.h +++ b/src/script/qscriptclass.h @@ -47,6 +47,7 @@ #ifndef QT_NO_SCRIPT #include <QtCore/qvariant.h> +#include <QtCore/qscopedpointer.h> #include <QtScript/qscriptvalue.h> QT_BEGIN_HEADER @@ -103,7 +104,7 @@ public: protected: QScriptClass(QScriptEngine *engine, QScriptClassPrivate &dd); - QScriptClassPrivate *d_ptr; + QScopedPointer<QScriptClassPrivate> d_ptr; private: Q_DECLARE_PRIVATE(QScriptClass) diff --git a/src/script/qscriptclasspropertyiterator.cpp b/src/script/qscriptclasspropertyiterator.cpp index 88ea2cc..bb07b08 100644 --- a/src/script/qscriptclasspropertyiterator.cpp +++ b/src/script/qscriptclasspropertyiterator.cpp @@ -111,8 +111,6 @@ QScriptClassPropertyIterator::QScriptClassPropertyIterator(const QScriptValue &o */ QScriptClassPropertyIterator::~QScriptClassPropertyIterator() { - delete d_ptr; - d_ptr = 0; } /*! diff --git a/src/script/qscriptclasspropertyiterator.h b/src/script/qscriptclasspropertyiterator.h index 03d9c71..1570410 100644 --- a/src/script/qscriptclasspropertyiterator.h +++ b/src/script/qscriptclasspropertyiterator.h @@ -46,6 +46,7 @@ #ifndef QT_NO_SCRIPT +#include <QtCore/qscopedpointer.h> #include <QtScript/qscriptvalue.h> QT_BEGIN_HEADER @@ -80,7 +81,7 @@ public: protected: QScriptClassPropertyIterator(const QScriptValue &object, QScriptClassPropertyIteratorPrivate &dd); - QScriptClassPropertyIteratorPrivate *d_ptr; + QScopedPointer<QScriptClassPropertyIteratorPrivate> d_ptr; private: Q_DECLARE_PRIVATE(QScriptClassPropertyIterator) diff --git a/src/script/qscriptcontext.cpp b/src/script/qscriptcontext.cpp index 62d5ea8..6a3e945 100644 --- a/src/script/qscriptcontext.cpp +++ b/src/script/qscriptcontext.cpp @@ -219,8 +219,6 @@ QScriptContext::QScriptContext(): */ QScriptContext::~QScriptContext() { - delete d_ptr; - d_ptr = 0; } /*! diff --git a/src/script/qscriptcontext.h b/src/script/qscriptcontext.h index c8094da..5a86cba 100644 --- a/src/script/qscriptcontext.h +++ b/src/script/qscriptcontext.h @@ -46,6 +46,7 @@ #ifndef QT_NO_SCRIPT +#include <QtCore/qscopedpointer.h> #include <QtScript/qscriptvalue.h> QT_BEGIN_HEADER @@ -111,7 +112,7 @@ public: private: QScriptContext(); - QScriptContextPrivate *d_ptr; + QScopedPointer<QScriptContextPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptContext) Q_DISABLE_COPY(QScriptContext) diff --git a/src/script/qscriptcontextinfo.cpp b/src/script/qscriptcontextinfo.cpp index 7590e57..d22ee85 100644 --- a/src/script/qscriptcontextinfo.cpp +++ b/src/script/qscriptcontextinfo.cpp @@ -204,13 +204,12 @@ QScriptContextInfoPrivate::~QScriptContextInfoPrivate() previously created QScriptContextInfo. */ QScriptContextInfo::QScriptContextInfo(const QScriptContext *context) + : d_ptr(0) { if (context) { - d_ptr = new QScriptContextInfoPrivate(context); + d_ptr.data_ptr() = new QScriptContextInfoPrivate(context); d_ptr->q_ptr = this; d_ptr->ref.ref(); - } else { - d_ptr = 0; } } @@ -218,7 +217,7 @@ QScriptContextInfo::QScriptContextInfo(const QScriptContext *context) Constructs a new QScriptContextInfo from the \a other info. */ QScriptContextInfo::QScriptContextInfo(const QScriptContextInfo &other) - : d_ptr(other.d_ptr) + : d_ptr(other.d_ptr.data()) { if (d_ptr) d_ptr->ref.ref(); @@ -239,10 +238,6 @@ QScriptContextInfo::QScriptContextInfo() */ QScriptContextInfo::~QScriptContextInfo() { - if (d_ptr && !d_ptr->ref.deref()) { - delete d_ptr; - d_ptr = 0; - } } /*! @@ -251,15 +246,7 @@ QScriptContextInfo::~QScriptContextInfo() */ QScriptContextInfo &QScriptContextInfo::operator=(const QScriptContextInfo &other) { - if (d_ptr == other.d_ptr) - return *this; - if (d_ptr && !d_ptr->ref.deref()) { - delete d_ptr; - d_ptr = 0; - } - d_ptr = other.d_ptr; - if (d_ptr) - d_ptr->ref.ref(); + d_ptr.assign(other.d_ptr.data()); return *this; } @@ -510,7 +497,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptContextInfo &info) Q_SCRIPT_EXPORT QDataStream &operator>>(QDataStream &in, QScriptContextInfo &info) { if (!info.d_ptr) { - info.d_ptr = new QScriptContextInfoPrivate(); + info.d_ptr.data_ptr() = new QScriptContextInfoPrivate(); info.d_ptr->ref.ref(); } diff --git a/src/script/qscriptcontextinfo.h b/src/script/qscriptcontextinfo.h index c0c5090..3540060 100644 --- a/src/script/qscriptcontextinfo.h +++ b/src/script/qscriptcontextinfo.h @@ -48,6 +48,7 @@ #include <QtCore/qlist.h> #include <QtCore/qstringlist.h> +#include <QtCore/qscopedpointer.h> QT_BEGIN_HEADER @@ -104,7 +105,7 @@ public: bool operator!=(const QScriptContextInfo &other) const; private: - QScriptContextInfoPrivate *d_ptr; + QScopedSharedPointer<QScriptContextInfoPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptContextInfo) }; diff --git a/src/script/qscriptengine.cpp b/src/script/qscriptengine.cpp index de78403..48ba459 100644 --- a/src/script/qscriptengine.cpp +++ b/src/script/qscriptengine.cpp @@ -330,10 +330,6 @@ QScriptEngine::~QScriptEngine() Q_D(QScriptEngine); d->m_frameRepository.release(currentContext()); d->objectAllocator.destruct(); -#ifdef QT_NO_QOBJECT - delete d_ptr; - d_ptr = 0; -#endif } /*! @@ -1778,7 +1774,7 @@ QScriptValue QScriptEngine::objectById(qint64 id) const Constructs a new QScriptSyntaxCheckResult from the \a other result. */ QScriptSyntaxCheckResult::QScriptSyntaxCheckResult(const QScriptSyntaxCheckResult &other) - : d_ptr(other.d_ptr) + : d_ptr(other.d_ptr.data()) { if (d_ptr) d_ptr->ref.ref(); @@ -1807,10 +1803,6 @@ QScriptSyntaxCheckResult::QScriptSyntaxCheckResult() */ QScriptSyntaxCheckResult::~QScriptSyntaxCheckResult() { - if (d_ptr && !d_ptr->ref.deref()) { - delete d_ptr; - d_ptr = 0; - } } /*! @@ -1864,15 +1856,7 @@ QString QScriptSyntaxCheckResult::errorMessage() const */ QScriptSyntaxCheckResult &QScriptSyntaxCheckResult::operator=(const QScriptSyntaxCheckResult &other) { - if (d_ptr == other.d_ptr) - return *this; - if (d_ptr && !d_ptr->ref.deref()) { - delete d_ptr; - d_ptr = 0; - } - d_ptr = other.d_ptr; - if (d_ptr) - d_ptr->ref.ref(); + d_ptr.assign(other.d_ptr.data()); return *this; } diff --git a/src/script/qscriptengine.h b/src/script/qscriptengine.h index 91e076f..794c965 100644 --- a/src/script/qscriptengine.h +++ b/src/script/qscriptengine.h @@ -47,6 +47,7 @@ #ifndef QT_NO_SCRIPT #include <QtCore/qvariant.h> +#include <QtCore/qscopedpointer.h> #ifndef QT_NO_QOBJECT #include <QtCore/qobject.h> @@ -114,7 +115,7 @@ public: private: QScriptSyntaxCheckResult(); QScriptSyntaxCheckResult(QScriptSyntaxCheckResultPrivate *d); - QScriptSyntaxCheckResultPrivate *d_ptr; + QScopedSharedPointer<QScriptSyntaxCheckResultPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptSyntaxCheckResult) friend class QScriptEnginePrivate; @@ -282,7 +283,7 @@ private: protected: #ifdef QT_NO_QOBJECT - QScriptEnginePrivate *d_ptr; + QScopedPointer<QScriptEnginePrivate> d_ptr; QScriptEngine(QScriptEnginePrivate &dd); #else diff --git a/src/script/qscriptengine_p.cpp b/src/script/qscriptengine_p.cpp index ffb5a27..4ac4403 100644 --- a/src/script/qscriptengine_p.cpp +++ b/src/script/qscriptengine_p.cpp @@ -1711,6 +1711,8 @@ QScriptEnginePrivate::QScriptEnginePrivate() m_maxCallDepth = 640; #elif defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) m_maxCallDepth = 360; +#elif defined(Q_OS_SYMBIAN) + m_maxCallDepth = 128; //stack size limitation of 80k, has headroom for other stack vars. #else m_maxCallDepth = 512; #endif diff --git a/src/script/qscriptengineagent.cpp b/src/script/qscriptengineagent.cpp index 38178f7..68c0a41 100644 --- a/src/script/qscriptengineagent.cpp +++ b/src/script/qscriptengineagent.cpp @@ -173,8 +173,6 @@ QScriptEngineAgent::QScriptEngineAgent(QScriptEngineAgentPrivate &dd, QScriptEng */ QScriptEngineAgent::~QScriptEngineAgent() { - delete d_ptr; - d_ptr = 0; } /*! diff --git a/src/script/qscriptengineagent.h b/src/script/qscriptengineagent.h index 7b3c30d..e71560c 100644 --- a/src/script/qscriptengineagent.h +++ b/src/script/qscriptengineagent.h @@ -47,6 +47,7 @@ #ifndef QT_NO_SCRIPT #include <QtCore/qvariant.h> +#include <QtCore/qscopedpointer.h> QT_BEGIN_HEADER @@ -96,7 +97,7 @@ public: protected: QScriptEngineAgent(QScriptEngineAgentPrivate &dd, QScriptEngine *engine); - QScriptEngineAgentPrivate *d_ptr; + QScopedPointer<QScriptEngineAgentPrivate> d_ptr; private: Q_DECLARE_PRIVATE(QScriptEngineAgent) diff --git a/src/script/qscriptstring.cpp b/src/script/qscriptstring.cpp index 23ba729..137c6d0 100644 --- a/src/script/qscriptstring.cpp +++ b/src/script/qscriptstring.cpp @@ -54,6 +54,29 @@ QT_BEGIN_NAMESPACE +/*! \internal */ +struct QScriptStringPrivatePointerHandler +{ + static inline void cleanup(QScriptStringPrivate *d) + { + if (!d || d->ref.deref()) + return; + + if (d->nameId) { + d->engine->uninternString(d); + } else { + // the engine has already been deleted + delete d; + } + } + + static inline void reset(QScriptStringPrivate *&d, QScriptStringPrivate *other) + { + cleanup(d); + d = other; + } +}; + /*! \since 4.4 \class QScriptString @@ -108,8 +131,8 @@ QScriptStringPrivate *QScriptStringPrivate::get(const QScriptString &q) void QScriptStringPrivate::init(QScriptString &q, QScriptStringPrivate *d) { Q_ASSERT(q.d_ptr == 0); - q.d_ptr = d; - q.d_ptr->ref.ref(); + q.d_ptr.data_ptr() = d; + d->ref.ref(); } /*! @@ -124,7 +147,7 @@ QScriptString::QScriptString() Constructs a new QScriptString that is a copy of \a other. */ QScriptString::QScriptString(const QScriptString &other) - : d_ptr(other.d_ptr) + : d_ptr(other.d_ptr.data()) { if (d_ptr) d_ptr->ref.ref(); @@ -135,15 +158,6 @@ QScriptString::QScriptString(const QScriptString &other) */ QScriptString::~QScriptString() { - if (d_ptr && !d_ptr->ref.deref()) { - if (isValid()) { - d_ptr->engine->uninternString(d_ptr); - } else { - // the engine has already been deleted - delete d_ptr; - } - d_ptr = 0; - } } /*! @@ -153,15 +167,7 @@ QScriptString &QScriptString::operator=(const QScriptString &other) { if (d_ptr == other.d_ptr) return *this; - if (d_ptr && !d_ptr->ref.deref()) { - if (isValid()) { - d_ptr->engine->uninternString(d_ptr); - } else { - // the engine has already been deleted - delete d_ptr; - } - } - d_ptr = other.d_ptr; + d_ptr.reset(other.d_ptr.data()); if (d_ptr) d_ptr->ref.ref(); return *this; diff --git a/src/script/qscriptstring.h b/src/script/qscriptstring.h index db4d59a..7256ee9 100644 --- a/src/script/qscriptstring.h +++ b/src/script/qscriptstring.h @@ -46,6 +46,8 @@ #ifndef QT_NO_SCRIPT +#include <QtCore/qscopedpointer.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -54,6 +56,7 @@ QT_MODULE(Script) class QScriptEngine; class QScriptStringPrivate; +struct QScriptStringPrivatePointerHandler; class Q_SCRIPT_EXPORT QScriptString { @@ -73,7 +76,7 @@ public: operator QString() const; private: - QScriptStringPrivate *d_ptr; + QScopedCustomPointer<QScriptStringPrivate, QScriptStringPrivatePointerHandler> d_ptr; Q_DECLARE_PRIVATE(QScriptString) }; diff --git a/src/script/qscriptvalue.cpp b/src/script/qscriptvalue.cpp index 97ce61a..d99e912 100644 --- a/src/script/qscriptvalue.cpp +++ b/src/script/qscriptvalue.cpp @@ -57,6 +57,28 @@ QT_BEGIN_NAMESPACE +/*! \internal + */ +struct QScriptValuePrivatePointerHandler +{ + static inline void cleanup(QScriptValuePrivate *d) + { + if (!d || d->ref.deref()) + return; + if (d->engine) { + QScriptEnginePrivate::get(d->engine)->unregisterValue(d); + } else { + delete d; + } + } + + static inline void reset(QScriptValuePrivate *&d, QScriptValuePrivate *other) + { + cleanup(d); + d = other; + } +}; + /*! \since 4.3 \class QScriptValue @@ -194,14 +216,6 @@ QScriptValue::QScriptValue() */ QScriptValue::~QScriptValue() { - if (d_ptr && !d_ptr->ref.deref()) { - if (engine()) { - QScriptEnginePrivate::get(engine())->unregisterValue(d_ptr); - } else { - delete d_ptr; - } - d_ptr = 0; - } } /*! @@ -212,7 +226,7 @@ QScriptValue::~QScriptValue() the new script value (i.e., the object itself is not copied). */ QScriptValue::QScriptValue(const QScriptValue &other) - : d_ptr(other.d_ptr) + : d_ptr(other.d_ptr.data()) { if (d_ptr) d_ptr->ref.ref(); @@ -225,13 +239,12 @@ QScriptValue::QScriptValue(const QScriptValue &other) registers it with the script \a engine. */ QScriptValue::QScriptValue(QScriptEngine *engine, QScriptValue::SpecialValue value) + : d_ptr(0) { if (engine) { QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); - d_ptr = eng_p->registerValue(QScriptValueImpl(value)); + d_ptr.data_ptr() = eng_p->registerValue(QScriptValueImpl(value)); d_ptr->ref.ref(); - } else { - d_ptr = 0; } } @@ -244,13 +257,12 @@ QScriptValue::QScriptValue(QScriptEngine *engine, QScriptValue::SpecialValue val registers it with the script \a engine. */ QScriptValue::QScriptValue(QScriptEngine *engine, bool val) + : d_ptr(0) { if (engine) { QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); - d_ptr = eng_p->registerValue(QScriptValueImpl(val)); + d_ptr.data_ptr() = eng_p->registerValue(QScriptValueImpl(val)); d_ptr->ref.ref(); - } else { - d_ptr = 0; } } @@ -262,13 +274,12 @@ QScriptValue::QScriptValue(QScriptEngine *engine, bool val) registers it with the script \a engine. */ QScriptValue::QScriptValue(QScriptEngine *engine, int val) + : d_ptr(0) { if (engine) { QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); - d_ptr = eng_p->registerValue(QScriptValueImpl(val)); + d_ptr.data_ptr() = eng_p->registerValue(QScriptValueImpl(val)); d_ptr->ref.ref(); - } else { - d_ptr = 0; } } @@ -280,13 +291,12 @@ QScriptValue::QScriptValue(QScriptEngine *engine, int val) registers it with the script \a engine. */ QScriptValue::QScriptValue(QScriptEngine *engine, uint val) + : d_ptr(0) { if (engine) { QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); - d_ptr = eng_p->registerValue(QScriptValueImpl(val)); + d_ptr.data_ptr() = eng_p->registerValue(QScriptValueImpl(val)); d_ptr->ref.ref(); - } else { - d_ptr = 0; } } @@ -298,13 +308,12 @@ QScriptValue::QScriptValue(QScriptEngine *engine, uint val) registers it with the script \a engine. */ QScriptValue::QScriptValue(QScriptEngine *engine, qsreal val) + : d_ptr(0) { if (engine) { QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); - d_ptr = eng_p->registerValue(QScriptValueImpl(val)); + d_ptr.data_ptr() = eng_p->registerValue(QScriptValueImpl(val)); d_ptr->ref.ref(); - } else { - d_ptr = 0; } } @@ -316,15 +325,14 @@ QScriptValue::QScriptValue(QScriptEngine *engine, qsreal val) registers it with the script \a engine. */ QScriptValue::QScriptValue(QScriptEngine *engine, const QString &val) + : d_ptr(0) { if (engine) { QScriptValueImpl v; QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); eng_p->newString(&v, val); - d_ptr = eng_p->registerValue(v); + d_ptr.data_ptr() = eng_p->registerValue(v); d_ptr->ref.ref(); - } else { - d_ptr = 0; } } @@ -338,15 +346,14 @@ QScriptValue::QScriptValue(QScriptEngine *engine, const QString &val) #ifndef QT_NO_CAST_FROM_ASCII QScriptValue::QScriptValue(QScriptEngine *engine, const char *val) + : d_ptr(0) { if (engine) { QScriptValueImpl v; QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); eng_p->newString(&v, QString::fromAscii(val)); - d_ptr = eng_p->registerValue(v); + d_ptr.data_ptr() = eng_p->registerValue(v); d_ptr->ref.ref(); - } else { - d_ptr = 0; } } #endif @@ -464,14 +471,7 @@ QScriptValue &QScriptValue::operator=(const QScriptValue &other) { if (d_ptr == other.d_ptr) return *this; - if (d_ptr && !d_ptr->ref.deref()) { - if (engine()) { - QScriptEnginePrivate::get(engine())->unregisterValue(d_ptr); - } else { - delete d_ptr; - } - } - d_ptr = other.d_ptr; + d_ptr.reset(other.d_ptr.data()); if (d_ptr) d_ptr->ref.ref(); return *this; diff --git a/src/script/qscriptvalue.h b/src/script/qscriptvalue.h index 15a11e3..8125d01 100644 --- a/src/script/qscriptvalue.h +++ b/src/script/qscriptvalue.h @@ -47,6 +47,7 @@ #ifndef QT_NO_SCRIPT #include <QtCore/qlist.h> +#include <QtCore/qscopedpointer.h> QT_BEGIN_HEADER @@ -71,6 +72,7 @@ typedef QList<QScriptValue> QScriptValueList; typedef double qsreal; class QScriptValuePrivate; +struct QScriptValuePrivatePointerHandler; class Q_SCRIPT_EXPORT QScriptValue { public: @@ -216,12 +218,12 @@ public: private: // force compile error, prevent QScriptValue(bool) to be called - inline QScriptValue(void *) { Q_ASSERT(false); } + inline QScriptValue(void *); // force compile error, prevent QScriptValue(QScriptEngine*, bool) to be called - inline QScriptValue(QScriptEngine *, void *) { Q_ASSERT(false); } + inline QScriptValue(QScriptEngine *, void *); private: - QScriptValuePrivate *d_ptr; + QScopedCustomPointer<QScriptValuePrivate, QScriptValuePrivatePointerHandler> d_ptr; Q_DECLARE_PRIVATE(QScriptValue) }; diff --git a/src/script/qscriptvalue_p.h b/src/script/qscriptvalue_p.h index 20adb29..ce9959b 100644 --- a/src/script/qscriptvalue_p.h +++ b/src/script/qscriptvalue_p.h @@ -91,7 +91,7 @@ inline QScriptValueImpl QScriptValuePrivate::valueOf(const QScriptValue &value) inline void QScriptValuePrivate::init(QScriptValue &value, QScriptValuePrivate *p) { - value.d_ptr = p; + value.d_ptr.data_ptr() = p; value.d_ptr->ref.ref(); } diff --git a/src/script/qscriptvalueimplfwd_p.h b/src/script/qscriptvalueimplfwd_p.h index c30b32a..5a98bf0 100644 --- a/src/script/qscriptvalueimplfwd_p.h +++ b/src/script/qscriptvalueimplfwd_p.h @@ -88,6 +88,17 @@ public: StringTypeHint }; + QScript::Type m_type; + union { + bool m_bool_value; + int m_int_value; + qsreal m_number_value; + void *m_ptr_value; + QScriptObject *m_object_value; + QScriptNameIdImpl *m_string_value; + QString *m_lazy_string_value; + }; + inline QScriptValueImpl(); inline QScriptValueImpl(QScriptValue::SpecialValue val); inline QScriptValueImpl(bool val); @@ -218,16 +229,6 @@ public: bool detectedCycle() const; - QScript::Type m_type; - union { - bool m_bool_value; - int m_int_value; - qsreal m_number_value; - void *m_ptr_value; - QScriptObject *m_object_value; - QScriptNameIdImpl *m_string_value; - QString *m_lazy_string_value; - }; }; QT_END_NAMESPACE diff --git a/src/script/qscriptvalueiterator.cpp b/src/script/qscriptvalueiterator.cpp index 359a849..6f83d5c 100644 --- a/src/script/qscriptvalueiterator.cpp +++ b/src/script/qscriptvalueiterator.cpp @@ -115,12 +115,11 @@ QScriptValueIteratorPrivate::~QScriptValueIteratorPrivate() first property). */ QScriptValueIterator::QScriptValueIterator(const QScriptValue &object) + : d_ptr(0) { QScriptValueImpl val = QScriptValuePrivate::valueOf(object); - if (!val.isObject()) { - d_ptr = 0; - } else { - d_ptr = new QScriptValueIteratorPrivate(); + if (val.isObject()) { + d_ptr.reset(new QScriptValueIteratorPrivate()); d_ptr->it = new QScriptValueIteratorImpl(val); } } @@ -130,10 +129,6 @@ QScriptValueIterator::QScriptValueIterator(const QScriptValue &object) */ QScriptValueIterator::~QScriptValueIterator() { - if (d_ptr) { - delete d_ptr; - d_ptr = 0; - } } /*! @@ -311,13 +306,10 @@ void QScriptValueIterator::remove() */ QScriptValueIterator& QScriptValueIterator::operator=(QScriptValue &object) { - if (d_ptr) { - delete d_ptr; - d_ptr = 0; - } + d_ptr.reset(); QScriptValueImpl val = QScriptValuePrivate::valueOf(object); if (val.isObject()) { - d_ptr = new QScriptValueIteratorPrivate(); + d_ptr.reset(new QScriptValueIteratorPrivate()); d_ptr->it = new QScriptValueIteratorImpl(val); } return *this; diff --git a/src/script/qscriptvalueiterator.h b/src/script/qscriptvalueiterator.h index 2242c68..c8684ea 100644 --- a/src/script/qscriptvalueiterator.h +++ b/src/script/qscriptvalueiterator.h @@ -46,6 +46,8 @@ #ifndef QT_NO_SCRIPT +#include <QtCore/qscopedpointer.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -84,7 +86,7 @@ public: QScriptValueIterator& operator=(QScriptValue &value); private: - QScriptValueIteratorPrivate *d_ptr; + QScopedPointer<QScriptValueIteratorPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptValueIterator) Q_DISABLE_COPY(QScriptValueIterator) diff --git a/src/script/script.pro b/src/script/script.pro index 9aa9bc2..4792527 100644 --- a/src/script/script.pro +++ b/src/script/script.pro @@ -10,3 +10,5 @@ unix:QMAKE_PKGCONFIG_REQUIRES = QtCore include(../qbase.pri) include(script.pri) + +symbian:TARGET.UID3=0x2001B2E1 |