diff options
| -rw-r--r-- | indra/llappearance/llwearabletype.cpp | 37 | ||||
| -rw-r--r-- | indra/llappearance/llwearabletype.h | 18 | ||||
| -rw-r--r-- | indra/llcommon/llsingleton.h | 1 | ||||
| -rw-r--r-- | indra/newview/llappviewer.cpp | 4 | 
4 files changed, 36 insertions, 24 deletions
| diff --git a/indra/llappearance/llwearabletype.cpp b/indra/llappearance/llwearabletype.cpp index cd602b43b4..2dc4703399 100644 --- a/indra/llappearance/llwearabletype.cpp +++ b/indra/llappearance/llwearabletype.cpp @@ -29,18 +29,6 @@  #include "llinventorytype.h"  #include "llinventorydefines.h" -static LLTranslationBridge* sTrans = NULL; - -// static -void LLWearableType::initClass(LLTranslationBridge* trans) -{ -	sTrans = trans; -} - -void LLWearableType::cleanupClass() -{ -	delete sTrans; -}  struct WearableEntry : public LLDictionaryEntry  { @@ -53,7 +41,7 @@ struct WearableEntry : public LLDictionaryEntry  		LLDictionaryEntry(name),  		mAssetType(assetType),  		mDefaultNewName(default_new_name), -		mLabel(sTrans->getString(name)), +		mLabel(LLWearableType::getInstance()->mTrans->getString(name)),  		mIconName(iconName),  		mDisableCameraSwitch(disable_camera_switch),  		mAllowMultiwear(allow_multiwear) @@ -68,7 +56,7 @@ struct WearableEntry : public LLDictionaryEntry  	BOOL mAllowMultiwear;  }; -class LLWearableDictionary : public LLSingleton<LLWearableDictionary>, +class LLWearableDictionary : public LLParamSingleton<LLWearableDictionary>,  							 public LLDictionary<LLWearableType::EType, WearableEntry>  {  	LLSINGLETON(LLWearableDictionary); @@ -98,6 +86,27 @@ LLWearableDictionary::LLWearableDictionary()  	addEntry(LLWearableType::WT_NONE,      	  new WearableEntry("none",        "Invalid Wearable", 	LLAssetType::AT_NONE, 		LLInventoryType::ICONNAME_NONE, FALSE, FALSE));  } + +// class LLWearableType + +LLWearableType::LLWearableType(LLTranslationBridge* trans) +{ +    mTrans = trans; +} + +LLWearableType::~LLWearableType() +{ +    delete mTrans; +} + +void LLWearableType::initSingleton() +{ +    // To make sure all wrapping functions will crash without initing LLWearableType; +    LLWearableDictionary::initParamSingleton(); + +    // Todo: consider merging LLWearableType and LLWearableDictionary +} +  // static  LLWearableType::EType LLWearableType::typeNameToType(const std::string& type_name)  { diff --git a/indra/llappearance/llwearabletype.h b/indra/llappearance/llwearabletype.h index 519d5b92a2..fdb3dd79c1 100644 --- a/indra/llappearance/llwearabletype.h +++ b/indra/llappearance/llwearabletype.h @@ -42,8 +42,12 @@ public:  }; -class LLWearableType +class LLWearableType : public LLParamSingleton<LLWearableType>  { +	LLSINGLETON(LLWearableType, LLTranslationBridge* trans); +	~LLWearableType(); +	friend struct WearableEntry; +	void initSingleton();  public:   	enum EType  	{ @@ -69,9 +73,8 @@ public:  		WT_NONE		  = -1,  	}; -	static void			initClass(LLTranslationBridge* trans); // initializes static members -	static void			cleanupClass(); // initializes static members - +	// Most methods are wrappers for dictionary, but if LLWearableType is not initialized, +	// they will crash. Whole LLWearableType is just wrapper for convinient calls.  	static const std::string& 			getTypeName(EType type);  	static const std::string& 			getTypeDefaultNewName(EType type);  	static const std::string& 			getTypeLabel(EType type); @@ -80,11 +83,12 @@ public:  	static LLInventoryType::EIconName 	getIconName(EType type);  	static BOOL 						getDisableCameraSwitch(EType type);  	static BOOL 						getAllowMultiwear(EType type); -    static EType						inventoryFlagsToWearableType(U32 flags); + +	static EType						inventoryFlagsToWearableType(U32 flags);  protected: -	LLWearableType() {} -	~LLWearableType() {} + +	LLTranslationBridge* mTrans;  };  #endif  // LL_LLWEARABLETYPE_H diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 38d5af5309..9be02f7e7d 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -530,6 +530,7 @@ public:          else          {              super::constructSingleton(std::forward<Args>(args)...); +            lk.unlock();              super::finishInitializing();          }      } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index de70712627..84cd326f06 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -773,7 +773,7 @@ bool LLAppViewer::init()  	// initialize LLWearableType translation bridge.  	// Memory will be cleaned up in ::cleanupClass() -	LLWearableType::initClass(new LLUITranslationBridge()); +	LLWearableType::initParamSingleton(new LLUITranslationBridge());  	// initialize SSE options  	LLVector4a::initClass(); @@ -2085,8 +2085,6 @@ bool LLAppViewer::cleanup()  	SUBSYSTEM_CLEANUP(LLProxy);      LLCore::LLHttp::cleanup(); -	SUBSYSTEM_CLEANUP(LLWearableType); -  	LLMainLoopRepeater::instance().stop();  	ll_close_fail_log(); | 
