Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
e31e0de9
Commit
e31e0de9
authored
Jul 23, 2010
by
Olivier Goffart
Browse files
QML JS Debugger: use RIIA for initializeing an evaluation context
parent
70f3f5d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/tools/qml/qmlobserver/jsdebuggeragent.cpp
View file @
e31e0de9
...
...
@@ -52,6 +52,26 @@
QT_BEGIN_NAMESPACE
class
JSDebuggerAgent
::
SetupExecEnv
{
JSDebuggerAgent
*
agent
;
JSDebuggerAgent
::
State
previousState
;
bool
hadException
;
public:
SetupExecEnv
(
JSDebuggerAgent
*
a
)
:
agent
(
a
),
previousState
(
a
->
state
),
hadException
(
a
->
engine
()
->
hasUncaughtException
())
{
agent
->
state
=
JSDebuggerAgent
::
Stopped
;
}
~
SetupExecEnv
()
{
if
(
!
hadException
&&
agent
->
engine
()
->
hasUncaughtException
())
agent
->
engine
()
->
clearExceptions
();
agent
->
state
=
previousState
;
}
};
class
JSAgentWatchData
{
public:
QByteArray
exp
;
...
...
@@ -323,25 +343,22 @@ void JSDebuggerAgent::messageReceived(const QByteArray& message)
state
=
NoState
;
continueExec
();
}
else
if
(
command
==
"EXEC"
)
{
S
tate
oldState
=
state
;
state
=
Stopped
;
S
etupExecEnv
execEnv
(
this
)
;
QByteArray
id
;
QString
expr
;
ds
>>
id
>>
expr
;
JSAgentWatchData
data
=
JSAgentWatchData
::
fromScriptValue
(
expr
,
engine
()
->
evaluate
(
expr
));
knownObjectIds
<<
data
.
objectId
;
// Clear any exceptions occurred during locals evaluation.
engine
()
->
clearExceptions
();
QByteArray
reply
;
QDataStream
rs
(
&
reply
,
QIODevice
::
WriteOnly
);
rs
<<
QByteArray
(
"RESULT"
)
<<
id
<<
data
;
sendMessage
(
reply
);
state
=
oldState
;
}
else
if
(
command
==
"EXPAND"
)
{
S
tate
oldState
=
state
;
state
=
Stopped
;
S
etupExecEnv
execEnv
(
this
)
;
QByteArray
requestId
;
quint64
objectId
;
ds
>>
requestId
>>
objectId
;
...
...
@@ -352,17 +369,13 @@ void JSDebuggerAgent::messageReceived(const QByteArray& message)
QList
<
JSAgentWatchData
>
result
=
expandObject
(
v
);
recordKnownObjects
(
result
);
// Clear any exceptions occurred during locals evaluation.
engine
()
->
clearExceptions
();
QByteArray
reply
;
QDataStream
rs
(
&
reply
,
QIODevice
::
WriteOnly
);
rs
<<
QByteArray
(
"EXPANDED"
)
<<
requestId
<<
result
;
sendMessage
(
reply
);
state
=
oldState
;
}
else
if
(
command
==
"ACTIVATE_FRAME"
)
{
State
oldState
=
state
;
state
=
Stopped
;
SetupExecEnv
execEnv
(
this
);
int
frameId
;
ds
>>
frameId
;
...
...
@@ -376,17 +389,12 @@ void JSDebuggerAgent::messageReceived(const QByteArray& message)
QList
<
JSAgentWatchData
>
locals
=
getLocals
(
ctx
);
// Clear any exceptions occurred during locals evaluation.
engine
()
->
clearExceptions
();
QByteArray
reply
;
QDataStream
rs
(
&
reply
,
QIODevice
::
WriteOnly
);
rs
<<
QByteArray
(
"LOCALS"
)
<<
frameId
<<
locals
;
sendMessage
(
reply
);
state
=
oldState
;
}
else
if
(
command
==
"SET_PROPERTY"
)
{
State
oldState
=
state
;
state
=
Stopped
;
SetupExecEnv
execEnv
(
this
);
QByteArray
id
;
qint64
objectId
;
...
...
@@ -402,11 +410,8 @@ void JSDebuggerAgent::messageReceived(const QByteArray& message)
QScriptValue
result
=
engine
()
->
evaluate
(
value
);
object
.
setProperty
(
property
,
result
);
}
// Clear any exceptions occurred during locals evaluation.
engine
()
->
clearExceptions
();
}
state
=
oldState
;
//TODO: feedback
}
else
if
(
command
==
"PING"
)
{
int
ping
;
...
...
src/tools/qml/qmlobserver/jsdebuggeragent.h
View file @
e31e0de9
...
...
@@ -103,6 +103,8 @@ public slots:
// void pauses();
private:
class
SetupExecEnv
;
friend
class
SetupExecEnv
;
enum
State
{
NoState
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment