From 969a6f9be2eadcdc93fec3ace3be06a8cdbc509d Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Tue, 21 Jun 2011 15:02:34 -0700 Subject: Fix for memory leak & extra inventory observers in start_new_inventory_observer. Reviewed by Richard --- indra/newview/llviewermessage.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 7ab335314a..b840991bbc 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -936,7 +936,6 @@ protected: //one global instance to bind them LLOpenTaskOffer* gNewInventoryObserver=NULL; - class LLNewInventoryHintObserver : public LLInventoryAddedObserver { protected: @@ -946,6 +945,8 @@ protected: } }; +LLNewInventoryHintObserver* gNewInventoryHintObserver=NULL; + void start_new_inventory_observer() { if (!gNewInventoryObserver) //task offer observer @@ -962,7 +963,12 @@ void start_new_inventory_observer() gInventory.addObserver(gInventoryMoveObserver); } - gInventory.addObserver(new LLNewInventoryHintObserver()); + if (!gNewInventoryHintObserver) + { + // Observer is deleted by gInventory + gNewInventoryHintObserver = new LLNewInventoryHintObserver(); + gInventory.addObserver(gNewInventoryHintObserver); + } } class LLDiscardAgentOffer : public LLInventoryFetchItemsObserver -- cgit v1.2.3