src/script/api/qscriptprogram.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
child 37 758a864f9613
--- a/src/script/api/qscriptprogram.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/script/api/qscriptprogram.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -63,7 +63,10 @@
 
 QScriptProgramPrivate::~QScriptProgramPrivate()
 {
-    delete _executable;
+    if (engine) {
+        QScript::APIShim shim(engine);
+        _executable.clear();
+    }
 }
 
 QScriptProgramPrivate *QScriptProgramPrivate::get(const QScriptProgram &q)
@@ -76,17 +79,17 @@
 {
     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();
 }
 
 /*!
@@ -121,7 +124,7 @@
 */
 QScriptProgram::~QScriptProgram()
 {
-    Q_D(QScriptProgram);
+    //    Q_D(QScriptProgram);
     //    if (d->engine && (d->ref == 1))
     //      d->engine->unregisterScriptProgram(d);
 }