diff options
author | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
commit | 2a4dea528f670b9bb1f77ef27a8a1dd16603d114 (patch) | |
tree | 95c68e362703c9099d571ecbdc6142b1cda1e005 /linden/indra/newview/llfloaterproperties.cpp | |
parent | Second Life viewer sources 1.20.6 (diff) | |
download | meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.zip meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.gz meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.bz2 meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.xz |
Second Life viewer sources 1.20.7
Diffstat (limited to 'linden/indra/newview/llfloaterproperties.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterproperties.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/linden/indra/newview/llfloaterproperties.cpp b/linden/indra/newview/llfloaterproperties.cpp index 0d2cd5f..48232cb 100644 --- a/linden/indra/newview/llfloaterproperties.cpp +++ b/linden/indra/newview/llfloaterproperties.cpp | |||
@@ -65,11 +65,21 @@ | |||
65 | // helper class to watch the inventory. | 65 | // helper class to watch the inventory. |
66 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 66 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
67 | 67 | ||
68 | class LLPropertiesObserver : public LLInventoryObserver, public LLSingleton<LLPropertiesObserver> | 68 | // Ugh. This can't be a singleton because it needs to remove itself |
69 | // from the inventory observer list when destroyed, which could | ||
70 | // happen after gInventory has already been destroyed if a singleton. | ||
71 | // Instead, do our own ref counting and create / destroy it as needed | ||
72 | class LLPropertiesObserver : public LLInventoryObserver | ||
69 | { | 73 | { |
70 | public: | 74 | public: |
71 | LLPropertiesObserver() {} | 75 | LLPropertiesObserver() |
72 | virtual ~LLPropertiesObserver() {} | 76 | { |
77 | gInventory.addObserver(this); | ||
78 | } | ||
79 | virtual ~LLPropertiesObserver() | ||
80 | { | ||
81 | gInventory.removeObserver(this); | ||
82 | } | ||
73 | virtual void changed(U32 mask); | 83 | virtual void changed(U32 mask); |
74 | }; | 84 | }; |
75 | 85 | ||
@@ -88,7 +98,10 @@ void LLPropertiesObserver::changed(U32 mask) | |||
88 | /// Class LLFloaterProperties | 98 | /// Class LLFloaterProperties |
89 | ///---------------------------------------------------------------------------- | 99 | ///---------------------------------------------------------------------------- |
90 | 100 | ||
101 | // static | ||
91 | LLFloaterProperties::instance_map LLFloaterProperties::sInstances; | 102 | LLFloaterProperties::instance_map LLFloaterProperties::sInstances; |
103 | LLPropertiesObserver* LLFloaterProperties::sPropertiesObserver = NULL; | ||
104 | S32 LLFloaterProperties::sPropertiesObserverCount = 0; | ||
92 | 105 | ||
93 | // static | 106 | // static |
94 | LLFloaterProperties* LLFloaterProperties::find(const LLUUID& item_id, | 107 | LLFloaterProperties* LLFloaterProperties::find(const LLUUID& item_id, |
@@ -145,12 +158,12 @@ LLFloaterProperties::LLFloaterProperties(const std::string& name, const LLRect& | |||
145 | { | 158 | { |
146 | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_inventory_item_properties.xml"); | 159 | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_inventory_item_properties.xml"); |
147 | 160 | ||
148 | // hack to make sure these floaters are observing the inventory. | 161 | if (!sPropertiesObserver) |
149 | if(!gInventory.containsObserver(LLPropertiesObserver::getInstance())) | ||
150 | { | 162 | { |
151 | // Note: this is where gPropertiesObserver used to be constructed. | 163 | sPropertiesObserver = new LLPropertiesObserver; |
152 | gInventory.addObserver(LLPropertiesObserver::getInstance()); | ||
153 | } | 164 | } |
165 | sPropertiesObserverCount++; | ||
166 | |||
154 | // add the object to the static structure | 167 | // add the object to the static structure |
155 | LLUUID key = mItemID ^ mObjectID; | 168 | LLUUID key = mItemID ^ mObjectID; |
156 | sInstances.insert(instance_map::value_type(key, this)); | 169 | sInstances.insert(instance_map::value_type(key, this)); |
@@ -193,6 +206,12 @@ LLFloaterProperties::~LLFloaterProperties() | |||
193 | { | 206 | { |
194 | sInstances.erase(it); | 207 | sInstances.erase(it); |
195 | } | 208 | } |
209 | sPropertiesObserverCount--; | ||
210 | if (!sPropertiesObserverCount) | ||
211 | { | ||
212 | delete sPropertiesObserver; | ||
213 | sPropertiesObserver = NULL; | ||
214 | } | ||
196 | } | 215 | } |
197 | 216 | ||
198 | void LLFloaterProperties::refresh() | 217 | void LLFloaterProperties::refresh() |
@@ -422,7 +441,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item) | |||
422 | 441 | ||
423 | perm_string = "G"; | 442 | perm_string = "G"; |
424 | perm_string += overwrite_group ? "*: " : ": "; | 443 | perm_string += overwrite_group ? "*: " : ": "; |
425 | perm_string += perm_string += mask_to_string(group_mask); | 444 | perm_string += mask_to_string(group_mask); |
426 | childSetText("GroupMaskDebug",perm_string); | 445 | childSetText("GroupMaskDebug",perm_string); |
427 | childSetVisible("GroupMaskDebug",TRUE); | 446 | childSetVisible("GroupMaskDebug",TRUE); |
428 | 447 | ||