From 3c552696bf8704e30c1525a4f9d4b3dd09034820 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 12 Aug 2019 22:56:15 +0300 Subject: DRTVWR-493 LLWearableType to LLParamSingleton --- indra/llappearance/llwearabletype.cpp | 37 ++++++++++++++++++++++------------- indra/llappearance/llwearabletype.h | 18 ++++++++++------- 2 files changed, 34 insertions(+), 21 deletions(-) (limited to 'indra/llappearance') 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, +class LLWearableDictionary : public LLParamSingleton, public LLDictionary { 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 { + 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 -- cgit v1.2.3 From b52f8573e454287556e00c1eda4765073e203308 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 13 Nov 2019 16:17:16 +0200 Subject: SL-12272 Ordered Shutdown log spam --- indra/llappearance/llwearabletype.cpp | 17 ++++++++--------- indra/llappearance/llwearabletype.h | 1 - 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'indra/llappearance') diff --git a/indra/llappearance/llwearabletype.cpp b/indra/llappearance/llwearabletype.cpp index 6b7dc41ffd..dc02b5e225 100644 --- a/indra/llappearance/llwearabletype.cpp +++ b/indra/llappearance/llwearabletype.cpp @@ -56,7 +56,7 @@ struct WearableEntry : public LLDictionaryEntry BOOL mAllowMultiwear; }; -class LLWearableDictionary : public LLParamSingleton, +class LLWearableDictionary : public LLSingleton, public LLDictionary { LLSINGLETON(LLWearableDictionary); @@ -64,6 +64,12 @@ class LLWearableDictionary : public LLParamSingleton, LLWearableDictionary::LLWearableDictionary() { + if (!LLWearableType::instanceExists()) + { + // LLWearableType is effectively a wrapper around LLWearableDictionary and is used as storage for LLTranslationBridge + // Todo: consider merging LLWearableType and LLWearableDictionary + LL_WARNS() << "Initing LLWearableDictionary without LLWearableType" << LL_ENDL; + } addEntry(LLWearableType::WT_SHAPE, new WearableEntry("shape", "New Shape", LLAssetType::AT_BODYPART, LLInventoryType::ICONNAME_BODYPART_SHAPE, FALSE, FALSE)); addEntry(LLWearableType::WT_SKIN, new WearableEntry("skin", "New Skin", LLAssetType::AT_BODYPART, LLInventoryType::ICONNAME_BODYPART_SKIN, FALSE, FALSE)); addEntry(LLWearableType::WT_HAIR, new WearableEntry("hair", "New Hair", LLAssetType::AT_BODYPART, LLInventoryType::ICONNAME_BODYPART_HAIR, FALSE, FALSE)); @@ -92,6 +98,7 @@ LLWearableDictionary::LLWearableDictionary() LLWearableType::LLWearableType(LLTranslationBridge* trans) { + // LLTranslationBridge exists, but is not ready at this point in time since strings.xml is not yet loaded mTrans = trans; } @@ -100,14 +107,6 @@ 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 80bb9a10b4..5fe969822a 100644 --- a/indra/llappearance/llwearabletype.h +++ b/indra/llappearance/llwearabletype.h @@ -47,7 +47,6 @@ class LLWearableType : public LLParamSingleton LLSINGLETON(LLWearableType, LLTranslationBridge* trans); ~LLWearableType(); friend struct WearableEntry; - void initSingleton(); public: enum EType { -- cgit v1.2.3