Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5555#include <QtCore/qdebug.h>
    5656#include <QtCore/qcoreapplication.h>
     57#include <QtCore/qpointer.h>
    5758#include <QtGui/qbrush.h>
    5859#include <QtGui/qfont.h>
     
    371372        if (!m_index.isValid()) {
    372373            // nothing to do, the node has been removed
     374            finish();
    373375            return;
    374376        }
     
    476478{
    477479public:
    478     InitModelJob(QScriptDebuggerLocalsModelPrivate *model,
     480    InitModelJob(QScriptDebuggerLocalsModel *model,
    479481                 int frameIndex,
    480482                 QScriptDebuggerCommandSchedulerInterface *scheduler)
     
    485487    void start()
    486488    {
     489        if (!m_model) {
     490            // Model has been deleted.
     491            finish();
     492            return;
     493        }
    487494        QScriptDebuggerCommandSchedulerFrontend frontend(commandScheduler(), this);
    488495        frontend.scheduleGetScopeChain(m_frameIndex);
     
    492499                        int)
    493500    {
     501        if (!m_model) {
     502            // Model has been deleted.
     503            finish();
     504            return;
     505        }
    494506        QScriptDebuggerCommandSchedulerFrontend frontend(commandScheduler(), this);
     507        QScriptDebuggerLocalsModelPrivate *model_d = QScriptDebuggerLocalsModelPrivate::get(m_model);
    495508        switch (m_state) {
    496509        case 0: {
     
    501514                if (i > 0)
    502515                    name.append(QString::fromLatin1(" (%0)").arg(i));
    503                 QModelIndex index = m_model->addTopLevelObject(name, scopeObject);
     516                QModelIndex index = model_d->addTopLevelObject(name, scopeObject);
    504517                if (i == 0)
    505                     m_model->emitScopeObjectAvailable(index);
     518                    model_d->emitScopeObjectAvailable(index);
    506519            }
    507520            frontend.scheduleGetThisObject(m_frameIndex);
     
    510523        case 1: {
    511524            QScriptDebuggerValue thisObject = response.resultAsScriptValue();
    512             m_model->addTopLevelObject(QLatin1String("this"), thisObject);
     525            model_d->addTopLevelObject(QLatin1String("this"), thisObject);
    513526            finish();
    514527          } break;
     
    517530
    518531private:
    519     QScriptDebuggerLocalsModelPrivate *m_model;
     532    QPointer<QScriptDebuggerLocalsModel> m_model;
    520533    int m_frameIndex;
    521534    int m_state;
     
    528541    Q_D(QScriptDebuggerLocalsModel);
    529542    d->frameIndex = frameIndex;
    530     QScriptDebuggerJob *job = new InitModelJob(d, frameIndex, d->commandScheduler);
     543    QScriptDebuggerJob *job = new InitModelJob(this, frameIndex, d->commandScheduler);
    531544    d->jobScheduler->scheduleJob(job);
    532545}
     
    537550{
    538551public:
    539     SyncModelJob(QScriptDebuggerLocalsModelPrivate *model,
     552    SyncModelJob(QScriptDebuggerLocalsModel *model,
    540553                 int frameIndex,
    541554                 QScriptDebuggerCommandSchedulerInterface *scheduler)
     
    546559    void start()
    547560    {
     561        if (!m_model) {
     562            // Model has been deleted.
     563            finish();
     564            return;
     565        }
    548566        QScriptDebuggerCommandSchedulerFrontend frontend(commandScheduler(), this);
    549567        frontend.scheduleGetScopeChain(m_frameIndex);
     
    553571                        int)
    554572    {
     573        if (!m_model) {
     574            // Model has been deleted.
     575            finish();
     576            return;
     577        }
    555578        QScriptDebuggerCommandSchedulerFrontend frontend(commandScheduler(), this);
    556579        switch (m_state) {
     
    562585        }   break;
    563586        case 1: {
     587            QScriptDebuggerLocalsModelPrivate *model_d = QScriptDebuggerLocalsModelPrivate::get(m_model);
    564588            QScriptDebuggerValue thisObject = response.resultAsScriptValue();
    565589            m_topLevelObjects.append(thisObject);
    566             bool equal = (m_topLevelObjects.size() == m_model->invisibleRootNode->children.size());
     590            bool equal = (m_topLevelObjects.size() == model_d->invisibleRootNode->children.size());
    567591            for (int i = 0; equal && (i < m_topLevelObjects.size()); ++i) {
    568592                const QScriptDebuggerValue &object = m_topLevelObjects.at(i);
    569                 equal = (object == m_model->invisibleRootNode->children.at(i)->property.value());
     593                equal = (object == model_d->invisibleRootNode->children.at(i)->property.value());
    570594            }
    571595            if (!equal) {
     
    573597                // we could try to be more clever, i.e. figure out
    574598                // exactly which objects were popped/pushed
    575                 m_model->removeTopLevelNodes();
     599                model_d->removeTopLevelNodes();
    576600                for (int j = 0; j < m_topLevelObjects.size(); ++j) {
    577601                    const QScriptDebuggerValue &object = m_topLevelObjects.at(j);
     
    584608                            name.append(QString::fromLatin1(" (%0)").arg(j));
    585609                    }
    586                     QModelIndex index = m_model->addTopLevelObject(name, object);
     610                    QModelIndex index = model_d->addTopLevelObject(name, object);
    587611                    if (j == 0)
    588                         m_model->emitScopeObjectAvailable(index);
     612                        model_d->emitScopeObjectAvailable(index);
    589613                }
    590614            } else {
    591                 m_model->syncTopLevelNodes();
     615                model_d->syncTopLevelNodes();
    592616            }
    593617            finish();
     
    597621
    598622private:
    599     QScriptDebuggerLocalsModelPrivate *m_model;
     623    QPointer<QScriptDebuggerLocalsModel> m_model;
    600624    int m_frameIndex;
    601625    int m_state;
     
    609633    Q_D(QScriptDebuggerLocalsModel);
    610634    d->frameIndex = frameIndex;
    611     QScriptDebuggerJob *job = new SyncModelJob(d, frameIndex, d->commandScheduler);
     635    QScriptDebuggerJob *job = new SyncModelJob(this, frameIndex, d->commandScheduler);
    612636    d->jobScheduler->scheduleJob(job);
    613637}
     
    637661        if (!m_index.isValid()) {
    638662            // nothing to do, the node has been removed
     663            finish();
    639664            return;
    640665        }
Note: See TracChangeset for help on using the changeset viewer.