summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2019-10-15 23:06:04 -0400
committerNat Goodspeed <nat@lindenlab.com>2020-03-25 18:52:11 -0400
commitafaad3cef749e926cb63b6aed0c14f25d3495d55 (patch)
treea0b17319b7b477504b9c5a754db4f95b85c2ec77 /indra/llui
parent18e2b9ca8b5d4be0f1b92b464421693678cca0a0 (diff)
DRTVWR-476: Remove special case for listen(boost::bind(weak_ptr)).
LLEventDetail::visit_and_connect() promised special treatment for the specific case when an LLEventPump::listen() listener was composed of (possibly nested) boost::bind() objects storing boost::weak_ptr values -- specifically boost::bind() rather than std::bind or lambdas, specifically boost::weak_ptr rather than std::weak_ptr. Outside of self-tests, it does not appear that anyone actually uses that support. There is good reason not to: it's a silent side effect of a complicated compile-time inspection that could be silently derailed by use of std::bind() or a lambda or a std::weak_ptr. Can you be sure you've engaged that promise? How? A more robust guarantee can be achieved by storing an LLTempBoundConnection in the transient object itself. When the object is destroyed, the listener is disconnected. Normal C++ rules around object destruction guarantee it. This idiom is widely used. There are a couple good reasons to remove the visit_and_connect() machinery: * boost::bind() and boost::weak_ptr do not constitute the wave of the future. Preferring those constructs to lambdas and std::weak_ptr penalizes new code, whether by silently failing or by discouraging use of modern idioms. * The visit_and_connect() machinery was always complicated, and apparently never very robust. Most of its promised features have been commented out over the years. Making the code base simpler, clearer and more maintainable is always a useful effect. LLEventDetail::visit_and_connect() was also used by the four LLNotificationChannelBase::connectMumble() methods. Streamline those as well. Of course, remove related test code.
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llnotifications.h34
1 files changed, 8 insertions, 26 deletions
diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h
index 62cf41256b..cac687f53d 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -746,42 +746,24 @@ public:
virtual ~LLNotificationChannelBase() {}
// you can also connect to a Channel, so you can be notified of
// changes to this channel
- template <typename LISTENER>
- LLBoundListener connectChanged(const LISTENER& slot)
+ LLBoundListener connectChanged(const LLEventListener& slot)
{
- // Examine slot to see if it binds an LLEventTrackable subclass, or a
- // boost::shared_ptr to something, or a boost::weak_ptr to something.
// Call this->connectChangedImpl() to actually connect it.
- return LLEventDetail::visit_and_connect(slot,
- boost::bind(&LLNotificationChannelBase::connectChangedImpl,
- this,
- _1));
+ return connectChangedImpl(slot);
}
- template <typename LISTENER>
- LLBoundListener connectAtFrontChanged(const LISTENER& slot)
+ LLBoundListener connectAtFrontChanged(const LLEventListener& slot)
{
- return LLEventDetail::visit_and_connect(slot,
- boost::bind(&LLNotificationChannelBase::connectAtFrontChangedImpl,
- this,
- _1));
+ return connectAtFrontChangedImpl(slot);
}
- template <typename LISTENER>
- LLBoundListener connectPassedFilter(const LISTENER& slot)
+ LLBoundListener connectPassedFilter(const LLEventListener& slot)
{
// see comments in connectChanged()
- return LLEventDetail::visit_and_connect(slot,
- boost::bind(&LLNotificationChannelBase::connectPassedFilterImpl,
- this,
- _1));
+ return connectPassedFilterImpl(slot);
}
- template <typename LISTENER>
- LLBoundListener connectFailedFilter(const LISTENER& slot)
+ LLBoundListener connectFailedFilter(const LLEventListener& slot)
{
// see comments in connectChanged()
- return LLEventDetail::visit_and_connect(slot,
- boost::bind(&LLNotificationChannelBase::connectFailedFilterImpl,
- this,
- _1));
+ return connectFailedFilterImpl(slot);
}
// use this when items change or to add a new one