src/script/api/qscriptprogram.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
child 37 758a864f9613
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    61     ref = 0;
    61     ref = 0;
    62 }
    62 }
    63 
    63 
    64 QScriptProgramPrivate::~QScriptProgramPrivate()
    64 QScriptProgramPrivate::~QScriptProgramPrivate()
    65 {
    65 {
    66     delete _executable;
    66     if (engine) {
       
    67         QScript::APIShim shim(engine);
       
    68         _executable.clear();
       
    69     }
    67 }
    70 }
    68 
    71 
    69 QScriptProgramPrivate *QScriptProgramPrivate::get(const QScriptProgram &q)
    72 QScriptProgramPrivate *QScriptProgramPrivate::get(const QScriptProgram &q)
    70 {
    73 {
    71     return const_cast<QScriptProgramPrivate*>(q.d_func());
    74     return const_cast<QScriptProgramPrivate*>(q.d_func());
    74 JSC::EvalExecutable *QScriptProgramPrivate::executable(JSC::ExecState *exec,
    77 JSC::EvalExecutable *QScriptProgramPrivate::executable(JSC::ExecState *exec,
    75                                                        QScriptEnginePrivate *eng)
    78                                                        QScriptEnginePrivate *eng)
    76 {
    79 {
    77     if (_executable) {
    80     if (_executable) {
    78         if (eng == engine)
    81         if (eng == engine)
    79             return _executable;
    82             return _executable.get();
    80         delete _executable;
    83         _executable = 0;
    81     }
    84     }
    82     WTF::PassRefPtr<QScript::UStringSourceProviderWithFeedback> provider
    85     WTF::PassRefPtr<QScript::UStringSourceProviderWithFeedback> provider
    83         = QScript::UStringSourceProviderWithFeedback::create(sourceCode, fileName, firstLineNumber, eng);
    86         = QScript::UStringSourceProviderWithFeedback::create(sourceCode, fileName, firstLineNumber, eng);
    84     sourceId = provider->asID();
    87     sourceId = provider->asID();
    85     JSC::SourceCode source(provider, firstLineNumber); //after construction of SourceCode provider variable will be null.
    88     JSC::SourceCode source(provider, firstLineNumber); //after construction of SourceCode provider variable will be null.
    86     _executable = new JSC::EvalExecutable(exec, source);
    89     _executable = JSC::EvalExecutable::create(exec, source);
    87     engine = eng;
    90     engine = eng;
    88     isCompiled = false;
    91     isCompiled = false;
    89     return _executable;
    92     return _executable.get();
    90 }
    93 }
    91 
    94 
    92 /*!
    95 /*!
    93   Constructs a null QScriptProgram.
    96   Constructs a null QScriptProgram.
    94 */
    97 */
   119 /*!
   122 /*!
   120   Destroys this QScriptProgram.
   123   Destroys this QScriptProgram.
   121 */
   124 */
   122 QScriptProgram::~QScriptProgram()
   125 QScriptProgram::~QScriptProgram()
   123 {
   126 {
   124     Q_D(QScriptProgram);
   127     //    Q_D(QScriptProgram);
   125     //    if (d->engine && (d->ref == 1))
   128     //    if (d->engine && (d->ref == 1))
   126     //      d->engine->unregisterScriptProgram(d);
   129     //      d->engine->unregisterScriptProgram(d);
   127 }
   130 }
   128 
   131 
   129 /*!
   132 /*!