From c538254fbd77df962b627460d863911aa2196988 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 8 Oct 2026 06:47:32 -0500 Subject: Do not recreate destroyed singletons during shutdown (#31) deleteAll() used to let getInstance() build a replacement, which crashed when the script-editor server posted a toast after LLUI was gone. Shutdown now refuses that construction, and notification adds do nothing once the notification system is gone. --- indra/llui/llnotificationsutil.cpp | 62 +++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 7 deletions(-) (limited to 'indra/llui/llnotificationsutil.cpp') diff --git a/indra/llui/llnotificationsutil.cpp b/indra/llui/llnotificationsutil.cpp index 6b570d043f..ce36f33bf9 100644 --- a/indra/llui/llnotificationsutil.cpp +++ b/indra/llui/llnotificationsutil.cpp @@ -30,20 +30,44 @@ #include "llsd.h" #include "llxmlnode.h" // apparently needed to call LLNotifications::instance() +namespace +{ + // deleteAll() must not resurrect LLNotifications after its dependencies + // are gone. A null return means the caller should skip the toast. + LLNotifications* live_notifications() + { + if (LLNotifications::wasDeleted() || LLSingletonBase::shuttingDown()) + { + return nullptr; + } + return LLNotifications::getInstance(); + } +} + LLNotificationPtr LLNotificationsUtil::add(const std::string& name) { + LLNotifications* notifications = live_notifications(); + if (!notifications) + { + return LLNotificationPtr(); + } LLNotification::Params::Functor functor_p; functor_p.name = name; - return LLNotifications::instance().add( + return notifications->add( LLNotification::Params().name(name).substitutions(LLSD()).payload(LLSD()).functor(functor_p)); } LLNotificationPtr LLNotificationsUtil::add(const std::string& name, const LLSD& substitutions) { + LLNotifications* notifications = live_notifications(); + if (!notifications) + { + return LLNotificationPtr(); + } LLNotification::Params::Functor functor_p; functor_p.name = name; - return LLNotifications::instance().add( + return notifications->add( LLNotification::Params().name(name).substitutions(substitutions).payload(LLSD()).functor(functor_p)); } @@ -51,9 +75,14 @@ LLNotificationPtr LLNotificationsUtil::add(const std::string& name, const LLSD& substitutions, const LLSD& payload) { + LLNotifications* notifications = live_notifications(); + if (!notifications) + { + return LLNotificationPtr(); + } LLNotification::Params::Functor functor_p; functor_p.name = name; - return LLNotifications::instance().add( + return notifications->add( LLNotification::Params().name(name).substitutions(substitutions).payload(payload).functor(functor_p)); } @@ -62,9 +91,14 @@ LLNotificationPtr LLNotificationsUtil::add(const std::string& name, const LLSD& payload, const std::string& functor_name) { + LLNotifications* notifications = live_notifications(); + if (!notifications) + { + return LLNotificationPtr(); + } LLNotification::Params::Functor functor_p; functor_p.name = functor_name; - return LLNotifications::instance().add( + return notifications->add( LLNotification::Params().name(name).substitutions(substitutions).payload(payload).functor(functor_p)); } @@ -73,9 +107,14 @@ LLNotificationPtr LLNotificationsUtil::add(const std::string& name, const LLSD& payload, std::function functor) { + LLNotifications* notifications = live_notifications(); + if (!notifications) + { + return LLNotificationPtr(); + } LLNotification::Params::Functor functor_p; functor_p.function = functor; - return LLNotifications::instance().add( + return notifications->add( LLNotification::Params().name(name).substitutions(substitutions).payload(payload).functor(functor_p)); } @@ -86,10 +125,19 @@ S32 LLNotificationsUtil::getSelectedOption(const LLSD& notification, const LLSD& void LLNotificationsUtil::cancel(LLNotificationPtr pNotif) { - LLNotifications::instance().cancel(pNotif); + LLNotifications* notifications = live_notifications(); + if (notifications) + { + notifications->cancel(pNotif); + } } LLNotificationPtr LLNotificationsUtil::find(LLUUID uuid) { - return LLNotifications::instance().find(uuid); + LLNotifications* notifications = live_notifications(); + if (!notifications) + { + return LLNotificationPtr(); + } + return notifications->find(uuid); } -- cgit v1.3