summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-25 07:45:20 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-25 08:36:35 (GMT)
commita5a215eefff176eda3b1bb97ee70abfbab20f054 (patch)
tree2a66bc6d4727aa31217a975383191ed67abc9f1f
parent5e43eb85043395655155edb5206de15024e3fb71 (diff)
downloadQt-a5a215eefff176eda3b1bb97ee70abfbab20f054.zip
Qt-a5a215eefff176eda3b1bb97ee70abfbab20f054.tar.gz
Qt-a5a215eefff176eda3b1bb97ee70abfbab20f054.tar.bz2
Memory leak in QScriptEngineAgent.
The documentation of the agent constructor specify that the agant is owned by the engine. Even if the agent is not set to the engine Reviewed-by: Kent Hansen
-rw-r--r--src/script/api/qscriptengine.cpp3
-rw-r--r--src/script/api/qscriptengineagent.cpp1
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp1
3 files changed, 2 insertions, 3 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 033d92e..f4e9594 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -3585,9 +3585,6 @@ void QScriptEngine::setAgent(QScriptEngineAgent *agent)
QScriptEngineAgentPrivate::get(d->activeAgent)->detach();
d->activeAgent = agent;
if (agent) {
- int index = d->ownedAgents.indexOf(agent);
- if (index == -1)
- d->ownedAgents.append(agent);
QScriptEngineAgentPrivate::get(agent)->attach();
}
}
diff --git a/src/script/api/qscriptengineagent.cpp b/src/script/api/qscriptengineagent.cpp
index b18f29d..193ee21 100644
--- a/src/script/api/qscriptengineagent.cpp
+++ b/src/script/api/qscriptengineagent.cpp
@@ -213,6 +213,7 @@ QScriptEngineAgent::QScriptEngineAgent(QScriptEngine *engine)
{
d_ptr->q_ptr = this;
d_ptr->engine = QScriptEnginePrivate::get(engine);
+ d_ptr->engine->ownedAgents.append(this);
}
/*!
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 0c67987..df74144 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -3913,6 +3913,7 @@ void tst_QScriptEngine::getSetAgent()
TestAgent *agent = new TestAgent(&eng);
QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::setAgent(): cannot set agent belonging to different engine");
eng2.setAgent(agent);
+ QCOMPARE(eng2.agent(), (QScriptEngineAgent*)0);
}
}