summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterproperties.cpp
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2008-05-09 20:57:23 +0000
committerSteven Bennetts <steve@lindenlab.com>2008-05-09 20:57:23 +0000
commit783e05058c5d74984ab554fdc60aa06839b9b5c9 (patch)
treeb40ca6762c7546b65db3966c04ef545a23643f21 /indra/newview/llfloaterproperties.cpp
parentdbe0176552e070baef9a693252cb47dda97d1fb4 (diff)
QAR-537 Viewer 1.20 RC 6
merge -r 86279:86925 Branch_1-20-Viewer -> release
Diffstat (limited to 'indra/newview/llfloaterproperties.cpp')
-rw-r--r--indra/newview/llfloaterproperties.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/indra/newview/llfloaterproperties.cpp b/indra/newview/llfloaterproperties.cpp
index bea12fe017..74a880e010 100644
--- a/indra/newview/llfloaterproperties.cpp
+++ b/indra/newview/llfloaterproperties.cpp
@@ -65,11 +65,21 @@
// helper class to watch the inventory.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLPropertiesObserver : public LLInventoryObserver, public LLSingleton<LLPropertiesObserver>
+// Ugh. This can't be a singleton because it needs to remove itself
+// from the inventory observer list when destroyed, which could
+// happen after gInventory has already been destroyed if a singleton.
+// Instead, do our own ref counting and create / destroy it as needed
+class LLPropertiesObserver : public LLInventoryObserver
{
public:
- LLPropertiesObserver() {}
- virtual ~LLPropertiesObserver() {}
+ LLPropertiesObserver()
+ {
+ gInventory.addObserver(this);
+ }
+ virtual ~LLPropertiesObserver()
+ {
+ gInventory.removeObserver(this);
+ }
virtual void changed(U32 mask);
};
@@ -88,7 +98,10 @@ void LLPropertiesObserver::changed(U32 mask)
/// Class LLFloaterProperties
///----------------------------------------------------------------------------
+// static
LLFloaterProperties::instance_map LLFloaterProperties::sInstances;
+LLPropertiesObserver* LLFloaterProperties::sPropertiesObserver = NULL;
+S32 LLFloaterProperties::sPropertiesObserverCount = 0;
// static
LLFloaterProperties* LLFloaterProperties::find(const LLUUID& item_id,
@@ -145,12 +158,12 @@ LLFloaterProperties::LLFloaterProperties(const std::string& name, const LLRect&
{
LLUICtrlFactory::getInstance()->buildFloater(this,"floater_inventory_item_properties.xml");
- // hack to make sure these floaters are observing the inventory.
- if(!gInventory.containsObserver(LLPropertiesObserver::getInstance()))
+ if (!sPropertiesObserver)
{
- // Note: this is where gPropertiesObserver used to be constructed.
- gInventory.addObserver(LLPropertiesObserver::getInstance());
+ sPropertiesObserver = new LLPropertiesObserver;
}
+ sPropertiesObserverCount++;
+
// add the object to the static structure
LLUUID key = mItemID ^ mObjectID;
sInstances.insert(instance_map::value_type(key, this));
@@ -193,6 +206,12 @@ LLFloaterProperties::~LLFloaterProperties()
{
sInstances.erase(it);
}
+ sPropertiesObserverCount--;
+ if (!sPropertiesObserverCount)
+ {
+ delete sPropertiesObserver;
+ sPropertiesObserver = NULL;
+ }
}
void LLFloaterProperties::refresh()