X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fdeclarative%2Fqml%2Fqdeclarativecleanup.cpp;h=aa7a1e32545653004378497f0d3c8b96152795bc;hb=45b14259fc0cf704692df1c00da511527d1fba1d;hp=db671a392a54ec0cc96e69c34757c772dd7deda3;hpb=7cf421d04d19441a6e17ab9460dc4560374a5bcc;p=profile%2Fivi%2Fqtdeclarative.git diff --git a/src/declarative/qml/qdeclarativecleanup.cpp b/src/declarative/qml/qdeclarativecleanup.cpp index db671a3..aa7a1e3 100644 --- a/src/declarative/qml/qdeclarativecleanup.cpp +++ b/src/declarative/qml/qdeclarativecleanup.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ ** ** This file is part of the QtDeclarative module of the Qt Toolkit. ** @@ -35,13 +34,14 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "private/qdeclarativecleanup_p.h" +#include "qdeclarativecleanup_p.h" -#include "private/qdeclarativeengine_p.h" +#include "qdeclarativeengine_p.h" QT_BEGIN_NAMESPACE @@ -50,22 +50,43 @@ QT_BEGIN_NAMESPACE \class QDeclarativeCleanup \brief The QDeclarativeCleanup provides a callback when a QDeclarativeEngine is deleted. -Any object that needs cleanup to occur before the QDeclarativeEngine's QScriptEngine is +Any object that needs cleanup to occur before the QDeclarativeEngine's V8 engine is destroyed should inherit from QDeclarativeCleanup. The clear() virtual method will be -called by QDeclarativeEngine just before it deletes the QScriptEngine. +called by QDeclarativeEngine just before it destroys the context. */ -/*! -\internal +/* +Create a QDeclarativeCleanup that is not associated with any engine. +*/ +QDeclarativeCleanup::QDeclarativeCleanup() +: prev(0), next(0), engine(0) +{ +} + +/*! Create a QDeclarativeCleanup for \a engine */ QDeclarativeCleanup::QDeclarativeCleanup(QDeclarativeEngine *engine) -: prev(0), next(0) +: prev(0), next(0), engine(0) { if (!engine) return; + addToEngine(engine); +} + +/*! +Adds this object to \a engine's cleanup list. hasEngine() must be false +before calling this method. +*/ +void QDeclarativeCleanup::addToEngine(QDeclarativeEngine *engine) +{ + Q_ASSERT(engine); + Q_ASSERT(QDeclarativeEnginePrivate::isEngineThread(engine)); + + this->engine = engine; + QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine); if (p->cleanup) next = p->cleanup; @@ -75,13 +96,23 @@ QDeclarativeCleanup::QDeclarativeCleanup(QDeclarativeEngine *engine) } /*! +\fn bool QDeclarativeCleanup::hasEngine() const + +Returns true if this QDeclarativeCleanup is associated with an engine, otherwise false. +*/ + +/*! \internal */ QDeclarativeCleanup::~QDeclarativeCleanup() { + Q_ASSERT(!prev || engine); + Q_ASSERT(!prev || QDeclarativeEnginePrivate::isEngineThread(engine)); + if (prev) *prev = next; if (next) next->prev = prev; prev = 0; next = 0; } + QT_END_NAMESPACE