Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: webrtc/base/sigslot.h

Issue 2842423002: Fixing sigslot copy constructors. (Closed)
Patch Set: Fixing missing backreference from copied slot to signal. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/base/sigslot_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/sigslot.h
diff --git a/webrtc/base/sigslot.h b/webrtc/base/sigslot.h
index 4534ec9dae4c4f5af97c068d1949ebf682d00c5c..45e0da216bf5c4acc09dd47f4e11c54edfbd2165 100644
--- a/webrtc/base/sigslot.h
+++ b/webrtc/base/sigslot.h
@@ -407,15 +407,12 @@ namespace sigslot {
_signal_base& operator= (_signal_base const& that);
public:
- _signal_base(const _signal_base& s) : _signal_base_interface(&_signal_base::do_slot_disconnect, &_signal_base::do_slot_duplicate) {
+ _signal_base(const _signal_base& o) : _signal_base_interface(&_signal_base::do_slot_disconnect, &_signal_base::do_slot_duplicate) {
lock_block<mt_policy> lock(this);
- connections_list::const_iterator it = m_connected_slots.begin();
- connections_list::const_iterator itEnd = m_connected_slots.end();
- while(it != itEnd)
+ for (const auto& connection : o.m_connected_slots)
{
- it->getdest()->signal_connect(this);
- m_connected_slots.push_back(*it);
- ++it;
+ connection.getdest()->signal_connect(this);
+ m_connected_slots.push_back(connection);
}
}
@@ -528,13 +525,21 @@ namespace sigslot {
{
}
+ has_slots(has_slots const& o) : has_slots_interface(&has_slots::do_signal_connect, &has_slots::do_signal_disconnect, &has_slots::do_disconnect_all)
+ {
+ lock_block<mt_policy> lock(this);
+ for (auto* sender : o.m_senders) {
+ sender->slot_duplicate(&o, this);
+ m_senders.insert(sender);
+ }
+ }
+
~has_slots()
{
this->disconnect_all();
}
private:
- has_slots(has_slots const&);
has_slots& operator= (has_slots const&);
static void do_signal_connect(has_slots_interface* p, _signal_base_interface* sender)
« no previous file with comments | « no previous file | webrtc/base/sigslot_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698