summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptengine.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-25 15:54:51 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-25 15:54:51 (GMT)
commit3671dbf34940e166b747b6f8f3f5758fd486073c (patch)
tree73dfe3d7d5150f4f6cbeac8ead747eedfd323123 /src/script/api/qscriptengine.cpp
parent194013d9db1b3e4ba6f56a864f3b64f523202948 (diff)
parent3343298448da3f2546b0708670effb798f762c5c (diff)
downloadQt-3671dbf34940e166b747b6f8f3f5758fd486073c.zip
Qt-3671dbf34940e166b747b6f8f3f5758fd486073c.tar.gz
Qt-3671dbf34940e166b747b6f8f3f5758fd486073c.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (153 commits) Use QTRY_COMPARE after QTest::qWaitForWindowShown() Use the new memory cost reporting API in QtScript Custom Class example QtScript: Add API for reporting additional memory costs Add experimental support for StaticContents in Mac OS X. Fix misspelling in function name. don't just return the first key here. Fix CI sytem build breakage. Fix crash. Compile with QT_NO_NETWORKINTERFACE defined. Don't emit signals in constructor. Remove unused code. fix multiple promps for keychain access when connecting to wifi network not all interfaces should be active Update changelog Fix qcombobox:flaggedItems autotest failure. Wrong value for PM_ScrollBarExtent on Windows XP. doc: Fixed all the remaining qdoc errors. For now. Do not move keyboard focus to invisible windows on X11. Do not use _NET_ACTIVE_WINDOW for nonmanaged windows. Revert "Revert "Make QWidget::activateWindow() NET window manager aware."" ...
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r--src/script/api/qscriptengine.cpp62
1 files changed, 59 insertions, 3 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 356b4d0..b322523 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -260,6 +260,22 @@ QT_BEGIN_NAMESPACE
whether an engine is currently running a script by calling
isEvaluating().
+ \section1 Garbage Collection
+
+ Qt Script objects may be garbage collected when they are no longer
+ referenced. There is no guarantee as to when automatic garbage
+ collection will take place.
+
+ The collectGarbage() function can be called to explicitly request
+ garbage collection.
+
+ The reportAdditionalMemoryCost() function can be called to indicate
+ that a Qt Script object occupies memory that isn't managed by the
+ scripting environment. Reporting the additional cost makes it more
+ likely that the garbage collector will be triggered. This can be
+ useful, for example, when many custom, native Qt Script objects are
+ allocated.
+
\section1 Core Debugging/Tracing Facilities
Since Qt 4.4, you can be notified of events pertaining to script
@@ -292,6 +308,7 @@ QT_BEGIN_NAMESPACE
\value ExcludeSuperClassProperties The script object will not expose properties inherited from the superclass.
\value ExcludeSuperClassContents Shorthand form for ExcludeSuperClassMethods | ExcludeSuperClassProperties
\value ExcludeDeleteLater The script object will not expose the QObject::deleteLater() slot.
+ \value ExcludeSlots The script object will not expose the QObject's slots.
\value AutoCreateDynamicProperties Properties that don't already exist in the QObject will be created as dynamic properties of that object, rather than as properties of the script object.
\value PreferExistingWrapperObject If a wrapper object with the requested configuration already exists, return that object.
\value SkipMethodsInEnumeration Don't include methods (signals and slots) when enumerating the object's properties.
@@ -1192,6 +1209,12 @@ void QScriptEnginePrivate::collectGarbage()
globalData->heap.collectAllGarbage();
}
+void QScriptEnginePrivate::reportAdditionalMemoryCost(int size)
+{
+ if (size > 0)
+ globalData->heap.reportExtraMemoryCost(size);
+}
+
QScript::TimeoutCheckerProxy *QScriptEnginePrivate::timeoutChecker() const
{
return static_cast<QScript::TimeoutCheckerProxy*>(globalData->timeoutChecker);
@@ -1989,7 +2012,7 @@ QScriptValue QScriptEngine::newRegExp(const QRegExp &regexp)
prototype; otherwise, the prototype will be the Object prototype
object.
- \sa setDefaultPrototype(), QScriptValue::toVariant()
+ \sa setDefaultPrototype(), QScriptValue::toVariant(), reportAdditionalMemoryCost()
*/
QScriptValue QScriptEngine::newVariant(const QVariant &value)
{
@@ -2020,6 +2043,8 @@ QScriptValue QScriptEngine::newVariant(const QVariant &value)
true), you can pass QScriptContext::thisObject() (the default
constructed script object) to this function to initialize the new
object.
+
+ \sa reportAdditionalMemoryCost()
*/
QScriptValue QScriptEngine::newVariant(const QScriptValue &object,
const QVariant &value)
@@ -2050,7 +2075,7 @@ QScriptValue QScriptEngine::newVariant(const QScriptValue &object,
wrapper object (either by script code or C++) will result in a
script exception.
- \sa QScriptValue::toQObject()
+ \sa QScriptValue::toQObject(), reportAdditionalMemoryCost()
*/
QScriptValue QScriptEngine::newQObject(QObject *object, ValueOwnership ownership,
const QObjectWrapOptions &options)
@@ -2084,6 +2109,8 @@ QScriptValue QScriptEngine::newQObject(QObject *object, ValueOwnership ownership
(QScriptContext::isCalledAsConstructor() returns true), you can pass
QScriptContext::thisObject() (the default constructed script object)
to this function to initialize the new object.
+
+ \sa reportAdditionalMemoryCost()
*/
QScriptValue QScriptEngine::newQObject(const QScriptValue &scriptObject,
QObject *qtObject,
@@ -2137,7 +2164,7 @@ QScriptValue QScriptEngine::newObject()
\a data, if specified, is set as the internal data of the
new object (using QScriptValue::setData()).
- \sa QScriptValue::scriptClass()
+ \sa QScriptValue::scriptClass(), reportAdditionalMemoryCost()
*/
QScriptValue QScriptEngine::newObject(QScriptClass *scriptClass,
const QScriptValue &data)
@@ -3843,6 +3870,8 @@ QStringList QScriptEngine::importedExtensions() const
been created). However, you can call this function to explicitly
request that garbage collection should be performed as soon as
possible.
+
+ \sa reportAdditionalMemoryCost()
*/
void QScriptEngine::collectGarbage()
{
@@ -3851,6 +3880,33 @@ void QScriptEngine::collectGarbage()
}
/*!
+ \since 4.7
+
+ Reports an additional memory cost of the given \a size, measured in
+ bytes, to the garbage collector.
+
+ This function can be called to indicate that a Qt Script object has
+ memory associated with it that isn't managed by Qt Script itself.
+ Reporting the additional cost makes it more likely that the garbage
+ collector will be triggered.
+
+ Note that if the additional memory is shared with objects outside
+ the scripting environment, the cost should not be reported, since
+ collecting the Qt Script object would not cause the memory to be
+ freed anyway.
+
+ Negative \a size values are ignored, i.e. this function can't be
+ used to report that the additional memory has been deallocated.
+
+ \sa collectGarbage()
+*/
+void QScriptEngine::reportAdditionalMemoryCost(int size)
+{
+ Q_D(QScriptEngine);
+ d->reportAdditionalMemoryCost(size);
+}
+
+/*!
Sets the interval between calls to QCoreApplication::processEvents
to \a interval milliseconds.