Skip to content

Commit

Permalink
qmlui: try to avoid actions looping and incomplete TCP packets
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Oct 15, 2017
1 parent c504c33 commit 9e946c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion qmlui/tardis/networkmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,10 @@ void NetworkManager::slotProcessTCPPackets()
if (read < 0)
{
/* if more data is needed, get it from the socket */
wholeData.append(socket->readAll());
QByteArray moreData = socket->readAll();
if (moreData.length() == 0)
return;
wholeData.append(moreData);
bytesAvailable = wholeData.length();
continue;
}
Expand Down
10 changes: 6 additions & 4 deletions qmlui/tardis/tardis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Tardis::Tardis(QQuickView *view, Doc *doc, NetworkManager *netMgr,
, m_showManager(showMgr)
, m_virtualConsole(vc)
, m_historyCount(0)
, m_undoing(false)
, m_busy(false)
{
Q_ASSERT(s_instance == NULL);
s_instance = this;
Expand Down Expand Up @@ -82,7 +82,7 @@ Tardis *Tardis::instance()

void Tardis::enqueueAction(int code, QObject *object, QVariant oldVal, QVariant newVal)
{
if (m_doc->loadStatus() == Doc::Loading || m_undoing)
if (m_doc->loadStatus() == Doc::Loading || m_busy)
return;

TardisAction action;
Expand All @@ -108,7 +108,7 @@ void Tardis::undoAction()

bool done = false;

m_undoing = true;
m_busy = true;

while (!done)
{
Expand All @@ -127,7 +127,7 @@ void Tardis::undoAction()

m_historyCount--;

m_undoing = false;
m_busy = false;
}

void Tardis::resetHistory()
Expand Down Expand Up @@ -250,7 +250,9 @@ void Tardis::slotProcessNetworkAction(int code, quint32 id, QVariant value)
/* on old value, because we're going to call the method used for undoing actions */
action.m_oldValue = value;

m_busy = true;
processAction(action);
m_busy = false;
}

void Tardis::processAction(TardisAction &action)
Expand Down
3 changes: 2 additions & 1 deletion qmlui/tardis/tardis.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ protected slots:
/** Count the actions (or batch of actions) recorded */
int m_historyCount;

bool m_undoing;
/** Flag to prevent actions looping */
bool m_busy;
};

#endif /* TARDIS_H */

0 comments on commit 9e946c3

Please sign in to comment.