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
Plasma
Plasma Add-ons
Commits
376b1a6f
Verified
Commit
376b1a6f
authored
May 10, 2022
by
Fushan Wen
Browse files
dict: move `waitForReadyRead` to while condition
In case `waitForReadyRead` returns false, there will be a dead loop.
parent
52e13a84
Changes
1
Hide whitespace changes
Inline
Side-by-side
dict/dictengine.cpp
View file @
376b1a6f
...
...
@@ -115,10 +115,12 @@ void DictEngine::getDefinition()
m_tcpSocket
->
write
(
command
);
m_tcpSocket
->
flush
();
while
(
std
::
none_of
(
m_definitionResponses
.
cbegin
(),
m_definitionResponses
.
cend
(),
[
&
ret
](
const
QByteArray
&
code
)
{
return
ret
.
contains
(
code
);
}))
{
m_tcpSocket
->
waitForReadyRead
();
while
(
std
::
none_of
(
m_definitionResponses
.
cbegin
(),
m_definitionResponses
.
cend
(),
[
&
ret
](
const
QByteArray
&
code
)
{
return
ret
.
contains
(
code
);
})
&&
m_tcpSocket
->
waitForReadyRead
())
{
ret
+=
m_tcpSocket
->
readAll
();
}
...
...
@@ -135,10 +137,10 @@ void DictEngine::getDicts()
m_tcpSocket
->
write
(
QByteArray
(
"SHOW DB
\n
"
));
m_tcpSocket
->
flush
();
m_tcpSocket
->
waitForReadyRead
()
;
while
(
!
ret
.
contains
(
"250"
)
&&
!
ret
.
contains
(
"420"
)
&&
!
ret
.
contains
(
"421"
))
{
m_tcpSocket
->
waitForReadyRead
();
ret
+=
m_tcpSocket
->
readAll
();
if
(
m_tcpSocket
->
waitForReadyRead
()
)
{
while
(
!
ret
.
contains
(
"250"
)
&&
!
ret
.
contains
(
"420"
)
&&
!
ret
.
contains
(
"421"
)
&&
m_tcpSocket
->
waitForReadyRead
()
)
{
ret
+=
m_tcpSocket
->
readAll
();
}
}
QMap
<
QString
,
QString
>
availableDicts
;
...
...
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