Skip to content

Commit 82e7a7b

Browse files
committed
signal_base docs: Warn against deletion during emission
There is no known ABI-preserving fix for a memory leak, if a signal is deleted during emission. Describe a workaround in the documentation. Bug 167714
1 parent a0089c4 commit 82e7a7b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sigc++/signal_base.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,16 @@ struct temp_slot_list
297297
* incremented. Both sigc::signal# objects then refer to the same
298298
* sigc::internal::signal_impl object.
299299
*
300+
* Deleting the signal during emission, e.g. from one of its slots, may result
301+
* in memory leaks. This drawback is fixed in version 3 of libsigc++.
302+
* A workaround is to make a copy of the signal during the emission:
303+
* @code
304+
* sigc::signal<...> sig2(*p_sig);
305+
* p_sig->emit();
306+
* @endcode
307+
* This is not very costly. A sigc::signal<> is not much more than a pointer to
308+
* a sigc::internal::signal_impl instance, which is not copied.
309+
*
300310
* @ingroup signal
301311
*/
302312
struct SIGC_API signal_base : public trackable

0 commit comments

Comments
 (0)