static QScriptValue breakpointDataToScriptValue(QScriptEngine *eng, const QScriptBreakpointData &in) { QScriptValue out = eng->newObject(); out.setProperty(QString::fromLatin1("scriptId"), QScriptValue(eng, qsreal(in.scriptId()))); out.setProperty(QString::fromLatin1("fileName"), QScriptValue(eng, in.fileName())); out.setProperty(QString::fromLatin1("lineNumber"), QScriptValue(eng, in.lineNumber())); out.setProperty(QString::fromLatin1("enabled"), QScriptValue(eng, in.isEnabled())); out.setProperty(QString::fromLatin1("singleShot"), QScriptValue(eng, in.isSingleShot())); out.setProperty(QString::fromLatin1("ignoreCount"), QScriptValue(eng, in.ignoreCount())); out.setProperty(QString::fromLatin1("condition"), QScriptValue(eng, in.condition())); return out; }
void QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsDataChanged( const QModelIndex &tl, const QModelIndex &br) { for (int i = tl.row(); i <= br.row(); ++i) { QScriptBreakpointData data = breakpointsModel->breakpointDataAt(i); qint64 scriptId = data.scriptId(); if (scriptId == -1) { scriptId = scriptsModel->resolveScript(data.fileName()); if (scriptId == -1) continue; } QScriptDebuggerCodeViewInterface *view = viewHash.value(scriptId); if (!view) continue; view->setBreakpointEnabled(data.lineNumber(), data.isEnabled()); } }
void QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsInserted( const QModelIndex &, int first, int last) { for (int i = first; i <= last; ++i) { QScriptBreakpointData data = breakpointsModel->breakpointDataAt(i); qint64 scriptId = data.scriptId(); if (scriptId == -1) { scriptId = scriptsModel->resolveScript(data.fileName()); if (scriptId == -1) continue; } QScriptDebuggerCodeViewInterface *view = viewHash.value(scriptId); if (!view) continue; view->setBreakpoint(data.lineNumber()); } }
/*! Sets a breakpoint defined by the given \a data. Returns an integer that uniquely identifies the new breakpoint, or -1 if setting the breakpoint failed. */ int QScriptDebuggerAgent::setBreakpoint(const QScriptBreakpointData &data) { Q_D(QScriptDebuggerAgent); qint64 scriptId = data.scriptId(); if (scriptId != -1) { if (!d->scripts.contains(scriptId)) { // that script has been unloaded, so invalidate the ID scriptId = -1; const_cast<QScriptBreakpointData&>(data).setScriptId(-1); } else if (data.fileName().isEmpty()) { QString fileName = d->scripts[scriptId].fileName(); const_cast<QScriptBreakpointData&>(data).setFileName(fileName); } } int id = d->nextBreakpointId; ++d->nextBreakpointId; if (scriptId != -1) { d->resolvedBreakpoints[scriptId].append(id); } else { QString fileName = data.fileName(); bool resolved = false; QScriptScriptMap::const_iterator it; for (it = d->scripts.constBegin(); it != d->scripts.constEnd(); ++it) { if (it.value().fileName() == fileName) { d->resolvedBreakpoints[it.key()].append(id); resolved = true; break; } } if (!resolved) d->unresolvedBreakpoints[fileName].append(id); } d->breakpoints.insert(id, data); return id; }