diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2017-11-09 09:14:40 +0100 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2017-11-09 09:14:40 +0100 |
commit | 82e7a7be938e2eb6f90a969c043c81ea42e290ab (patch) | |
tree | 817e5c0465d126208451e574a4f47a2474e21ea4 | |
parent | a0089c47b0942cf889aaf45e5a5348b6fac644c3 (diff) | |
download | sigc++-82e7a7be938e2eb6f90a969c043c81ea42e290ab.tar.gz |
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
-rw-r--r-- | sigc++/signal_base.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sigc++/signal_base.h b/sigc++/signal_base.h index f50a6cb..843cb5f 100644 --- a/sigc++/signal_base.h +++ b/sigc++/signal_base.h @@ -297,6 +297,16 @@ private: * incremented. Both sigc::signal# objects then refer to the same * sigc::internal::signal_impl object. * + * Deleting the signal during emission, e.g. from one of its slots, may result + * in memory leaks. This drawback is fixed in version 3 of libsigc++. + * A workaround is to make a copy of the signal during the emission: + * @code + * sigc::signal<...> sig2(*p_sig); + * p_sig->emit(); + * @endcode + * This is not very costly. A sigc::signal<> is not much more than a pointer to + * a sigc::internal::signal_impl instance, which is not copied. + * * @ingroup signal */ struct SIGC_API signal_base : public trackable |