@@ -432,10 +432,7 @@ void SocketApi::slotRegisterPath(const QString &alias)
432
432
433
433
Folder *f = FolderMan::instance ()->folder (alias);
434
434
if (f) {
435
- const QString message = buildRegisterPathMessage (removeTrailingSlash (f->path ()));
436
- for (const auto &listener : qAsConst (_listeners)) {
437
- listener->sendMessage (message);
438
- }
435
+ broadcastMessage (buildRegisterPathMessage (removeTrailingSlash (f->path ())));
439
436
}
440
437
441
438
_registeredAliases.insert (alias);
@@ -479,7 +476,9 @@ void SocketApi::slotUpdateFolderView(Folder *f)
479
476
480
477
void SocketApi::broadcastMessage (const QString &msg, bool doWait)
481
478
{
482
- for (const auto &listener : qAsConst (_listeners)) {
479
+ // operate on a copy of the list to prevent concurrency issues
480
+ const auto clients = _listeners.values ();
481
+ for (const auto &listener : clients) {
483
482
listener->sendMessage (msg, doWait);
484
483
}
485
484
}
@@ -530,7 +529,9 @@ void SocketApi::broadcastStatusPushMessage(const QString &systemPath, SyncFileSt
530
529
QString msg = buildMessage (QLatin1String (" STATUS" ), systemPath, fileStatus.toSocketAPIString ());
531
530
Q_ASSERT (!systemPath.endsWith (' /' ));
532
531
uint directoryHash = qHash (systemPath.left (systemPath.lastIndexOf (' /' )));
533
- for (const auto &listener : qAsConst (_listeners)) {
532
+ // operate on a copy of the list to prevent concurrency issues
533
+ const auto clients = _listeners.values ();
534
+ for (const auto &listener : clients) {
534
535
listener->sendMessageIfDirectoryMonitored (msg, directoryHash);
535
536
}
536
537
}
0 commit comments