From ec4eeb8f52b4a5841a3345db415b496adae2dee2 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 1 Feb 2010 14:37:44 +0100 Subject: Use RefPtr to store QScriptProgram's EvalExecutable Otherwise we crash with latest WebKit trunk because the SourceProvider is prematurely destructed. --- src/script/api/qscriptprogram.cpp | 9 ++++----- src/script/api/qscriptprogram_p.h | 4 +++- 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 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 +#include "RefPtr.h" + namespace JSC { class EvalExecutable; @@ -67,7 +69,7 @@ public: int firstLineNumber; QScriptEnginePrivate *engine; - JSC::EvalExecutable *_executable; + WTF::RefPtr _executable; intptr_t sourceId; bool isCompiled; }; -- cgit v0.12