diff options
Diffstat (limited to 'src/scripttools/debugging')
34 files changed, 56 insertions, 110 deletions
diff --git a/src/scripttools/debugging/qscriptbreakpointdata.cpp b/src/scripttools/debugging/qscriptbreakpointdata.cpp index 9762ca4..50e597e 100644 --- a/src/scripttools/debugging/qscriptbreakpointdata.cpp +++ b/src/scripttools/debugging/qscriptbreakpointdata.cpp @@ -136,7 +136,6 @@ QScriptBreakpointData::QScriptBreakpointData(const QScriptBreakpointData &other) */ QScriptBreakpointData::~QScriptBreakpointData() { - delete d_ptr; } /*! @@ -355,7 +354,7 @@ bool QScriptBreakpointData::operator!=(const QScriptBreakpointData &other) const */ QDataStream &operator<<(QDataStream &out, const QScriptBreakpointData &data) { - const QScriptBreakpointDataPrivate *d = data.d_ptr; + const QScriptBreakpointDataPrivate *d = data.d_ptr.data(); out << d->scriptId; out << d->fileName; out << d->lineNumber; @@ -377,7 +376,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptBreakpointData &data) */ QDataStream &operator>>(QDataStream &in, QScriptBreakpointData &data) { - QScriptBreakpointDataPrivate *d = data.d_ptr; + QScriptBreakpointDataPrivate *d = data.d_ptr.data(); in >> d->scriptId; in >> d->fileName; in >> d->lineNumber; diff --git a/src/scripttools/debugging/qscriptbreakpointdata_p.h b/src/scripttools/debugging/qscriptbreakpointdata_p.h index c1ff033..6cfceed 100644 --- a/src/scripttools/debugging/qscriptbreakpointdata_p.h +++ b/src/scripttools/debugging/qscriptbreakpointdata_p.h @@ -54,7 +54,7 @@ // #include <QtCore/qobjectdefs.h> - +#include <QtCore/qscopedpointer.h> #include <QtCore/qmap.h> QT_BEGIN_NAMESPACE @@ -114,7 +114,7 @@ public: bool operator!=(const QScriptBreakpointData &other) const; private: - QScriptBreakpointDataPrivate *d_ptr; + QScopedPointer<QScriptBreakpointDataPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptBreakpointData) }; diff --git a/src/scripttools/debugging/qscriptdebuggerbackend.cpp b/src/scripttools/debugging/qscriptdebuggerbackend.cpp index 3c29130..46d8497 100644 --- a/src/scripttools/debugging/qscriptdebuggerbackend.cpp +++ b/src/scripttools/debugging/qscriptdebuggerbackend.cpp @@ -385,7 +385,6 @@ QScriptDebuggerBackend::QScriptDebuggerBackend() QScriptDebuggerBackend::~QScriptDebuggerBackend() { detach(); - delete d_ptr; } /*! diff --git a/src/scripttools/debugging/qscriptdebuggerbackend_p.h b/src/scripttools/debugging/qscriptdebuggerbackend_p.h index 6d593a6..d9ec307 100644 --- a/src/scripttools/debugging/qscriptdebuggerbackend_p.h +++ b/src/scripttools/debugging/qscriptdebuggerbackend_p.h @@ -144,7 +144,7 @@ protected: protected: QScriptDebuggerBackend(QScriptDebuggerBackendPrivate &dd); - QScriptDebuggerBackendPrivate *d_ptr; + QScopedPointer<QScriptDebuggerBackendPrivate> d_ptr; private: Q_DECLARE_PRIVATE(QScriptDebuggerBackend) diff --git a/src/scripttools/debugging/qscriptdebuggercommand.cpp b/src/scripttools/debugging/qscriptdebuggercommand.cpp index c40bfc4..98bb3b3 100644 --- a/src/scripttools/debugging/qscriptdebuggercommand.cpp +++ b/src/scripttools/debugging/qscriptdebuggercommand.cpp @@ -118,7 +118,6 @@ QScriptDebuggerCommand::QScriptDebuggerCommand(const QScriptDebuggerCommand &oth */ QScriptDebuggerCommand::~QScriptDebuggerCommand() { - delete d_ptr; } /*! @@ -646,7 +645,7 @@ QScriptDebuggerCommand QScriptDebuggerCommand::clearExceptionsCommand() */ QDataStream &operator<<(QDataStream &out, const QScriptDebuggerCommand &command) { - const QScriptDebuggerCommandPrivate *d = command.d_ptr; + const QScriptDebuggerCommandPrivate *d = command.d_ptr.data(); out << (quint32)d->type; out << (qint32)d->attributes.size(); QHash<QScriptDebuggerCommand::Attribute, QVariant>::const_iterator it; @@ -666,7 +665,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptDebuggerCommand &command) */ QDataStream &operator>>(QDataStream &in, QScriptDebuggerCommand &command) { - QScriptDebuggerCommandPrivate *d = command.d_ptr; + QScriptDebuggerCommandPrivate *d = command.d_ptr.data(); quint32 type; in >> type; diff --git a/src/scripttools/debugging/qscriptdebuggercommand_p.h b/src/scripttools/debugging/qscriptdebuggercommand_p.h index 260e3ec..363738f 100644 --- a/src/scripttools/debugging/qscriptdebuggercommand_p.h +++ b/src/scripttools/debugging/qscriptdebuggercommand_p.h @@ -54,7 +54,7 @@ // #include <QtCore/qobjectdefs.h> - +#include <QtCore/qscopedpointer.h> #include <QtCore/qhash.h> #include <QtCore/qvariant.h> @@ -250,7 +250,7 @@ public: static QScriptDebuggerCommand clearExceptionsCommand(); private: - QScriptDebuggerCommandPrivate *d_ptr; + QScopedPointer<QScriptDebuggerCommandPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptDebuggerCommand) }; diff --git a/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp b/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp index 1be8c5f..e75ff99 100644 --- a/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp +++ b/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp @@ -98,7 +98,6 @@ QScriptDebuggerCommandExecutor::QScriptDebuggerCommandExecutor() QScriptDebuggerCommandExecutor::~QScriptDebuggerCommandExecutor() { - delete d_ptr; } /*! diff --git a/src/scripttools/debugging/qscriptdebuggercommandexecutor_p.h b/src/scripttools/debugging/qscriptdebuggercommandexecutor_p.h index 8fff5e5..da7de76 100644 --- a/src/scripttools/debugging/qscriptdebuggercommandexecutor_p.h +++ b/src/scripttools/debugging/qscriptdebuggercommandexecutor_p.h @@ -54,6 +54,7 @@ // #include <QtCore/qobjectdefs.h> +#include <QtCore/qscopedpointer.h> QT_BEGIN_NAMESPACE @@ -74,7 +75,7 @@ public: protected: QScriptDebuggerCommandExecutor(QScriptDebuggerCommandExecutorPrivate &dd); - QScriptDebuggerCommandExecutorPrivate *d_ptr; + QScopedPointer<QScriptDebuggerCommandExecutorPrivate> d_ptr; private: Q_DECLARE_PRIVATE(QScriptDebuggerCommandExecutor) diff --git a/src/scripttools/debugging/qscriptdebuggerconsole.cpp b/src/scripttools/debugging/qscriptdebuggerconsole.cpp index 70bb8b1..09a32db 100644 --- a/src/scripttools/debugging/qscriptdebuggerconsole.cpp +++ b/src/scripttools/debugging/qscriptdebuggerconsole.cpp @@ -199,7 +199,6 @@ QScriptDebuggerConsole::QScriptDebuggerConsole() QScriptDebuggerConsole::~QScriptDebuggerConsole() { - delete d_ptr; } void QScriptDebuggerConsole::loadScriptedCommands(const QString &scriptsPath, diff --git a/src/scripttools/debugging/qscriptdebuggerconsole_p.h b/src/scripttools/debugging/qscriptdebuggerconsole_p.h index b5ebf44..a8c4163 100644 --- a/src/scripttools/debugging/qscriptdebuggerconsole_p.h +++ b/src/scripttools/debugging/qscriptdebuggerconsole_p.h @@ -54,6 +54,7 @@ // #include <QtCore/qobjectdefs.h> +#include <QtCore/qscopedpointer.h> #include "qscriptdebuggerconsolehistorianinterface_p.h" @@ -109,7 +110,7 @@ public: void bumpSessionId(); private: - QScriptDebuggerConsolePrivate *d_ptr; + QScopedPointer<QScriptDebuggerConsolePrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptDebuggerConsole) Q_DISABLE_COPY(QScriptDebuggerConsole) diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommand.cpp b/src/scripttools/debugging/qscriptdebuggerconsolecommand.cpp index 6cbf58c..8e4bc06 100644 --- a/src/scripttools/debugging/qscriptdebuggerconsolecommand.cpp +++ b/src/scripttools/debugging/qscriptdebuggerconsolecommand.cpp @@ -72,7 +72,6 @@ QScriptDebuggerConsoleCommand::QScriptDebuggerConsoleCommand() QScriptDebuggerConsoleCommand::~QScriptDebuggerConsoleCommand() { - delete d_ptr; } QScriptDebuggerConsoleCommand::QScriptDebuggerConsoleCommand(QScriptDebuggerConsoleCommandPrivate &dd) diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommand_p.h b/src/scripttools/debugging/qscriptdebuggerconsolecommand_p.h index fbf285f..2ce3315 100644 --- a/src/scripttools/debugging/qscriptdebuggerconsolecommand_p.h +++ b/src/scripttools/debugging/qscriptdebuggerconsolecommand_p.h @@ -54,7 +54,7 @@ // #include <QtCore/qobjectdefs.h> - +#include <QtCore/qscopedpointer.h> #include <QtCore/qlist.h> QT_BEGIN_NAMESPACE @@ -91,7 +91,7 @@ public: protected: QScriptDebuggerConsoleCommand(QScriptDebuggerConsoleCommandPrivate &dd); - QScriptDebuggerConsoleCommandPrivate *d_ptr; + QScopedPointer<QScriptDebuggerConsoleCommandPrivate> d_ptr; private: Q_DECLARE_PRIVATE(QScriptDebuggerConsoleCommand) diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata.cpp b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata.cpp index 9cfac97..1d43dd0 100644 --- a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata.cpp +++ b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata.cpp @@ -90,7 +90,7 @@ QScriptDebuggerConsoleCommandGroupData::QScriptDebuggerConsoleCommandGroupData( QScriptDebuggerConsoleCommandGroupData::QScriptDebuggerConsoleCommandGroupData( const QScriptDebuggerConsoleCommandGroupData &other) - : d_ptr(other.d_ptr) + : d_ptr(other.d_ptr.data()) { if (d_ptr) d_ptr->ref.ref(); @@ -98,22 +98,12 @@ QScriptDebuggerConsoleCommandGroupData::QScriptDebuggerConsoleCommandGroupData( QScriptDebuggerConsoleCommandGroupData::~QScriptDebuggerConsoleCommandGroupData() { - if (d_ptr && !d_ptr->ref.deref()) { - delete d_ptr; - d_ptr = 0; - } } QScriptDebuggerConsoleCommandGroupData &QScriptDebuggerConsoleCommandGroupData::operator=( const QScriptDebuggerConsoleCommandGroupData &other) { - if (d_ptr == other.d_ptr) - return *this; - if (d_ptr && !d_ptr->ref.deref()) - delete d_ptr; - 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/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h index c32277f..9b0e281 100644 --- a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h +++ b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h @@ -54,7 +54,7 @@ // #include <QtCore/qobjectdefs.h> - +#include <QtCore/qscopedpointer.h> #include <QtCore/qmap.h> QT_BEGIN_NAMESPACE @@ -82,7 +82,7 @@ public: const QScriptDebuggerConsoleCommandGroupData &other); private: - QScriptDebuggerConsoleCommandGroupDataPrivate *d_ptr; + QScopedSharedPointer<QScriptDebuggerConsoleCommandGroupDataPrivate> d_ptr; private: Q_DECLARE_PRIVATE(QScriptDebuggerConsoleCommandGroupData) diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager.cpp b/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager.cpp index ef9687e..f22efc5 100644 --- a/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager.cpp +++ b/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager.cpp @@ -105,7 +105,6 @@ QScriptDebuggerConsoleCommandManager::QScriptDebuggerConsoleCommandManager() QScriptDebuggerConsoleCommandManager::~QScriptDebuggerConsoleCommandManager() { - delete d_ptr; } /*! diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager_p.h b/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager_p.h index b5c9842..cebb999 100644 --- a/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager_p.h +++ b/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager_p.h @@ -54,7 +54,7 @@ // #include <QtCore/qobjectdefs.h> - +#include <QtCore/qscopedpointer.h> #include <QtCore/qmap.h> #include <QtCore/qlist.h> @@ -86,7 +86,7 @@ public: QStringList completions(const QString &prefix) const; private: - QScriptDebuggerConsoleCommandManagerPrivate *d_ptr; + QScopedPointer<QScriptDebuggerConsoleCommandManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptDebuggerConsoleCommandManager) }; diff --git a/src/scripttools/debugging/qscriptdebuggerevent.cpp b/src/scripttools/debugging/qscriptdebuggerevent.cpp index 9d971a9..418e8fa 100644 --- a/src/scripttools/debugging/qscriptdebuggerevent.cpp +++ b/src/scripttools/debugging/qscriptdebuggerevent.cpp @@ -97,7 +97,6 @@ QScriptDebuggerEvent::QScriptDebuggerEvent(const QScriptDebuggerEvent &other) QScriptDebuggerEvent::~QScriptDebuggerEvent() { - delete d_ptr; } QScriptDebuggerEvent &QScriptDebuggerEvent::operator=(const QScriptDebuggerEvent &other) @@ -276,7 +275,7 @@ bool QScriptDebuggerEvent::operator!=(const QScriptDebuggerEvent &other) const */ QDataStream &operator<<(QDataStream &out, const QScriptDebuggerEvent &event) { - const QScriptDebuggerEventPrivate *d = event.d_ptr; + const QScriptDebuggerEventPrivate *d = event.d_ptr.data(); out << (quint32)d->type; out << (qint32)d->attributes.size(); QHash<QScriptDebuggerEvent::Attribute, QVariant>::const_iterator it; @@ -296,7 +295,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptDebuggerEvent &event) */ QDataStream &operator>>(QDataStream &in, QScriptDebuggerEvent &event) { - QScriptDebuggerEventPrivate *d = event.d_ptr; + QScriptDebuggerEventPrivate *d = event.d_ptr.data(); quint32 type; in >> type; diff --git a/src/scripttools/debugging/qscriptdebuggerevent_p.h b/src/scripttools/debugging/qscriptdebuggerevent_p.h index d9c073c..0cfde4f 100644 --- a/src/scripttools/debugging/qscriptdebuggerevent_p.h +++ b/src/scripttools/debugging/qscriptdebuggerevent_p.h @@ -57,6 +57,7 @@ #include <QtCore/qcoreevent.h> #include <QtCore/qhash.h> #include <QtCore/qvariant.h> +#include <QtCore/qscopedpointer.h> QT_BEGIN_NAMESPACE @@ -137,7 +138,7 @@ public: bool operator!=(const QScriptDebuggerEvent &other) const; private: - QScriptDebuggerEventPrivate *d_ptr; + QScopedPointer<QScriptDebuggerEventPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptDebuggerEvent) }; diff --git a/src/scripttools/debugging/qscriptdebuggerfrontend.cpp b/src/scripttools/debugging/qscriptdebuggerfrontend.cpp index ced20b1..4d0a8b4 100644 --- a/src/scripttools/debugging/qscriptdebuggerfrontend.cpp +++ b/src/scripttools/debugging/qscriptdebuggerfrontend.cpp @@ -143,7 +143,6 @@ QScriptDebuggerFrontend::QScriptDebuggerFrontend() QScriptDebuggerFrontend::~QScriptDebuggerFrontend() { - delete d_ptr; } QScriptDebuggerFrontend::QScriptDebuggerFrontend(QScriptDebuggerFrontendPrivate &dd) diff --git a/src/scripttools/debugging/qscriptdebuggerfrontend_p.h b/src/scripttools/debugging/qscriptdebuggerfrontend_p.h index a763463..bed0f85 100644 --- a/src/scripttools/debugging/qscriptdebuggerfrontend_p.h +++ b/src/scripttools/debugging/qscriptdebuggerfrontend_p.h @@ -54,7 +54,7 @@ // #include <QtCore/qobjectdefs.h> - +#include <QtCore/qscopedpointer.h> #include <QtCore/qstring.h> #include "qscriptdebuggercommandschedulerinterface_p.h" @@ -90,7 +90,7 @@ protected: protected: QScriptDebuggerFrontend(QScriptDebuggerFrontendPrivate &dd); - QScriptDebuggerFrontendPrivate *d_ptr; + QScopedPointer<QScriptDebuggerFrontendPrivate> d_ptr; private: Q_DECLARE_PRIVATE(QScriptDebuggerFrontend) diff --git a/src/scripttools/debugging/qscriptdebuggerjob.cpp b/src/scripttools/debugging/qscriptdebuggerjob.cpp index 109c805..20d17bb 100644 --- a/src/scripttools/debugging/qscriptdebuggerjob.cpp +++ b/src/scripttools/debugging/qscriptdebuggerjob.cpp @@ -85,7 +85,6 @@ QScriptDebuggerJob::QScriptDebuggerJob(QScriptDebuggerJobPrivate &dd) QScriptDebuggerJob::~QScriptDebuggerJob() { - delete d_ptr; } void QScriptDebuggerJob::finish() diff --git a/src/scripttools/debugging/qscriptdebuggerjob_p.h b/src/scripttools/debugging/qscriptdebuggerjob_p.h index e84d6d5..2f7305f 100644 --- a/src/scripttools/debugging/qscriptdebuggerjob_p.h +++ b/src/scripttools/debugging/qscriptdebuggerjob_p.h @@ -54,6 +54,7 @@ // #include <QtCore/qobjectdefs.h> +#include <QtCore/qscopedpointer.h> QT_BEGIN_NAMESPACE @@ -76,7 +77,7 @@ public: protected: QScriptDebuggerJob(QScriptDebuggerJobPrivate &dd); - QScriptDebuggerJobPrivate *d_ptr; + QScopedPointer<QScriptDebuggerJobPrivate> d_ptr; private: Q_DECLARE_PRIVATE(QScriptDebuggerJob) diff --git a/src/scripttools/debugging/qscriptdebuggerresponse.cpp b/src/scripttools/debugging/qscriptdebuggerresponse.cpp index 82bfff2..bf24846 100644 --- a/src/scripttools/debugging/qscriptdebuggerresponse.cpp +++ b/src/scripttools/debugging/qscriptdebuggerresponse.cpp @@ -101,7 +101,6 @@ QScriptDebuggerResponse::QScriptDebuggerResponse(const QScriptDebuggerResponse & QScriptDebuggerResponse::~QScriptDebuggerResponse() { - delete d_ptr; } QScriptDebuggerResponse &QScriptDebuggerResponse::operator=(const QScriptDebuggerResponse &other) @@ -320,7 +319,7 @@ bool QScriptDebuggerResponse::operator!=(const QScriptDebuggerResponse &other) c */ QDataStream &operator<<(QDataStream &out, const QScriptDebuggerResponse &response) { - const QScriptDebuggerResponsePrivate *d = response.d_ptr; + const QScriptDebuggerResponsePrivate *d = response.d_ptr.data(); out << (quint32)d->error; out << d->result; out << d->async; @@ -336,7 +335,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptDebuggerResponse &respons */ QDataStream &operator>>(QDataStream &in, QScriptDebuggerResponse &response) { - QScriptDebuggerResponsePrivate *d = response.d_ptr; + QScriptDebuggerResponsePrivate *d = response.d_ptr.data(); quint32 error; in >> error; diff --git a/src/scripttools/debugging/qscriptdebuggerresponse_p.h b/src/scripttools/debugging/qscriptdebuggerresponse_p.h index dd65ffd..4fa1731 100644 --- a/src/scripttools/debugging/qscriptdebuggerresponse_p.h +++ b/src/scripttools/debugging/qscriptdebuggerresponse_p.h @@ -54,7 +54,7 @@ // #include <QtCore/qobjectdefs.h> - +#include <QtCore/qscopedpointer.h> #include <QtCore/qmap.h> #include <QtCore/qvariant.h> @@ -127,7 +127,7 @@ public: bool operator!=(const QScriptDebuggerResponse &other) const; private: - QScriptDebuggerResponsePrivate *d_ptr; + QScopedPointer<QScriptDebuggerResponsePrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptDebuggerResponse) }; diff --git a/src/scripttools/debugging/qscriptdebuggervalue.cpp b/src/scripttools/debugging/qscriptdebuggervalue.cpp index bb41ee8..b92cbd2 100644 --- a/src/scripttools/debugging/qscriptdebuggervalue.cpp +++ b/src/scripttools/debugging/qscriptdebuggervalue.cpp @@ -94,7 +94,7 @@ QScriptDebuggerValue::QScriptDebuggerValue(const QScriptValue &value) : d_ptr(0) { if (value.isValid()) { - d_ptr = new QScriptDebuggerValuePrivate; + d_ptr.reset(new QScriptDebuggerValuePrivate); if (value.isUndefined()) d_ptr->type = UndefinedValue; else if (value.isNull()) @@ -157,7 +157,7 @@ QScriptDebuggerValue::QScriptDebuggerValue(ValueType type) } QScriptDebuggerValue::QScriptDebuggerValue(const QScriptDebuggerValue &other) - : d_ptr(other.d_ptr) + : d_ptr(other.d_ptr.data()) { if (d_ptr) d_ptr->ref.ref(); @@ -165,21 +165,11 @@ QScriptDebuggerValue::QScriptDebuggerValue(const QScriptDebuggerValue &other) QScriptDebuggerValue::~QScriptDebuggerValue() { - if (d_ptr && !d_ptr->ref.deref()) { - delete d_ptr; - d_ptr = 0; - } } QScriptDebuggerValue &QScriptDebuggerValue::operator=(const QScriptDebuggerValue &other) { - if (d_ptr == other.d_ptr) - return *this; - if (d_ptr && !d_ptr->ref.deref()) - delete d_ptr; - 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/scripttools/debugging/qscriptdebuggervalue_p.h b/src/scripttools/debugging/qscriptdebuggervalue_p.h index 0142de0..c082bf3 100644 --- a/src/scripttools/debugging/qscriptdebuggervalue_p.h +++ b/src/scripttools/debugging/qscriptdebuggervalue_p.h @@ -54,7 +54,7 @@ // #include <QtCore/qobjectdefs.h> - +#include <QtCore/qscopedpointer.h> #include <QtCore/qlist.h> QT_BEGIN_NAMESPACE @@ -103,7 +103,7 @@ public: bool operator!=(const QScriptDebuggerValue &other) const; private: - QScriptDebuggerValuePrivate *d_ptr; + QScopedSharedPointer<QScriptDebuggerValuePrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptDebuggerValue) }; diff --git a/src/scripttools/debugging/qscriptdebuggervalueproperty.cpp b/src/scripttools/debugging/qscriptdebuggervalueproperty.cpp index 723e304..63f820b 100644 --- a/src/scripttools/debugging/qscriptdebuggervalueproperty.cpp +++ b/src/scripttools/debugging/qscriptdebuggervalueproperty.cpp @@ -105,7 +105,7 @@ QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QString &name, Constructs a QScriptDebuggerValueProperty that is a copy of the \a other property. */ QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QScriptDebuggerValueProperty &other) - : d_ptr(other.d_ptr) + : d_ptr(other.d_ptr.data()) { if (d_ptr) d_ptr->ref.ref(); @@ -116,10 +116,6 @@ QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QScriptDebugger */ QScriptDebuggerValueProperty::~QScriptDebuggerValueProperty() { - if (d_ptr && !d_ptr->ref.deref()) { - delete d_ptr; - d_ptr = 0; - } } /*! @@ -127,13 +123,7 @@ QScriptDebuggerValueProperty::~QScriptDebuggerValueProperty() */ QScriptDebuggerValueProperty &QScriptDebuggerValueProperty::operator=(const QScriptDebuggerValueProperty &other) { - if (d_ptr == other.d_ptr) - return *this; - if (d_ptr && !d_ptr->ref.deref()) - delete d_ptr; - 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/scripttools/debugging/qscriptdebuggervalueproperty_p.h b/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h index f67bafd..be27ebd 100644 --- a/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h +++ b/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h @@ -55,6 +55,7 @@ #include <QtCore/qobjectdefs.h> #include <QtCore/qlist.h> +#include <QtCore/qscopedpointer.h> #include <QtScript/qscriptvalue.h> QT_BEGIN_NAMESPACE @@ -85,7 +86,7 @@ public: bool isValid() const; private: - QScriptDebuggerValuePropertyPrivate *d_ptr; + QScopedSharedPointer<QScriptDebuggerValuePropertyPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptDebuggerValueProperty) }; diff --git a/src/scripttools/debugging/qscriptscriptdata.cpp b/src/scripttools/debugging/qscriptscriptdata.cpp index 068748f..a4f8cd7 100644 --- a/src/scripttools/debugging/qscriptscriptdata.cpp +++ b/src/scripttools/debugging/qscriptscriptdata.cpp @@ -98,7 +98,7 @@ QScriptScriptData::QScriptScriptData(const QString &contents, const QString &fil } QScriptScriptData::QScriptScriptData(const QScriptScriptData &other) - : d_ptr(other.d_ptr) + : d_ptr(other.d_ptr.data()) { if (d_ptr) d_ptr->ref.ref(); @@ -106,21 +106,11 @@ QScriptScriptData::QScriptScriptData(const QScriptScriptData &other) QScriptScriptData::~QScriptScriptData() { - if (d_ptr && !d_ptr->ref.deref()) { - delete d_ptr; - d_ptr = 0; - } } QScriptScriptData &QScriptScriptData::operator=(const QScriptScriptData &other) { - if (d_ptr == other.d_ptr) - return *this; - if (d_ptr && !d_ptr->ref.deref()) - delete d_ptr; - d_ptr = other.d_ptr; - if (d_ptr) - d_ptr->ref.ref(); + d_ptr.assign(other.d_ptr.data()); return *this; } @@ -191,7 +181,7 @@ bool QScriptScriptData::operator!=(const QScriptScriptData &other) const QDataStream &operator<<(QDataStream &out, const QScriptScriptData &data) { - const QScriptScriptDataPrivate *d = data.d_ptr; + const QScriptScriptDataPrivate *d = data.d_ptr.data(); if (d) { out << d->contents; out << d->fileName; @@ -207,10 +197,10 @@ QDataStream &operator<<(QDataStream &out, const QScriptScriptData &data) QDataStream &operator>>(QDataStream &in, QScriptScriptData &data) { if (!data.d_ptr) { - data.d_ptr = new QScriptScriptDataPrivate(); + data.d_ptr.reset(new QScriptScriptDataPrivate()); data.d_ptr->ref.ref(); } - QScriptScriptDataPrivate *d = data.d_ptr; + QScriptScriptDataPrivate *d = data.d_ptr.data(); in >> d->contents; in >> d->fileName; qint32 ln; diff --git a/src/scripttools/debugging/qscriptscriptdata_p.h b/src/scripttools/debugging/qscriptscriptdata_p.h index 50cad32..e871c2c 100644 --- a/src/scripttools/debugging/qscriptscriptdata_p.h +++ b/src/scripttools/debugging/qscriptscriptdata_p.h @@ -54,7 +54,7 @@ // #include <QtCore/qobjectdefs.h> - +#include <QtCore/qscopedpointer.h> #include <QtCore/qdatetime.h> #include <QtCore/qmap.h> @@ -91,7 +91,7 @@ public: bool operator!=(const QScriptScriptData &other) const; private: - QScriptScriptDataPrivate *d_ptr; + QScopedSharedPointer<QScriptScriptDataPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptScriptData) }; diff --git a/src/scripttools/debugging/qscriptstdmessagehandler.cpp b/src/scripttools/debugging/qscriptstdmessagehandler.cpp index 4e0f12c..6742554 100644 --- a/src/scripttools/debugging/qscriptstdmessagehandler.cpp +++ b/src/scripttools/debugging/qscriptstdmessagehandler.cpp @@ -66,7 +66,6 @@ QScriptStdMessageHandler::QScriptStdMessageHandler() QScriptStdMessageHandler::~QScriptStdMessageHandler() { - delete d_ptr; } void QScriptStdMessageHandler::message(QtMsgType type, const QString &text, diff --git a/src/scripttools/debugging/qscriptstdmessagehandler_p.h b/src/scripttools/debugging/qscriptstdmessagehandler_p.h index 8b75f6a..06d680b 100644 --- a/src/scripttools/debugging/qscriptstdmessagehandler_p.h +++ b/src/scripttools/debugging/qscriptstdmessagehandler_p.h @@ -53,6 +53,8 @@ // We mean it. // +#include <QtCore/qscopedpointer.h> + #include "qscriptmessagehandlerinterface_p.h" QT_BEGIN_NAMESPACE @@ -71,7 +73,7 @@ public: const QVariant &data = QVariant()); private: - QScriptStdMessageHandlerPrivate *d_ptr; + QScopedPointer<QScriptStdMessageHandlerPrivate> d_ptr; private: Q_DECLARE_PRIVATE(QScriptStdMessageHandler) diff --git a/src/scripttools/debugging/qscriptvalueproperty.cpp b/src/scripttools/debugging/qscriptvalueproperty.cpp index 245edc3..75cfdd7 100644 --- a/src/scripttools/debugging/qscriptvalueproperty.cpp +++ b/src/scripttools/debugging/qscriptvalueproperty.cpp @@ -95,7 +95,7 @@ QScriptValueProperty::QScriptValueProperty(const QString &name, Constructs a QScriptValueProperty that is a copy of the \a other property. */ QScriptValueProperty::QScriptValueProperty(const QScriptValueProperty &other) - : d_ptr(other.d_ptr) + : d_ptr(other.d_ptr.data()) { if (d_ptr) d_ptr->ref.ref(); @@ -106,10 +106,6 @@ QScriptValueProperty::QScriptValueProperty(const QScriptValueProperty &other) */ QScriptValueProperty::~QScriptValueProperty() { - if (d_ptr && !d_ptr->ref.deref()) { - delete d_ptr; - d_ptr = 0; - } } /*! @@ -117,13 +113,7 @@ QScriptValueProperty::~QScriptValueProperty() */ QScriptValueProperty &QScriptValueProperty::operator=(const QScriptValueProperty &other) { - if (d_ptr == other.d_ptr) - return *this; - if (d_ptr && !d_ptr->ref.deref()) - delete d_ptr; - 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/scripttools/debugging/qscriptvalueproperty_p.h b/src/scripttools/debugging/qscriptvalueproperty_p.h index 938ab83..ca6980f 100644 --- a/src/scripttools/debugging/qscriptvalueproperty_p.h +++ b/src/scripttools/debugging/qscriptvalueproperty_p.h @@ -55,6 +55,7 @@ #include <QtCore/qobjectdefs.h> #include <QtCore/qlist.h> +#include <QtCore/qscopedpointer.h> #include <QtScript/qscriptvalue.h> QT_BEGIN_NAMESPACE @@ -81,7 +82,7 @@ public: bool isValid() const; private: - QScriptValuePropertyPrivate *d_ptr; + QScopedSharedPointer<QScriptValuePropertyPrivate> d_ptr; Q_DECLARE_PRIVATE(QScriptValueProperty) }; |