mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-03 00:06:09 +00:00
Only emit state changed once per iteration
This commit is contained in:
parent
6a37a9d77a
commit
6c8349787a
@ -125,7 +125,6 @@ class PcMonitorThread : public QThread
|
|||||||
// We must have at least 1 address for this host
|
// We must have at least 1 address for this host
|
||||||
Q_ASSERT(uniqueAddressList.count() != 0);
|
Q_ASSERT(uniqueAddressList.count() != 0);
|
||||||
|
|
||||||
|
|
||||||
bool stateChanged = false;
|
bool stateChanged = false;
|
||||||
for (int i = 0; i < TRIES_BEFORE_OFFLINING; i++) {
|
for (int i = 0; i < TRIES_BEFORE_OFFLINING; i++) {
|
||||||
for (auto& address : uniqueAddressList) {
|
for (auto& address : uniqueAddressList) {
|
||||||
@ -152,25 +151,19 @@ class PcMonitorThread : public QThread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stateChanged) {
|
|
||||||
// Tell anyone listening that we've changed state
|
|
||||||
emit computerStateChanged(m_Computer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grab the applist if it's empty or it's been long enough that we need to refresh
|
// Grab the applist if it's empty or it's been long enough that we need to refresh
|
||||||
pollsSinceLastAppListFetch++;
|
pollsSinceLastAppListFetch++;
|
||||||
if (m_Computer->state == NvComputer::CS_ONLINE &&
|
if (m_Computer->state == NvComputer::CS_ONLINE &&
|
||||||
(m_Computer->appList.isEmpty() || pollsSinceLastAppListFetch >= POLLS_PER_APPLIST_FETCH)) {
|
(m_Computer->appList.isEmpty() || pollsSinceLastAppListFetch >= POLLS_PER_APPLIST_FETCH)) {
|
||||||
stateChanged = false;
|
|
||||||
|
|
||||||
if (UpdateAppList(stateChanged)) {
|
if (UpdateAppList(stateChanged)) {
|
||||||
pollsSinceLastAppListFetch = 0;
|
pollsSinceLastAppListFetch = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (stateChanged) {
|
if (stateChanged) {
|
||||||
|
// Tell anyone listening that we've changed state
|
||||||
emit computerStateChanged(m_Computer);
|
emit computerStateChanged(m_Computer);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Wait a bit to poll again
|
// Wait a bit to poll again
|
||||||
QThread::sleep(3);
|
QThread::sleep(3);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user