summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r--src/script/api/qscriptengine.cpp67
1 files changed, 3 insertions, 64 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 9604fff..059b102 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -382,65 +382,6 @@ private:
bool m_shouldAbortEvaluation;
};
-/*Helper class. Main purpose is to give debugger feedback about unloading and loading scripts.
- It keeps pointer to JSGlobalObject assuming that it is always the same - there is no way to update
- this data. Class is internal and used as an implementation detail in and only in QScriptEngine::evaluate.*/
-class UStringSourceProviderWithFeedback: public JSC::UStringSourceProvider
-{
-public:
-
- static PassRefPtr<UStringSourceProviderWithFeedback> create(const JSC::UString& source, const JSC::UString& url, int lineNumber, QScriptEnginePrivate* engine)
- {
- return adoptRef(new UStringSourceProviderWithFeedback(source, url, lineNumber, engine));
- }
-
- /* Destruction means that there is no more copies of script so create scriptUnload event
- and unregister script in QScriptEnginePrivate::loadedScripts */
- virtual ~UStringSourceProviderWithFeedback()
- {
- if (m_ptr) {
- if (JSC::Debugger* debugger = this->debugger())
- debugger->scriptUnload(asID());
- m_ptr->loadedScripts.remove(this);
- }
- }
-
- /* set internal QScriptEnginePrivate pointer to null and create unloadScript event, should be called
- only if QScriptEnginePrivate is about to be destroyed.*/
- void disconnectFromEngine()
- {
- if (JSC::Debugger* debugger = this->debugger())
- debugger->scriptUnload(asID());
- m_ptr = 0;
- }
-
-protected:
- UStringSourceProviderWithFeedback(const JSC::UString& source, const JSC::UString& url, int lineNumber, QScriptEnginePrivate* engine)
- : UStringSourceProvider(source, url),
- m_ptr(engine)
- {
- if (JSC::Debugger* debugger = this->debugger())
- debugger->scriptLoad(asID(), source, url, lineNumber);
- if (m_ptr)
- m_ptr->loadedScripts.insert(this);
- }
-
- JSC::Debugger* debugger()
- {
- //if m_ptr is null it mean that QScriptEnginePrivate was destroyed and scriptUnload was called
- //else m_ptr is stable and we can use it as normal pointer without hesitation
- if(!m_ptr)
- return 0; //we are in ~QScriptEnginePrivate
- else
- return m_ptr->originalGlobalObject()->debugger(); //QScriptEnginePrivate is still alive
- }
-
- //trace global object and debugger instance
- QScriptEnginePrivate* m_ptr;
-};
-
-
-
static int toDigit(char c)
{
if ((c >= '0') && (c <= '9'))
@@ -900,11 +841,9 @@ QScriptEnginePrivate::QScriptEnginePrivate()
QScriptEnginePrivate::~QScriptEnginePrivate()
{
//disconnect all loadedScripts and generate all jsc::debugger::scriptUnload events
- QSet<QScript::UStringSourceProviderWithFeedback*>::const_iterator i = loadedScripts.constBegin();
- while(i!=loadedScripts.constEnd()) {
- (*i)->disconnectFromEngine();
- i++;
- }
+ QHash<intptr_t,QScript::UStringSourceProviderWithFeedback*>::const_iterator it;
+ for (it = loadedScripts.constBegin(); it != loadedScripts.constEnd(); ++it)
+ it.value()->disconnectFromEngine();
while (!ownedAgents.isEmpty())
delete ownedAgents.takeFirst();