Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
fea13a44
Commit
fea13a44
authored
Apr 15, 2011
by
Christiaan Janssen
Browse files
QmlDebugger: parsing packets iteratively in the communication protocol
Reviewed-by: Kai Koehne
parent
72e65485
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljsdebugclient/qpacketprotocol.cpp
View file @
fea13a44
...
...
@@ -153,46 +153,44 @@ public Q_SLOTS:
void
readyToRead
()
{
if
(
-
1
==
inProgressSize
)
{
// We need a size header of sizeof(qint32)
if
(
sizeof
(
qint32
)
>
(
uint
)
dev
->
bytesAvailable
())
return
;
// Read size header
int
read
=
dev
->
read
((
char
*
)
&
inProgressSize
,
sizeof
(
qint32
));
Q_ASSERT
(
read
==
sizeof
(
qint32
));
Q_UNUSED
(
read
);
// Check sizing constraints
if
(
inProgressSize
>
maxPacketSize
)
{
QObject
::
disconnect
(
dev
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readyToRead
()));
QObject
::
disconnect
(
dev
,
SIGNAL
(
aboutToClose
()),
this
,
SLOT
(
aboutToClose
()));
QObject
::
disconnect
(
dev
,
SIGNAL
(
bytesWritten
(
qint64
)),
this
,
SLOT
(
bytesWritten
(
qint64
)));
dev
=
0
;
emit
invalidPacket
();
return
;
}
inProgressSize
-=
sizeof
(
qint32
);
while
(
true
)
{
// Need to get trailing data
readyToRead
();
}
else
{
inProgress
.
append
(
dev
->
read
(
inProgressSize
-
inProgress
.
size
()));
if
(
inProgressSize
==
inProgress
.
size
())
{
// Packet has arrived!
packets
.
append
(
inProgress
);
inProgressSize
=
-
1
;
inProgress
.
clear
();
if
(
-
1
==
inProgressSize
)
{
// We need a size header of sizeof(qint32)
if
(
sizeof
(
qint32
)
>
(
uint
)
dev
->
bytesAvailable
())
return
;
// Read size header
int
read
=
dev
->
read
((
char
*
)
&
inProgressSize
,
sizeof
(
qint32
));
Q_ASSERT
(
read
==
sizeof
(
qint32
));
Q_UNUSED
(
read
);
// Check sizing constraints
if
(
inProgressSize
>
maxPacketSize
)
{
QObject
::
disconnect
(
dev
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readyToRead
()));
QObject
::
disconnect
(
dev
,
SIGNAL
(
aboutToClose
()),
this
,
SLOT
(
aboutToClose
()));
QObject
::
disconnect
(
dev
,
SIGNAL
(
bytesWritten
(
qint64
)),
this
,
SLOT
(
bytesWritten
(
qint64
)));
dev
=
0
;
emit
invalidPacket
();
return
;
}
inProgressSize
-=
sizeof
(
qint32
);
}
else
{
inProgress
.
append
(
dev
->
read
(
inProgressSize
-
inProgress
.
size
()));
emit
readyRead
();
if
(
inProgressSize
==
inProgress
.
size
())
{
// Packet has arrived!
packets
.
append
(
inProgress
);
inProgressSize
=
-
1
;
inProgress
.
clear
();
// Need to get trailing data
readyToRead
();
emit
readyRead
();
}
else
return
;
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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