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.cpp64
1 files changed, 51 insertions, 13 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index cd80e7f63f..56475a2d8d 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -457,7 +457,7 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par
mTags.push_back(tag.value);
}
- mForm = LLNotificationFormPtr(new LLNotificationForm(p.name, p.form_ref.form));
+ mForm = std::make_shared<LLNotificationForm>(p.name, p.form_ref.form);
}
LLNotificationVisibilityRule::LLNotificationVisibilityRule(const LLNotificationVisibilityRule::Rule &p)
@@ -614,6 +614,13 @@ void LLNotification::cancel()
LLSD LLNotification::getResponseTemplate(EResponseTemplateType type)
{
LLSD response = LLSD::emptyMap();
+
+ if (!mForm)
+ {
+ LL_WARNS("Notifications") << "Null form when getting response template for notification " << getName() << LL_ENDL;
+ return response;
+ }
+
for (S32 element_idx = 0;
element_idx < mForm->getNumElements();
++element_idx)
@@ -868,7 +875,7 @@ void LLNotification::init(const std::string& template_name, const LLSD& form_ele
// TODO: something like this so that a missing alert is sensible:
//mSubstitutions["_ARGS"] = get_all_arguments_as_text(mSubstitutions);
- mForm = LLNotificationFormPtr(new LLNotificationForm(*mTemplatep->mForm));
+ mForm = std::make_shared<LLNotificationForm>(*mTemplatep->mForm);
mForm->append(form_elements);
// apply substitution to form labels
@@ -1242,16 +1249,33 @@ LLNotifications::LLNotifications()
: LLNotificationChannelBase(LLNotificationFilters::includeEverything),
mIgnoreAllNotifications(false)
{
- mListener.reset(new LLNotificationsListener(*this));
+ mListener = std::make_unique<LLNotificationsListener>(*this);
LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Notification.Show", boost::bind(&LLNotifications::addFromCallback, this, _2));
// touch the instance tracker for notification channels, so that it will still be around in our destructor
LLInstanceTracker<LLNotificationChannel, std::string>::instanceCount();
}
+
+LLNotifications::~LLNotifications()
+{
+ // Clear explicitly, something in ~LLNotifications() crashes so narrowing down suspects
+ pHistoryChannel = nullptr;
+ pExpirationChannel = nullptr;
+ mGlobalStrings.clear();
+ mTemplates.clear();
+ mVisibilityRules.clear();
+ mUniqueNotifications.clear();
+ mListener = nullptr;
+}
+
void LLNotifications::clear()
{
- mDefaultChannels.clear();
+ mDefaultChannels.clear();
+ // At this point mTemplates still gets used by lingering notifications
+ // to do responses (ex: group notice will call forceResponse()), but
+ // since network should be down and everything save, it's questionable
+ // whether it should stay that way
}
// The expiration channel gets all notifications that are cancelled
@@ -1400,6 +1424,7 @@ LLNotificationChannelPtr LLNotifications::getChannel(const std::string& channelN
// this function is called once at construction time, after the object is constructed.
void LLNotifications::initSingleton()
{
+ LL_PROFILE_ZONE_SCOPED;
loadTemplates();
loadVisibilityRules();
createDefaultChannels();
@@ -1412,6 +1437,8 @@ void LLNotifications::cleanupSingleton()
void LLNotifications::createDefaultChannels()
{
+ LL_PROFILE_ZONE_SCOPED;
+
LL_INFOS("Notifications") << "Generating default notification channels" << LL_ENDL;
// now construct the various channels AFTER loading the notifications,
// because the history channel is going to rewrite the stored notifications file
@@ -1463,7 +1490,14 @@ bool LLNotifications::templateExists(std::string_view name)
void LLNotifications::forceResponse(const LLNotification::Params& params, S32 option)
{
- LLNotificationPtr temp_notify(new LLNotification(params));
+ LLNotificationPtr temp_notify = std::make_shared<LLNotification>(params);
+
+ if (!temp_notify->getForm())
+ {
+ LL_WARNS("Notifications") << "Cannot force response for notification with null form: " << (std::string)params.name << LL_ENDL;
+ return;
+ }
+
LLSD response = temp_notify->getResponseTemplate();
LLSD selected_item = temp_notify->getForm()->getElement(option);
@@ -1547,6 +1581,8 @@ void addPathIfExists(const std::string& new_path, std::vector<std::string>& path
bool LLNotifications::loadTemplates()
{
+ LL_PROFILE_ZONE_SCOPED;
+
LL_INFOS("Notifications") << "Reading notifications template" << LL_ENDL;
// Passing findSkinnedFilenames(constraint=LLDir::ALL_SKINS) makes it
// output all relevant pathnames instead of just the ones from the most
@@ -1555,7 +1591,7 @@ bool LLNotifications::loadTemplates()
gDirUtilp->findSkinnedFilenames(LLDir::XUI, "notifications.xml", LLDir::ALL_SKINS);
if (search_paths.empty())
{
- LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"), LLError::LLUserWarningMsg::ERROR_MISSING_FILES);
LL_ERRS() << "Problem finding notifications.xml" << LL_ENDL;
}
@@ -1565,7 +1601,7 @@ bool LLNotifications::loadTemplates()
if (!success || root.isNull() || !root->hasName( "notifications" ))
{
- LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"), LLError::LLUserWarningMsg::ERROR_MISSING_FILES);
LL_ERRS() << "Problem reading XML from UI Notifications file: " << base_filename << LL_ENDL;
return false;
}
@@ -1576,7 +1612,7 @@ bool LLNotifications::loadTemplates()
if(!params.validateBlock())
{
- LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"), LLError::LLUserWarningMsg::ERROR_MISSING_FILES);
LL_ERRS() << "Problem reading XUI from UI Notifications file: " << base_filename << LL_ENDL;
return false;
}
@@ -1622,7 +1658,7 @@ bool LLNotifications::loadTemplates()
replaceFormText(notification.form_ref.form, "$ignoretext", notification.form_ref.form_template.ignore_text);
}
}
- mTemplates[notification.name] = LLNotificationTemplatePtr(new LLNotificationTemplate(notification));
+ mTemplates[notification.name] = std::make_shared<LLNotificationTemplate>(notification);
}
LL_INFOS("Notifications") << "...done" << LL_ENDL;
@@ -1632,6 +1668,8 @@ bool LLNotifications::loadTemplates()
bool LLNotifications::loadVisibilityRules()
{
+ LL_PROFILE_ZONE_SCOPED;
+
const std::string xml_filename = "notification_visibility.xml";
// Note that here we're looking for the "en" version, the default
// language, rather than the most localized version of this file.
@@ -1643,7 +1681,7 @@ bool LLNotifications::loadVisibilityRules()
if(!params.validateBlock())
{
- LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"), LLError::LLUserWarningMsg::ERROR_MISSING_FILES);
LL_ERRS() << "Problem reading UI Notification Visibility Rules file: " << full_filename << LL_ENDL;
return false;
}
@@ -1652,7 +1690,7 @@ bool LLNotifications::loadVisibilityRules()
for (const LLNotificationVisibilityRule::Rule& rule : params.rules)
{
- mVisibilityRules.push_back(LLNotificationVisibilityRulePtr(new LLNotificationVisibilityRule(rule)));
+ mVisibilityRules.push_back(std::make_shared<LLNotificationVisibilityRule>(rule));
}
return true;
@@ -1695,7 +1733,7 @@ LLNotificationPtr LLNotifications::add(const std::string& name, const LLSD& subs
// generalized add function that takes a parameter block object for more complex instantiations
LLNotificationPtr LLNotifications::add(const LLNotification::Params& p)
{
- LLNotificationPtr pNotif(new LLNotification(p));
+ LLNotificationPtr pNotif = std::make_shared<LLNotification>(p);
add(pNotif);
return pNotif;
}
@@ -1803,7 +1841,7 @@ void LLNotifications::update(const LLNotificationPtr pNotif)
LLNotificationPtr LLNotifications::find(LLUUID uuid)
{
- LLNotificationPtr target = LLNotificationPtr(new LLNotification(LLNotification::Params().id(uuid)));
+ LLNotificationPtr target = std::make_shared<LLNotification>(LLNotification::Params().id(uuid));
LLNotificationSet::iterator it=mItems.find(target);
if (it == mItems.end())
{