diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llnotifications.cpp | 14 | ||||
-rw-r--r-- | indra/llui/llnotifications.h | 8 |
2 files changed, 16 insertions, 6 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index d736aa6634..c0a7866926 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -1171,6 +1171,14 @@ LLNotificationChannel::LLNotificationChannel(const std::string& name, connectToChannel(parent); } +LLNotificationChannel::~LLNotificationChannel() +{ + for (LLBoundListener &listener : mListeners) + { + listener.disconnect(); + } +} + bool LLNotificationChannel::isEmpty() const { return mItems.empty(); @@ -1213,14 +1221,14 @@ void LLNotificationChannel::connectToChannel( const std::string& channel_name ) { if (channel_name.empty()) { - LLNotifications::instance().connectChanged( - boost::bind(&LLNotificationChannelBase::updateItem, this, _1)); + mListeners.push_back(LLNotifications::instance().connectChanged( + boost::bind(&LLNotificationChannelBase::updateItem, this, _1))); } else { mParents.push_back(channel_name); LLNotificationChannelPtr p = LLNotifications::instance().getChannel(channel_name); - p->connectChanged(boost::bind(&LLNotificationChannelBase::updateItem, this, _1)); + mListeners.push_back(p->connectChanged(boost::bind(&LLNotificationChannelBase::updateItem, this, _1))); } } diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 921398a693..1577038c36 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -835,7 +835,7 @@ public: LLNotificationChannel(const Params& p = Params()); LLNotificationChannel(const std::string& name, const std::string& parent, LLNotificationFilter filter); - virtual ~LLNotificationChannel() {} + virtual ~LLNotificationChannel(); typedef LLNotificationSet::iterator Iterator; std::string getName() const { return mName; } @@ -845,8 +845,6 @@ public: return boost::iterator_range<parents_iter>(mParents); } - void connectToChannel(const std::string& channel_name); - bool isEmpty() const; S32 size() const; @@ -856,9 +854,13 @@ public: std::string summarize(); +protected: + void connectToChannel(const std::string& channel_name); + private: std::string mName; std::vector<std::string> mParents; + std::vector<LLBoundListener> mListeners; }; // An interface class to provide a clean linker seam to the LLNotifications class. |