net/Socket.hpp | 4 ++-- wsd/Admin.cpp | 19 +++++++------------ wsd/AdminModel.cpp | 4 +--- 3 files changed, 10 insertions(+), 17 deletions(-)
New commits: commit 6bc6bdece9ec23755d87a791f402cf2667678396 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Tue Jan 2 21:33:52 2018 -0500 wsd: lambda cleanup and better readability Change-Id: Iabb850be7a7c162847514ee0fb600297accfcffb Reviewed-on: https://gerrit.libreoffice.org/47364 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit 57d535b15b94c0b506c17ab68838168d422c5deb) wsd: pass lambda args by value These callbacks are executed on a different thread and passing by ref is clearly invalid (and unintentional). Change-Id: I02e5359594f912baf67028202e6262d74b5769eb Reviewed-on: https://gerrit.libreoffice.org/47624 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit b0fa4c33cd79f240064aa282eb88c5fd359905ea) Reviewed-on: https://gerrit.libreoffice.org/48337 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/net/Socket.hpp b/net/Socket.hpp index a8ac63a7..01759953 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -433,11 +433,11 @@ public: std::swap(_newCallbacks, invoke); } - for (size_t i = 0; i < invoke.size(); ++i) + for (const auto& callback : invoke) { try { - invoke[i](); + callback(); } catch (const std::exception& exc) { diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp index b11b50b4..1c93d822 100644 --- a/wsd/Admin.cpp +++ b/wsd/Admin.cpp @@ -430,27 +430,24 @@ void Admin::pollingThread() } void Admin::modificationAlert(const std::string& dockey, Poco::Process::PID pid, bool value){ - addCallback([this, dockey, pid, value] - { _model.modificationAlert(dockey, pid, value); }); + addCallback([=] { _model.modificationAlert(dockey, pid, value); }); } void Admin::addDoc(const std::string& docKey, Poco::Process::PID pid, const std::string& filename, const std::string& sessionId, const std::string& userName, const std::string& userId) { - addCallback([this, docKey, pid, filename, sessionId, userName, userId] - { _model.addDocument(docKey, pid, filename, sessionId, userName, userId); }); + addCallback([=] { _model.addDocument(docKey, pid, filename, sessionId, userName, userId); }); } void Admin::rmDoc(const std::string& docKey, const std::string& sessionId) { - addCallback([this, docKey, sessionId] - { _model.removeDocument(docKey, sessionId); }); + addCallback([=] { _model.removeDocument(docKey, sessionId); }); } void Admin::rmDoc(const std::string& docKey) { LOG_INF("Removing complete doc [" << docKey << "] from Admin."); - addCallback([this, docKey]{ _model.removeDocument(docKey); }); + addCallback([=]{ _model.removeDocument(docKey); }); } void Admin::rescheduleMemTimer(unsigned interval) @@ -521,19 +518,17 @@ AdminModel& Admin::getModel() void Admin::updateLastActivityTime(const std::string& docKey) { - addCallback([this, docKey]{ _model.updateLastActivityTime(docKey); }); + addCallback([=]{ _model.updateLastActivityTime(docKey); }); } void Admin::updateMemoryDirty(const std::string& docKey, int dirty) { - addCallback([this, docKey, dirty] - { _model.updateMemoryDirty(docKey, dirty); }); + addCallback([=] { _model.updateMemoryDirty(docKey, dirty); }); } void Admin::addBytes(const std::string& docKey, uint64_t sent, uint64_t recv) { - addCallback([this, docKey, sent, recv] - { _model.addBytes(docKey, sent, recv); }); + addCallback([=] { _model.addBytes(docKey, sent, recv); }); } void Admin::notifyForkit() diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp index b3d67f7a..4b52ab82 100644 --- a/wsd/AdminModel.cpp +++ b/wsd/AdminModel.cpp @@ -449,10 +449,8 @@ void AdminModel::modificationAlert(const std::string& docKey, Poco::Process::PID assertCorrectThread(); auto doc = _documents.find(docKey); - if(doc != _documents.end()) - { + if (doc != _documents.end()) doc->second.setModified(value); - } std::ostringstream oss; oss << "modifications " _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits