summaryrefslogtreecommitdiff
path: root/indra/llui/llnotifications.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-04-24 19:28:15 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2024-04-24 19:28:15 +0300
commit85f2447b3ddf7e4b91cd5963cb2e7668d48ab2a9 (patch)
tree494487bbc57c79d17921b7443003d2a118e24ddb /indra/llui/llnotifications.cpp
parent398369233fc2621eb447701e26082057fb0c97d7 (diff)
parentd98fc504a1d4bc292ba86acdda053c8b4598a193 (diff)
Merge branch 'main' into marchcat/a-merge
# Conflicts: # autobuild.xml # indra/llimage/llimage.cpp # indra/llui/llsearcheditor.cpp # indra/llui/llview.cpp # indra/newview/llagent.cpp # indra/newview/llappviewer.cpp # indra/newview/llfloatercamera.cpp # indra/newview/llfloatereditsky.cpp # indra/newview/llfloatereditwater.cpp # indra/newview/llinventoryfunctions.cpp # indra/newview/lloutfitgallery.cpp # indra/newview/lloutfitslist.cpp # indra/newview/llpanelgroupbulkban.cpp # indra/newview/llsidepanelappearance.cpp # indra/newview/llvovolume.cpp
Diffstat (limited to 'indra/llui/llnotifications.cpp')
-rw-r--r--indra/llui/llnotifications.cpp58
1 files changed, 30 insertions, 28 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index 8185f2d597..9ba8e9e645 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -45,7 +45,6 @@
#include <algorithm>
#include <boost/regex.hpp>
-#include <boost/foreach.hpp>
const std::string NOTIFICATION_PERSIST_VERSION = "0.93";
@@ -444,14 +443,14 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par
mSoundName = p.sound;
}
- BOOST_FOREACH(const LLNotificationTemplate::UniquenessContext& context, p.unique.contexts)
+ for (const LLNotificationTemplate::UniquenessContext& context : p.unique.contexts)
{
mUniqueContext.push_back(context.value);
}
LL_DEBUGS("Notifications") << "notification \"" << mName << "\": tag count is " << p.tags.size() << LL_ENDL;
- BOOST_FOREACH(const LLNotificationTemplate::Tag& tag, p.tags)
+ for (const LLNotificationTemplate::Tag& tag : p.tags)
{
LL_DEBUGS("Notifications") << " tag \"" << std::string(tag.value) << "\"" << LL_ENDL;
mTags.push_back(tag.value);
@@ -994,6 +993,7 @@ LLBoundListener LLNotificationChannelBase::connectChangedImpl(const LLEventListe
// all of the notifications that are already in the channel
// we use a special signal called "load" in case the channel wants to care
// only about new notifications
+ LLMutexLock lock(&mItemsMutex);
for (LLNotificationSet::iterator it = mItems.begin(); it != mItems.end(); ++it)
{
slot(LLSD().with("sigtype", "load").with("id", (*it)->id()));
@@ -1153,7 +1153,7 @@ LLNotificationChannel::LLNotificationChannel(const Params& p)
LLInstanceTracker<LLNotificationChannel, std::string>(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString()),
mName(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString())
{
- BOOST_FOREACH(const std::string& source, p.sources)
+ for (const std::string& source : p.sources)
{
connectToChannel(source);
}
@@ -1171,29 +1171,33 @@ LLNotificationChannel::LLNotificationChannel(const std::string& name,
connectToChannel(parent);
}
-bool LLNotificationChannel::isEmpty() const
+LLNotificationChannel::~LLNotificationChannel()
{
- return mItems.empty();
+ for (LLBoundListener &listener : mListeners)
+ {
+ listener.disconnect();
+ }
}
-S32 LLNotificationChannel::size() const
+bool LLNotificationChannel::isEmpty() const
{
- return mItems.size();
+ return mItems.empty();
}
-LLNotificationChannel::Iterator LLNotificationChannel::begin()
+S32 LLNotificationChannel::size() const
{
- return mItems.begin();
+ return mItems.size();
}
-LLNotificationChannel::Iterator LLNotificationChannel::end()
+size_t LLNotificationChannel::size()
{
- return mItems.end();
+ return mItems.size();
}
-size_t LLNotificationChannel::size()
+void LLNotificationChannel::forEachNotification(NotificationProcess process)
{
- return mItems.size();
+ LLMutexLock lock(&mItemsMutex);
+ std::for_each(mItems.begin(), mItems.end(), process);
}
std::string LLNotificationChannel::summarize()
@@ -1201,7 +1205,8 @@ std::string LLNotificationChannel::summarize()
std::string s("Channel '");
s += mName;
s += "'\n ";
- for (LLNotificationChannel::Iterator it = begin(); it != end(); ++it)
+ LLMutexLock lock(&mItemsMutex);
+ for (LLNotificationChannel::Iterator it = mItems.begin(); it != mItems.end(); ++it)
{
s += (*it)->summarize();
s += "\n ";
@@ -1213,14 +1218,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)));
}
}
@@ -1521,7 +1526,7 @@ void replaceFormText(LLNotificationForm::Params& form, const std::string& patter
form.ignore.text = replace;
}
- BOOST_FOREACH(LLNotificationForm::FormElement& element, form.form_elements.elements)
+ for (LLNotificationForm::FormElement& element : form.form_elements.elements)
{
if (element.button.isChosen() && element.button.text() == pattern)
{
@@ -1571,19 +1576,19 @@ bool LLNotifications::loadTemplates()
mTemplates.clear();
- BOOST_FOREACH(LLNotificationTemplate::GlobalString& string, params.strings)
+ for (const LLNotificationTemplate::GlobalString& string : params.strings)
{
mGlobalStrings[string.name] = string.value;
}
std::map<std::string, LLNotificationForm::Params> form_templates;
- BOOST_FOREACH(LLNotificationTemplate::Template& notification_template, params.templates)
+ for (const LLNotificationTemplate::Template& notification_template : params.templates)
{
form_templates[notification_template.name] = notification_template.form;
}
- BOOST_FOREACH(LLNotificationTemplate::Params& notification, params.notifications)
+ for (LLNotificationTemplate::Params& notification : params.notifications)
{
if (notification.form_ref.form_template.isChosen())
{
@@ -1638,7 +1643,7 @@ bool LLNotifications::loadVisibilityRules()
mVisibilityRules.clear();
- BOOST_FOREACH(LLNotificationVisibilityRule::Rule& rule, params.rules)
+ for (const LLNotificationVisibilityRule::Rule& rule : params.rules)
{
mVisibilityRules.push_back(LLNotificationVisibilityRulePtr(new LLNotificationVisibilityRule(rule)));
}
@@ -1731,6 +1736,7 @@ void LLNotifications::cancel(LLNotificationPtr pNotif)
void LLNotifications::cancelByName(const std::string& name)
{
+ LLMutexLock lock(&mItemsMutex);
std::vector<LLNotificationPtr> notifs_to_cancel;
for (LLNotificationSet::iterator it=mItems.begin(), end_it = mItems.end();
it != end_it;
@@ -1755,6 +1761,7 @@ void LLNotifications::cancelByName(const std::string& name)
void LLNotifications::cancelByOwner(const LLUUID ownerId)
{
+ LLMutexLock lock(&mItemsMutex);
std::vector<LLNotificationPtr> notifs_to_cancel;
for (LLNotificationSet::iterator it = mItems.begin(), end_it = mItems.end();
it != end_it;
@@ -1802,11 +1809,6 @@ LLNotificationPtr LLNotifications::find(LLUUID uuid)
}
}
-void LLNotifications::forEachNotification(NotificationProcess process)
-{
- std::for_each(mItems.begin(), mItems.end(), process);
-}
-
std::string LLNotifications::getGlobalString(const std::string& key) const
{
GlobalStringMap::const_iterator it = mGlobalStrings.find(key);