diff options
| author | Aurindam Jana <aurindam.jana@digia.com> | 2013-09-10 16:57:45 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 21:40:49 +0200 |
| commit | 353a068c7716a34eb90d1441893f4c4a5b28f9de (patch) | |
| tree | 1c7cbaa262b10ae5dc14d9e8ab3f7a4732217bb2 /src/qml/debugger/qv4debugservice.cpp | |
| parent | 0b901ddda7936bb535125beaccc5fb9ee12617cb (diff) | |
QmlDebugging: Replace QV8DebugService with QV4DebugService
Change-Id: Ic8c99e3984d9ef6d122f7d8834df97eeb1f1fda3
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/qml/debugger/qv4debugservice.cpp')
| -rw-r--r-- | src/qml/debugger/qv4debugservice.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/qml/debugger/qv4debugservice.cpp b/src/qml/debugger/qv4debugservice.cpp index 9415cc4d31..10aefbfd13 100644 --- a/src/qml/debugger/qv4debugservice.cpp +++ b/src/qml/debugger/qv4debugservice.cpp @@ -47,7 +47,8 @@ #include <private/qv8engine_p.h> -const char *V4_DEBUGGER_KEY_CONNECT = "connect"; +const char *V4_CONNECT = "connect"; +const char *V4_BREAK_ON_SIGNAL = "breakonsignal"; QT_BEGIN_NAMESPACE @@ -64,9 +65,20 @@ class QV4DebugServicePrivate : public QQmlDebugServicePrivate Q_DECLARE_PUBLIC(QV4DebugService) public: + static QByteArray packMessage(const QString &type, const QString &message = QString()) + { + QByteArray reply; + QQmlDebugStream rs(&reply, QIODevice::WriteOnly); + QByteArray cmd("V4DEBUG"); + rs << cmd << type.toUtf8() << message.toUtf8(); + return reply; + } + QMutex initializeMutex; QWaitCondition initializeCondition; QV4DebuggerAgent debuggerAgent; + + QStringList breakOnSignals; }; QV4DebugService::QV4DebugService(QObject *parent) @@ -122,6 +134,25 @@ void QV4DebugService::removeEngine(const QV4::ExecutionEngine *engine) d->debuggerAgent.removeDebugger(engine->debugger); } +void QV4DebugService::signalEmitted(const QString &signal) +{ + //This function is only called by QQmlBoundSignal + //only if there is a slot connected to the signal. Hence, there + //is no need for additional check. + Q_D(QV4DebugService); + + //Parse just the name and remove the class info + //Normalize to Lower case. + QString signalName = signal.left(signal.indexOf(QLatin1Char('('))).toLower(); + + foreach (const QString &signal, d->breakOnSignals) { + if (signal == signalName) { + // TODO: pause debugger + break; + } + } +} + void QV4DebugService::stateChanged(QQmlDebugService::State newState) { Q_D(QV4DebugService); @@ -148,9 +179,21 @@ void QV4DebugService::messageReceived(const QByteArray &message) QByteArray data; ds >> command >> data; - if (command == V4_DEBUGGER_KEY_CONNECT) { + if (command == V4_CONNECT) { // wake up constructor in blocking mode d->initializeCondition.wakeAll(); + } else if (command == V4_BREAK_ON_SIGNAL) { + QQmlDebugStream rs(data); + QByteArray signal; + bool enabled; + rs >> signal >> enabled; + //Normalize to lower case. + QString signalName(QString::fromUtf8(signal).toLower()); + if (enabled) + d->breakOnSignals.append(signalName); + else + d->breakOnSignals.removeOne(signalName); + sendMessage(QV4DebugServicePrivate::packMessage(QLatin1String(V4_BREAK_ON_SIGNAL))); } } } |
