diff options
author | Alexei Arabadji <aarabadji@productengine.com> | 2010-07-12 16:34:38 +0300 |
---|---|---|
committer | Alexei Arabadji <aarabadji@productengine.com> | 2010-07-12 16:34:38 +0300 |
commit | 4f6badf216144a37dc86c578d832c3a8f84df73e (patch) | |
tree | 0b992045609122e983ab2f51e3bc7cbaf9fa49b5 | |
parent | 50e6e5e49b252b38e48c2020a98e19215a74ca55 (diff) |
EXT-8124 FIXED Avoided saving processed notifications that spawns script floater.
Details:
1 Avoided memory leak in LLScriptFloaterManager caused not destroying processed notifications.
2 Provided destroying notification if user initiate closing script floater and not destroying if viewer exit.
reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/721/
--HG--
branch : product-engine
-rw-r--r-- | indra/newview/llchiclet.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llscriptfloater.cpp | 27 | ||||
-rw-r--r-- | indra/newview/llscriptfloater.h | 5 | ||||
-rw-r--r-- | indra/newview/llsyswellwindow.cpp | 4 |
4 files changed, 32 insertions, 8 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index 6897f4ee8e..2826899cb0 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -1886,7 +1886,7 @@ void LLScriptChiclet::onMenuItemClicked(const LLSD& user_data) if("end" == action) { - LLScriptFloaterManager::instance().onRemoveNotification(getSessionId()); + LLScriptFloaterManager::instance().removeNotification(getSessionId()); } } @@ -1969,7 +1969,7 @@ void LLInvOfferChiclet::onMenuItemClicked(const LLSD& user_data) if("end" == action) { - LLScriptFloaterManager::instance().onRemoveNotification(getSessionId()); + LLScriptFloaterManager::instance().removeNotification(getSessionId()); } } diff --git a/indra/newview/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp index b68fc3b002..75797dae81 100644 --- a/indra/newview/llscriptfloater.cpp +++ b/indra/newview/llscriptfloater.cpp @@ -176,7 +176,15 @@ void LLScriptFloater::onClose(bool app_quitting) if(getNotificationId().notNull()) { - LLScriptFloaterManager::getInstance()->onRemoveNotification(getNotificationId()); + // we shouldn't kill notification on exit since it may be used as persistent. + if (app_quitting) + { + LLScriptFloaterManager::getInstance()->onRemoveNotification(getNotificationId()); + } + else + { + LLScriptFloaterManager::getInstance()->removeNotification(getNotificationId()); + } } } @@ -352,7 +360,7 @@ void LLScriptFloaterManager::onAddNotification(const LLUUID& notification_id) set_new_message |= !floater->hasFocus(); } - onRemoveNotification(it->first); + removeNotification(it->first); } } @@ -379,6 +387,17 @@ void LLScriptFloaterManager::onAddNotification(const LLUUID& notification_id) toggleScriptFloater(notification_id, set_new_message); } +void LLScriptFloaterManager::removeNotification(const LLUUID& notification_id) +{ + LLNotificationPtr notification = LLNotifications::instance().find(notification_id); + if (notification != NULL && !notification->isCancelled()) + { + LLNotificationsUtil::cancel(notification); + } + + onRemoveNotification(notification_id); +} + void LLScriptFloaterManager::onRemoveNotification(const LLUUID& notification_id) { if(notification_id.isNull()) @@ -392,6 +411,8 @@ void LLScriptFloaterManager::onRemoveNotification(const LLUUID& notification_id) LLIMWellWindow::getInstance()->removeObjectRow(notification_id); + mNotifications.erase(notification_id); + // close floater LLScriptFloater* floater = LLFloaterReg::findTypedInstance<LLScriptFloater>("script_floater", notification_id); if(floater) @@ -400,8 +421,6 @@ void LLScriptFloaterManager::onRemoveNotification(const LLUUID& notification_id) floater->setNotificationId(LLUUID::null); floater->closeFloater(); } - - mNotifications.erase(notification_id); } void LLScriptFloaterManager::toggleScriptFloater(const LLUUID& notification_id, bool set_new_message) diff --git a/indra/newview/llscriptfloater.h b/indra/newview/llscriptfloater.h index dc0cfc2400..6990234fd7 100644 --- a/indra/newview/llscriptfloater.h +++ b/indra/newview/llscriptfloater.h @@ -65,6 +65,11 @@ public: void onAddNotification(const LLUUID& notification_id); /** + * Removes notification. + */ + void removeNotification(const LLUUID& notification_id); + + /** * Handles notification removal. * Removes script notification toast, removes script chiclet, closes script floater */ diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp index e6b4aeb6c2..1a8c2b8fc0 100644 --- a/indra/newview/llsyswellwindow.cpp +++ b/indra/newview/llsyswellwindow.cpp @@ -371,7 +371,7 @@ LLIMWellWindow::ObjectRowPanel::~ObjectRowPanel() //--------------------------------------------------------------------------------- void LLIMWellWindow::ObjectRowPanel::onClosePanel() { - LLScriptFloaterManager::getInstance()->onRemoveNotification(mChiclet->getSessionId()); + LLScriptFloaterManager::getInstance()->removeNotification(mChiclet->getSessionId()); } void LLIMWellWindow::ObjectRowPanel::initChiclet(const LLUUID& notification_id, bool new_message/* = false*/) @@ -832,7 +832,7 @@ void LLIMWellWindow::closeAllImpl() ObjectRowPanel* obj_panel = dynamic_cast <ObjectRowPanel*> (panel); if (obj_panel) { - LLScriptFloaterManager::instance().onRemoveNotification(*iter); + LLScriptFloaterManager::instance().removeNotification(*iter); } } } |