Exemplo n.º 1
0
/*!
  Detaches this backend from the current script engine.
  The backend's state (including breakpoints and information on loaded
  scripts) will be invalidated.

  \sa attach()
*/
void QScriptDebuggerBackend::detach()
{
    Q_D(QScriptDebuggerBackend);
    if (!d->agent)
        return;
    QScriptEngine *eng = d->agent->engine();
    if (eng && eng->agent() == d->agent) {
        eng->setAgent(0);
        QScriptValue global = eng->globalObject();
        if (global.property(QString::fromLatin1("print")).strictlyEquals(traceFunction()))
            global.setProperty(QString::fromLatin1("print"), QScriptValue());
//        global.setProperty(QString::fromLatin1("qAssert"), QScriptValue());
        if (global.property(QString::fromLatin1("__FILE__")).strictlyEquals(fileNameFunction()))
            global.setProperty(QString::fromLatin1("__FILE__"), QScriptValue());
        if (global.property(QString::fromLatin1("__LINE__")).strictlyEquals(lineNumberFunction()))
            global.setProperty(QString::fromLatin1("__LINE__"), QScriptValue());
        d->agent->nullifyBackendPointer();
        d->agent = 0; // agent is owned by engine
    }

    d->pendingEvaluateLineNumber = -1;
    d->ignoreExceptions = false;
    d->nextScriptValueIteratorId = 0;
    qDeleteAll(d->scriptValueIterators);
    d->scriptValueIterators.clear();
    qDeleteAll(d->scriptObjectSnapshots);
    d->scriptObjectSnapshots.clear();
}