Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/scripttools/debugging/qscriptdebuggerbackend.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtSCriptTools module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    132132
    133133QScriptDebuggerBackendPrivate::QScriptDebuggerBackendPrivate()
    134 {
    135     eventReceiver = 0;
    136     agent = 0;
    137     commandExecutor = 0;
    138     pendingEvaluateLineNumber = -1;
    139     ignoreExceptions = false;
    140     nextScriptValueIteratorId = 0;
    141     nextScriptObjectSnapshotId = 0;
     134    : agent(0), commandExecutor(0),
     135        pendingEvaluateContextIndex(-1), pendingEvaluateLineNumber(-1),
     136        ignoreExceptions(false),
     137        nextScriptValueIteratorId(0), nextScriptObjectSnapshotId(0),
     138        eventReceiver(0),
     139        q_ptr(0) // q_ptr will be set later by QScriptDebuggerBackend constructor
     140{
    142141}
    143142
     
    293292    for (int i = 0; i < context->argumentCount(); ++i) {
    294293        if (i > 0)
    295             str.append(QLatin1String(" "));
     294            str.append(QLatin1));
    296295        str.append(context->argument(i).toString());
    297296    }
     
    386385{
    387386    detach();
    388     delete d_ptr;
    389387}
    390388
     
    413411    d->agent = new QScriptDebuggerAgent(d, engine);
    414412    QScriptValue global = engine->globalObject();
     413
    415414    global.setProperty(QString::fromLatin1("print"), traceFunction());
    416415//    global.setProperty(QString::fromLatin1("qAssert"), assertFunction());
     416
    417417    global.setProperty(QString::fromLatin1("__FILE__"), fileNameFunction(),
    418                        QScriptValue::PropertyGetter | QScriptValue::PropertySetter
    419                        | QScriptValue::ReadOnly);
     418                       QScriptValue::PropertyGetter | QScriptValue::
     419    );
    420420    global.setProperty(QString::fromLatin1("__LINE__"), lineNumberFunction(),
    421                        QScriptValue::PropertyGetter | QScriptValue::PropertySetter
    422                        | QScriptValue::ReadOnly);
     421                       QScriptValue::PropertyGetter | QScriptValue::ReadOnly);
    423422    engine->setAgent(d->agent);
    424423}
     
    434433{
    435434    Q_D(QScriptDebuggerBackend);
    436     if (!d->agent)
    437         return;
    438     QScriptEngine *eng = d->agent->engine();
    439     if (eng && eng->agent() == d->agent) {
    440         eng->setAgent(0);
    441         QScriptValue global = eng->globalObject();
    442         if (global.property(QString::fromLatin1("print")).strictlyEquals(traceFunction()))
    443             global.setProperty(QString::fromLatin1("print"), QScriptValue());
    444 //        global.setProperty(QString::fromLatin1("qAssert"), QScriptValue());
    445         if (global.property(QString::fromLatin1("__FILE__")).strictlyEquals(fileNameFunction()))
    446             global.setProperty(QString::fromLatin1("__FILE__"), QScriptValue());
    447         if (global.property(QString::fromLatin1("__LINE__")).strictlyEquals(lineNumberFunction()))
    448             global.setProperty(QString::fromLatin1("__LINE__"), QScriptValue());
    449         d->agent->nullifyBackendPointer();
    450         d->agent = 0; // agent is owned by engine
     435    if (d->agent) {
     436        QScriptEngine *eng = d->agent->engine();
     437        if (eng && eng->agent() == d->agent) {
     438            eng->setAgent(0);
     439            QScriptValue global = eng->globalObject();
     440            global.setProperty(QString::fromLatin1("print"), d->origTraceFunction);
     441            d->origTraceFunction = QScriptValue();
     442//            global.setProperty(QString::fromLatin1("qAssert"), QScriptValue());
     443            global.setProperty(QString::fromLatin1("__FILE__"), QScriptValue(),
     444                               QScriptValue::PropertyGetter);
     445            global.setProperty(QString::fromLatin1("__FILE__"), d->origFileNameFunction);
     446            d->origFileNameFunction = QScriptValue();
     447            global.setProperty(QString::fromLatin1("__LINE__"), QScriptValue(),
     448                               QScriptValue::PropertyGetter);
     449            global.setProperty(QString::fromLatin1("__LINE__"), d->origLineNumberFunction);
     450            d->origLineNumberFunction = QScriptValue();
     451            d->agent->nullifyBackendPointer();
     452            d->agent = 0; // agent is owned by engine
     453        }
    451454    }
    452455
     
    616619    {
    617620        QScriptContext *evalContext = engine()->pushContext();
    618 #if QT_VERSION >= 0x040500
    619621        QScriptValueList scopeChain = ctx->scopeChain();
    620622        if (scopeChain.isEmpty())
     
    622624        while (!scopeChain.isEmpty())
    623625            evalContext->pushScope(scopeChain.takeLast());
    624 #endif
    625626        evalContext->setActivationObject(ctx->activationObject());
    626627        evalContext->setThisObject(ctx->thisObject());
     
    805806    if (!engine())
    806807        return 0;
    807     int count = 0;
    808     QScriptContext *ctx = engine()->currentContext();
    809     while (ctx) {
    810         ++count;
    811         ctx = ctx->parentContext();
    812     }
    813     return count;
     808    return contextIds().count();
    814809}
    815810
Note: See TracChangeset for help on using the changeset viewer.