summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-02-03 15:49:13 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-02-03 15:49:13 (GMT)
commitc0b1153b2fef7aa203ec5894fde616802f3c4725 (patch)
tree20ab5326ccd20d0e928393c0d953bb96598fd5be /src/script
parentc920856b58e9e01ea3813a4c158638b19a113501 (diff)
parentfda461ddb2ae740b50544d1fd8309d51418912db (diff)
downloadQt-c0b1153b2fef7aa203ec5894fde616802f3c4725.zip
Qt-c0b1153b2fef7aa203ec5894fde616802f3c4725.tar.gz
Qt-c0b1153b2fef7aa203ec5894fde616802f3c4725.tar.bz2
Merge branch 'qt-master-from-4.7' of scm.dev.nokia.troll.no:qt/qt-integration into master-integration
* 'qt-master-from-4.7' of scm.dev.nokia.troll.no:qt/qt-integration: (29 commits) Fix for QTBUG-17035 Fix QMutex can deadlock when calling tryLock Carefull free the data from XGetWindowProperty on X11. Fixes memory leaks in QX11Embed Fixed missing text when using static text items in GL 2 engine. Prevent recursion when creating window surface. Fixed es2 configure when both EGL/egl.h and GLES/egl.h are present. document that QThread::exit will exit future event loops Revert "Restore Qt 4.6 behaviour: exec() always enters the event loop." Don't ignore source-text when generating qsTrId translations for QML Fix a crash when undoing form layout Fix generated mif file cleaning in symbian-abld Fix potential networking crash due to null-pointer dereference Fix typo in qglthreads auto test. Revert "Improve timer ID safety by using a serial counter per ID." Invalidate QScriptPrograms when engine is destroyed Fix alignment issue causing crash in QtScript/JavaScriptCore Orientation control implementation for Symbian Restore Qt 4.6 behaviour: exec() always enters the event loop. No longer replace dash and dot in TARGET with underscore in Symbian ...
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/qscriptengine.cpp9
-rw-r--r--src/script/api/qscriptengine_p.h18
-rw-r--r--src/script/api/qscriptprogram.cpp21
-rw-r--r--src/script/api/qscriptprogram_p.h1
4 files changed, 42 insertions, 7 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 004e3a5..e3291e0 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -1022,6 +1022,7 @@ QScriptEnginePrivate::~QScriptEnginePrivate()
while (!ownedAgents.isEmpty())
delete ownedAgents.takeFirst();
+ detachAllRegisteredScriptPrograms();
detachAllRegisteredScriptValues();
detachAllRegisteredScriptStrings();
qDeleteAll(m_qobjectData);
@@ -1576,6 +1577,14 @@ bool QScriptEnginePrivate::scriptDisconnect(JSC::JSValue signal, JSC::JSValue re
#endif
+void QScriptEnginePrivate::detachAllRegisteredScriptPrograms()
+{
+ QSet<QScriptProgramPrivate*>::const_iterator it;
+ for (it = registeredScriptPrograms.constBegin(); it != registeredScriptPrograms.constEnd(); ++it)
+ (*it)->detachFromEngine();
+ registeredScriptPrograms.clear();
+}
+
void QScriptEnginePrivate::detachAllRegisteredScriptValues()
{
QScriptValuePrivate *it;
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index 05a8901..f8144e9 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -87,6 +87,7 @@ class QScriptEngineAgent;
class QScriptEnginePrivate;
class QScriptSyntaxCheckResult;
class QScriptEngine;
+class QScriptProgramPrivate;
namespace QScript
{
@@ -273,6 +274,10 @@ public:
static QScriptSyntaxCheckResult checkSyntax(const QString &program);
static bool canEvaluate(const QString &program);
+ inline void registerScriptProgram(QScriptProgramPrivate *program);
+ inline void unregisterScriptProgram(QScriptProgramPrivate *program);
+ void detachAllRegisteredScriptPrograms();
+
inline QScriptValuePrivate *allocateScriptValuePrivate(size_t);
inline void freeScriptValuePrivate(QScriptValuePrivate *p);
@@ -368,6 +373,7 @@ public:
static const int maxFreeScriptValues = 256;
int freeScriptValuesCount;
QScriptStringPrivate *registeredScriptStrings;
+ QSet<QScriptProgramPrivate*> registeredScriptPrograms;
QHash<int, QScriptTypeInfo*> m_typeInfos;
int processEventsInterval;
QScriptValue abortResult;
@@ -566,6 +572,18 @@ inline QByteArray convertToLatin1(const JSC::UString &str)
} // namespace QScript
+inline void QScriptEnginePrivate::registerScriptProgram(QScriptProgramPrivate *program)
+{
+ Q_ASSERT(!registeredScriptPrograms.contains(program));
+ registeredScriptPrograms.insert(program);
+}
+
+inline void QScriptEnginePrivate::unregisterScriptProgram(QScriptProgramPrivate *program)
+{
+ Q_ASSERT(registeredScriptPrograms.contains(program));
+ registeredScriptPrograms.remove(program);
+}
+
inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(size_t size)
{
if (freeScriptValues) {
diff --git a/src/script/api/qscriptprogram.cpp b/src/script/api/qscriptprogram.cpp
index da103bb..31af9a0 100644
--- a/src/script/api/qscriptprogram.cpp
+++ b/src/script/api/qscriptprogram.cpp
@@ -64,6 +64,7 @@ QScriptProgramPrivate::~QScriptProgramPrivate()
if (engine) {
QScript::APIShim shim(engine);
_executable.clear();
+ engine->unregisterScriptProgram(this);
}
}
@@ -78,7 +79,10 @@ JSC::EvalExecutable *QScriptProgramPrivate::executable(JSC::ExecState *exec,
if (_executable) {
if (eng == engine)
return _executable.get();
- _executable = 0;
+ // "Migrating" to another engine; clean up old state
+ QScript::APIShim shim(engine);
+ _executable.clear();
+ engine->unregisterScriptProgram(this);
}
WTF::PassRefPtr<QScript::UStringSourceProviderWithFeedback> provider
= QScript::UStringSourceProviderWithFeedback::create(sourceCode, fileName, firstLineNumber, eng);
@@ -86,10 +90,19 @@ JSC::EvalExecutable *QScriptProgramPrivate::executable(JSC::ExecState *exec,
JSC::SourceCode source(provider, firstLineNumber); //after construction of SourceCode provider variable will be null.
_executable = JSC::EvalExecutable::create(exec, source);
engine = eng;
+ engine->registerScriptProgram(this);
isCompiled = false;
return _executable.get();
}
+void QScriptProgramPrivate::detachFromEngine()
+{
+ _executable.clear();
+ sourceId = -1;
+ isCompiled = false;
+ engine = 0;
+}
+
/*!
Constructs a null QScriptProgram.
*/
@@ -122,9 +135,6 @@ QScriptProgram::QScriptProgram(const QScriptProgram &other)
*/
QScriptProgram::~QScriptProgram()
{
- // Q_D(QScriptProgram);
- // if (d->engine && (d->ref == 1))
- // d->engine->unregisterScriptProgram(d);
}
/*!
@@ -132,9 +142,6 @@ QScriptProgram::~QScriptProgram()
*/
QScriptProgram &QScriptProgram::operator=(const QScriptProgram &other)
{
- // if (d_func() && d_func()->engine && (d_func()->ref == 1))
- // d_func()->engine->unregisterScriptProgram(d_func());
- // }
d_ptr = other.d_ptr;
return *this;
}
diff --git a/src/script/api/qscriptprogram_p.h b/src/script/api/qscriptprogram_p.h
index d2fd234..e7809ab 100644
--- a/src/script/api/qscriptprogram_p.h
+++ b/src/script/api/qscriptprogram_p.h
@@ -61,6 +61,7 @@ public:
JSC::EvalExecutable *executable(JSC::ExecState *exec,
QScriptEnginePrivate *engine);
+ void detachFromEngine();
QBasicAtomicInt ref;