aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlengine_p.h
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2016-04-06 11:23:11 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-04-21 15:06:23 +0000
commit223516ae2f7131cc7f8972e9afdeca970d85473d (patch)
treef4415038b5507f26ee88e9a77325ba432d61f211 /src/qml/qml/qqmlengine_p.h
parent0c7a5165f3b3c9d2f271da4fe3cb49f09844a56e (diff)
V4: make QQmlEnginePrivate::dereferenceScarceResources inlinable.
Done by giving the "expensive" part its own function, that's even unlikely to be called anyway. Change-Id: I35621fb0a764879f9339b9e23f210c66971ff5b7 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/qml/qqmlengine_p.h')
-rw-r--r--src/qml/qml/qqmlengine_p.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 92eadb0540..440840d3c9 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -267,6 +267,8 @@ private:
struct Deletable { Deletable():next(0) {} virtual ~Deletable() {} Deletable *next; };
QFieldList<Deletable, &Deletable::next> toDeleteInEngineThread;
void doDeleteInEngineThread();
+
+ void cleanupScarceResources();
};
/*
@@ -279,6 +281,26 @@ inline void QQmlEnginePrivate::referenceScarceResources()
scarceResourcesRefCount += 1;
}
+/*
+ This function should be called after evaluation of the js expression is
+ complete, and so the scarce resources may be freed safely.
+ */
+inline void QQmlEnginePrivate::dereferenceScarceResources()
+{
+ Q_ASSERT(scarceResourcesRefCount > 0);
+ scarceResourcesRefCount -= 1;
+
+ // if the refcount is zero, then evaluation of the "top level"
+ // expression must have completed. We can safely release the
+ // scarce resources.
+ if (scarceResourcesRefCount == 0) {
+ QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine());
+ if (Q_UNLIKELY(!engine->scarceResources.isEmpty())) {
+ cleanupScarceResources();
+ }
+ }
+}
+
/*!
Returns true if the calling thread is the QQmlEngine thread.
*/