Skip to content

Commit 65edaa5

Browse files
committed
signal_impl::clear(): Don't clear the slot list during signal emission
If signal_impl::clear() is called during signal emission, don't call slots_.clear(). Let signal_impl::sweep() erase all slots after the signal emission. Bug 784550
1 parent d1a04ee commit 65edaa5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

sigc++/signal_base.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ signal_impl::clear()
6868
// Don't call shared_from_this() here. clear() is called from the destructor.
6969
// When the destructor is executing, shared_ptr's use_count has reached 0,
7070
// and it's no longer possible to get a shared_ptr to this.
71+
const bool during_signal_emission = exec_count_ > 0;
7172
const bool saved_deferred = deferred_;
7273
signal_impl_exec_holder exec(this);
7374

@@ -76,9 +77,15 @@ signal_impl::clear()
7677
for (auto& slot : slots_)
7778
slot.disconnect();
7879

79-
deferred_ = saved_deferred;
80-
81-
slots_.clear();
80+
// Don't clear slots_ during signal emission. Provided deferred_ is true,
81+
// sweep() will be called from ~signal_impl_holder() after signal emission,
82+
// and it will erase all disconnected slots.
83+
// https://bugzilla.gnome.org/show_bug.cgi?id=784550
84+
if (!during_signal_emission)
85+
{
86+
deferred_ = saved_deferred;
87+
slots_.clear();
88+
}
8289
}
8390

8491
signal_impl::size_type

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy