FIX(client): Don't delay ChannelListener processing

The processing of ChannelListeners was delayed until the next iteration
of the Qt event loop since it was thought that msgServerSync was running
in another thread. Given that this function already accesses the DB,
this can't be though.

Thus the delay is unnecessary and was therefore removed.
This commit is contained in:
Robert Adam 2020-08-19 16:37:17 +02:00
parent 3a55fb4a66
commit ba06bb184a

View File

@ -186,27 +186,24 @@ void MainWindow::msgServerSync(const MumbleProto::ServerSync &msg) {
updateTrayIcon();
// Set-up all ChannelListeners and their volume adjustments as before for this server
// Use the timer to execute the code in the main event loop as we have to access
// the database.
QTimer::singleShot(0, []() {
QList<int> localListeners = g.db->getChannelListeners(g.sh->qbaDigest);
QList<int> localListeners = g.db->getChannelListeners(g.sh->qbaDigest);
if (!localListeners.isEmpty()) {
ChannelListener::setInitialServerSyncDone(false);
g.sh->startListeningToChannels(localListeners);
} else {
// If there are no listeners, then no synchronization is needed in the first place
ChannelListener::setInitialServerSyncDone(true);
}
QHash<int, float> volumeMap = g.db->getChannelListenerLocalVolumeAdjustments(g.sh->qbaDigest);
if (!localListeners.isEmpty()) {
ChannelListener::setInitialServerSyncDone(false);
g.sh->startListeningToChannels(localListeners);
} else {
// If there are no listeners, then no synchronization is needed in the first place
ChannelListener::setInitialServerSyncDone(true);
}
QHash<int, float> volumeMap = g.db->getChannelListenerLocalVolumeAdjustments(g.sh->qbaDigest);
QHashIterator<int, float> it(volumeMap);
while(it.hasNext()) {
it.next();
ChannelListener::setListenerLocalVolumeAdjustment(it.key(), it.value());
}
QHashIterator<int, float> it(volumeMap);
while(it.hasNext()) {
it.next();
ChannelListener::setListenerLocalVolumeAdjustment(it.key(), it.value());
}
});
g.sh->setServerSynchronized(true);