aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8/qv8engine_p.h
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>2012-04-19 14:38:38 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-27 10:38:58 +0200
commitb765e3a84bc531878a5cc0d451451a94565b13f8 (patch)
tree4c506d229c76924a2c72de31464efa8b440f005f /src/qml/qml/v8/qv8engine_p.h
parent7ec674ee9a8e51cb1cb7ef60b1d27845349b8dec (diff)
Avoid calling gc in QQmlEngine destructor.
GC may be expensive. GC call in QQmlEngine doesn't have much sense because V8 will destroy all objects living in a current context. The only problem is that V8 may decide to not invoke weak callbacks which may cause a memory leak. To avoid that we track all QObjects that have JavaScript ownership set and we delete them explicitly. The change reduce time of destroying QQmlEngine by 75%, which is really visible in qquicklistmodel test. Change-Id: I2a3668fd23630669114baee8c241a7ecc4100e33 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/qml/qml/v8/qv8engine_p.h')
-rw-r--r--src/qml/qml/v8/qv8engine_p.h22
1 files changed, 1 insertions, 21 deletions
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 1fc03d82e5..09e1ae537e 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -72,6 +72,7 @@
#include <private/qqmlpropertycache_p.h>
+#include "qv8objectresource_p.h"
#include "qv8contextwrapper_p.h"
#include "qv8qobjectwrapper_p.h"
#include "qv8stringwrapper_p.h"
@@ -91,12 +92,6 @@ QT_BEGIN_NAMESPACE
// a handle, qFatal() is called.
// #define QML_GLOBAL_HANDLE_DEBUGGING
-#define V8_RESOURCE_TYPE(resourcetype) \
-public: \
- enum { V8ResourceType = QV8ObjectResource:: resourcetype }; \
- virtual QV8ObjectResource::ResourceType resourceType() const { return QV8ObjectResource:: resourcetype; } \
-private:
-
#define V8ENGINE() ((QV8Engine *)v8::External::Unwrap(args.Data()))
#define V8FUNCTION(function, engine) v8::FunctionTemplate::New(function, v8::External::Wrap((QV8Engine*)engine))->GetFunction()
#define V8THROW_ERROR(string) { \
@@ -132,21 +127,6 @@ private:
} \
-class QV8Engine;
-class QV8ObjectResource : public v8::Object::ExternalResource
-{
-public:
- QV8ObjectResource(QV8Engine *engine) : engine(engine) { Q_ASSERT(engine); }
- enum ResourceType { ContextType, QObjectType, TypeType, ListType, VariantType,
- ValueTypeType, XMLHttpRequestType, DOMNodeType, SQLDatabaseType,
- ListModelType, Context2DType, Context2DStyleType, Context2DPixelArrayType,
- ParticleDataType, SignalHandlerType, IncubatorType, VisualDataItemType,
- SequenceType, LocaleDataType };
- virtual ResourceType resourceType() const = 0;
-
- QV8Engine *engine;
-};
-
template<class T>
inline T *v8_resource_cast(v8::Handle<v8::Object> object) {
QV8ObjectResource *resource = static_cast<QV8ObjectResource *>(object->GetExternalResource());