summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-02-01 13:37:44 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2010-02-01 13:37:44 (GMT)
commitec4eeb8f52b4a5841a3345db415b496adae2dee2 (patch)
tree457f1171f8598acbeb4a3eae8b8c1a4f7cdfef0c /src
parent394b7ae6421afb0e309b6207fa2b1fce2e44426e (diff)
downloadQt-ec4eeb8f52b4a5841a3345db415b496adae2dee2.zip
Qt-ec4eeb8f52b4a5841a3345db415b496adae2dee2.tar.gz
Qt-ec4eeb8f52b4a5841a3345db415b496adae2dee2.tar.bz2
Use RefPtr to store QScriptProgram's EvalExecutable
Otherwise we crash with latest WebKit trunk because the SourceProvider is prematurely destructed.
Diffstat (limited to 'src')
-rw-r--r--src/script/api/qscriptprogram.cpp9
-rw-r--r--src/script/api/qscriptprogram_p.h4
2 files changed, 7 insertions, 6 deletions
diff --git a/src/script/api/qscriptprogram.cpp b/src/script/api/qscriptprogram.cpp
index c452052..d4a32f4 100644
--- a/src/script/api/qscriptprogram.cpp
+++ b/src/script/api/qscriptprogram.cpp
@@ -63,7 +63,6 @@ QScriptProgramPrivate::QScriptProgramPrivate(const QString &src,
QScriptProgramPrivate::~QScriptProgramPrivate()
{
- delete _executable;
}
QScriptProgramPrivate *QScriptProgramPrivate::get(const QScriptProgram &q)
@@ -76,17 +75,17 @@ JSC::EvalExecutable *QScriptProgramPrivate::executable(JSC::ExecState *exec,
{
if (_executable) {
if (eng == engine)
- return _executable;
- delete _executable;
+ return _executable.get();
+ _executable = 0;
}
WTF::PassRefPtr<QScript::UStringSourceProviderWithFeedback> provider
= QScript::UStringSourceProviderWithFeedback::create(sourceCode, fileName, firstLineNumber, eng);
sourceId = provider->asID();
JSC::SourceCode source(provider, firstLineNumber); //after construction of SourceCode provider variable will be null.
- _executable = new JSC::EvalExecutable(exec, source);
+ _executable = JSC::EvalExecutable::create(exec, source);
engine = eng;
isCompiled = false;
- return _executable;
+ return _executable.get();
}
/*!
diff --git a/src/script/api/qscriptprogram_p.h b/src/script/api/qscriptprogram_p.h
index 427ab34..95e75fd 100644
--- a/src/script/api/qscriptprogram_p.h
+++ b/src/script/api/qscriptprogram_p.h
@@ -37,6 +37,8 @@
#include <QtCore/qobjectdefs.h>
+#include "RefPtr.h"
+
namespace JSC
{
class EvalExecutable;
@@ -67,7 +69,7 @@ public:
int firstLineNumber;
QScriptEnginePrivate *engine;
- JSC::EvalExecutable *_executable;
+ WTF::RefPtr<JSC::EvalExecutable> _executable;
intptr_t sourceId;
bool isCompiled;
};