summaryrefslogtreecommitdiff
path: root/indra/llui/llnotifications.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llnotifications.cpp')
-rw-r--r--indra/llui/llnotifications.cpp61
1 files changed, 33 insertions, 28 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index d736aa6634..907408f309 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)
{
@@ -1553,6 +1558,7 @@ bool LLNotifications::loadTemplates()
if (!success || root.isNull() || !root->hasName( "notifications" ))
{
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
LL_ERRS() << "Problem reading XML from UI Notifications file: " << base_filename << LL_ENDL;
return false;
}
@@ -1563,25 +1569,26 @@ bool LLNotifications::loadTemplates()
if(!params.validateBlock())
{
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
LL_ERRS() << "Problem reading XUI from UI Notifications file: " << base_filename << LL_ENDL;
return false;
}
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())
{
@@ -1629,13 +1636,14 @@ bool LLNotifications::loadVisibilityRules()
if(!params.validateBlock())
{
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
LL_ERRS() << "Problem reading UI Notification Visibility Rules file: " << full_filename << LL_ENDL;
return false;
}
mVisibilityRules.clear();
- BOOST_FOREACH(LLNotificationVisibilityRule::Rule& rule, params.rules)
+ for (const LLNotificationVisibilityRule::Rule& rule : params.rules)
{
mVisibilityRules.push_back(LLNotificationVisibilityRulePtr(new LLNotificationVisibilityRule(rule)));
}
@@ -1728,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;
@@ -1752,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;
@@ -1799,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);