summaryrefslogtreecommitdiffstats
path: root/src/scripttools/debugging
diff options
context:
space:
mode:
Diffstat (limited to 'src/scripttools/debugging')
-rw-r--r--src/scripttools/debugging/qscriptdebugger.cpp10
-rw-r--r--src/scripttools/debugging/qscriptdebugger_p.h2
-rw-r--r--src/scripttools/debugging/qscriptdebuggerbackend.cpp43
-rw-r--r--src/scripttools/debugging/qscriptdebuggerbackend_p_p.h6
-rw-r--r--src/scripttools/debugging/qscriptenginedebugger.cpp26
-rw-r--r--src/scripttools/debugging/qscriptenginedebugger.h7
6 files changed, 69 insertions, 25 deletions
diff --git a/src/scripttools/debugging/qscriptdebugger.cpp b/src/scripttools/debugging/qscriptdebugger.cpp
index 9cca8ad..20de788 100644
--- a/src/scripttools/debugging/qscriptdebugger.cpp
+++ b/src/scripttools/debugging/qscriptdebugger.cpp
@@ -75,10 +75,6 @@
#include "qscriptdebuggerjob_p_p.h"
#include "qscriptxmlparser_p.h"
-#include "qscriptenginedebuggerfrontend_p.h"
-#include "qscriptdebuggerbackend_p.h"
-#include <QtScript/qscriptengine.h>
-
#include "private/qobject_p.h"
#include <QtScript/qscriptcontext.h>
@@ -1946,6 +1942,12 @@ QToolBar *QScriptDebugger::createStandardToolBar(QWidget *widgetParent, QObject
return tb;
}
+bool QScriptDebugger::isInteractive() const
+{
+ Q_D(const QScriptDebugger);
+ return d->interactive;
+}
+
/*!
\reimp
*/
diff --git a/src/scripttools/debugging/qscriptdebugger_p.h b/src/scripttools/debugging/qscriptdebugger_p.h
index 9ed7e0a..ba27200 100644
--- a/src/scripttools/debugging/qscriptdebugger_p.h
+++ b/src/scripttools/debugging/qscriptdebugger_p.h
@@ -172,6 +172,8 @@ public:
bool eventFilter(QObject *, QEvent *e);
+ bool isInteractive() const;
+
Q_SIGNALS:
void stopped() const;
void started() const;
diff --git a/src/scripttools/debugging/qscriptdebuggerbackend.cpp b/src/scripttools/debugging/qscriptdebuggerbackend.cpp
index 9eaf571..7f4211c 100644
--- a/src/scripttools/debugging/qscriptdebuggerbackend.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerbackend.cpp
@@ -412,14 +412,15 @@ void QScriptDebuggerBackend::attachTo(QScriptEngine *engine)
detach();
d->agent = new QScriptDebuggerAgent(d, engine);
QScriptValue global = engine->globalObject();
+ d->origTraceFunction = global.property(QString::fromLatin1("print"));
global.setProperty(QString::fromLatin1("print"), traceFunction());
// global.setProperty(QString::fromLatin1("qAssert"), assertFunction());
+ d->origFileNameFunction = global.property(QString::fromLatin1("__FILE__"));
global.setProperty(QString::fromLatin1("__FILE__"), fileNameFunction(),
- QScriptValue::PropertyGetter | QScriptValue::PropertySetter
- | QScriptValue::ReadOnly);
+ QScriptValue::PropertyGetter | QScriptValue::ReadOnly);
+ d->origLineNumberFunction = global.property(QString::fromLatin1("__LINE__"));
global.setProperty(QString::fromLatin1("__LINE__"), lineNumberFunction(),
- QScriptValue::PropertyGetter | QScriptValue::PropertySetter
- | QScriptValue::ReadOnly);
+ QScriptValue::PropertyGetter | QScriptValue::ReadOnly);
engine->setAgent(d->agent);
}
@@ -433,21 +434,25 @@ void QScriptDebuggerBackend::attachTo(QScriptEngine *engine)
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
+ if (d->agent) {
+ QScriptEngine *eng = d->agent->engine();
+ if (eng && eng->agent() == d->agent) {
+ eng->setAgent(0);
+ QScriptValue global = eng->globalObject();
+ global.setProperty(QString::fromLatin1("print"), d->origTraceFunction);
+ d->origTraceFunction = QScriptValue();
+// global.setProperty(QString::fromLatin1("qAssert"), QScriptValue());
+ global.setProperty(QString::fromLatin1("__FILE__"), QScriptValue(),
+ QScriptValue::PropertyGetter);
+ global.setProperty(QString::fromLatin1("__FILE__"), d->origFileNameFunction);
+ d->origFileNameFunction = QScriptValue();
+ global.setProperty(QString::fromLatin1("__LINE__"), QScriptValue(),
+ QScriptValue::PropertyGetter);
+ global.setProperty(QString::fromLatin1("__LINE__"), d->origLineNumberFunction);
+ d->origLineNumberFunction = QScriptValue();
+ d->agent->nullifyBackendPointer();
+ d->agent = 0; // agent is owned by engine
+ }
}
d->pendingEvaluateLineNumber = -1;
diff --git a/src/scripttools/debugging/qscriptdebuggerbackend_p_p.h b/src/scripttools/debugging/qscriptdebuggerbackend_p_p.h
index de18304..a356762 100644
--- a/src/scripttools/debugging/qscriptdebuggerbackend_p_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerbackend_p_p.h
@@ -57,6 +57,7 @@
#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
+#include <QtScript/qscriptvalue.h>
#include "qscriptdebuggerbackend_p.h"
@@ -66,7 +67,6 @@ class QEvent;
class QString;
class QScriptContext;
class QScriptEngine;
-class QScriptValue;
class QScriptValueIterator;
class QScriptObjectSnapshot;
class QScriptDebuggerAgent;
@@ -126,6 +126,10 @@ public:
QObject *eventReceiver;
QScriptDebuggerBackend *q_ptr;
+
+ QScriptValue origTraceFunction;
+ QScriptValue origFileNameFunction;
+ QScriptValue origLineNumberFunction;
};
QT_END_NAMESPACE
diff --git a/src/scripttools/debugging/qscriptenginedebugger.cpp b/src/scripttools/debugging/qscriptenginedebugger.cpp
index 948a01a..f2245cc 100644
--- a/src/scripttools/debugging/qscriptenginedebugger.cpp
+++ b/src/scripttools/debugging/qscriptenginedebugger.cpp
@@ -126,7 +126,7 @@ public:
mode in which it accepts input from the user. The
evaluationResumed() signal is emitted when script evaluation is
resumed, i.e, when execution control is given back to the script
- engine.
+ engine. The state() function returns the debugger's current state.
When calling QScriptEngine::evaluate() it is useful to pass a
descriptive script name (file name) as second argument, as this is
@@ -226,6 +226,16 @@ public:
\value GoToLineAction Shows the "Go to Line" dialog.
*/
+/*!
+ \enum QScriptEngineDebugger::DebuggerState
+ \since 4.6
+
+ This enum specifies the current state of the debugger.
+
+ \value RunningState The debugger is running. (Script evaluation is allowed.)
+ \value SuspendedState The debugger has suspended script evaluation.
+*/
+
class QScriptEngineDebuggerPrivate
: public QObjectPrivate
{
@@ -387,6 +397,20 @@ void QScriptEngineDebugger::detach()
}
/*!
+ \since 4.6
+
+ Returns the current state of the debugger.
+
+ \sa evaluationResumed()
+ \sa evaluationSuspended()
+*/
+QScriptEngineDebugger::DebuggerState QScriptEngineDebugger::state() const
+{
+ Q_D(const QScriptEngineDebugger);
+ return !d->debugger || !d->debugger->isInteractive() ? SuspendedState : RunningState;
+}
+
+/*!
Returns a pointer to the instance of the specified standard \a
widget. The widgets available are defined by the DebuggerWidget
diff --git a/src/scripttools/debugging/qscriptenginedebugger.h b/src/scripttools/debugging/qscriptenginedebugger.h
index 0fd4963..b9061a2 100644
--- a/src/scripttools/debugging/qscriptenginedebugger.h
+++ b/src/scripttools/debugging/qscriptenginedebugger.h
@@ -92,6 +92,11 @@ public:
GoToLineAction
};
+ enum DebuggerState {
+ RunningState,
+ SuspendedState
+ };
+
QScriptEngineDebugger(QObject *parent = 0);
~QScriptEngineDebugger();
@@ -108,6 +113,8 @@ public:
QWidget *widget(DebuggerWidget widget) const;
QAction *action(DebuggerAction action) const;
+ DebuggerState state() const;
+
Q_SIGNALS:
void evaluationSuspended();
void evaluationResumed();