From 2b3c1bd40d11b02cb097cb3dba7a661a4b528a91 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 17 Jul 2013 08:23:42 -0400 Subject: CHOP-962: Make LLControlGroup::declare* return LLControlVariable* LLControlGroup::declareControl(), declareString() etc. etc. all used to return BOOL -- which no one ever examines because it unconditionally returned TRUE. Make it return the (possibly new) LLControlVariable* instead. --- indra/llxml/llcontrol.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'indra/llxml/llcontrol.h') diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index ee7d1d50b7..a7424c6780 100755 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -207,19 +207,19 @@ public: virtual void apply(const std::string& name, LLControlVariable* control) = 0; }; void applyToAll(ApplyFunctor* func); - - BOOL declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist, BOOL hidefromsettingseditor = FALSE); - BOOL declareU32(const std::string& name, U32 initial_val, const std::string& comment, BOOL persist = TRUE); - BOOL declareS32(const std::string& name, S32 initial_val, const std::string& comment, BOOL persist = TRUE); - BOOL declareF32(const std::string& name, F32 initial_val, const std::string& comment, BOOL persist = TRUE); - BOOL declareBOOL(const std::string& name, BOOL initial_val, const std::string& comment, BOOL persist = TRUE); - BOOL declareString(const std::string& name, const std::string &initial_val, const std::string& comment, BOOL persist = TRUE); - BOOL declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment, BOOL persist = TRUE); - BOOL declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, BOOL persist = TRUE); - BOOL declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, BOOL persist = TRUE); - BOOL declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, BOOL persist = TRUE); - BOOL declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, BOOL persist = TRUE); - BOOL declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, BOOL persist = TRUE); + + LLControlVariable* declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist, BOOL hidefromsettingseditor = FALSE); + LLControlVariable* declareU32(const std::string& name, U32 initial_val, const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareS32(const std::string& name, S32 initial_val, const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareF32(const std::string& name, F32 initial_val, const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareBOOL(const std::string& name, BOOL initial_val, const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareString(const std::string& name, const std::string &initial_val, const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, BOOL persist = TRUE); std::string getString(const std::string& name); std::string getText(const std::string& name); -- cgit v1.2.3 From fd14c250b8aa7b2d512194b164646ff7f658bef3 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 17 Jul 2013 11:30:09 -0400 Subject: CHOP-962: Preserve unrecognized user settings variables. Change LLControlVariable::mPersist from bool to tri-state enum. Its 'true' value used to mean "persist only if changed from default;" third state now means "persist regardless of value." Add forcePersist() method to set that. Replace isSaveValueDefault() method -- used only by logic to determine whether to save the variable -- with shouldSave() method to encapsulate ALL that logic rather than only part of it. shouldSave() recognizes PERSIST_ALWAYS state. When loading an unrecognized control variable from a user settings file, use forcePersist() to ensure that we later save that variable again. Tweak one of the unit tests to adjust for new semantics. --- indra/llxml/llcontrol.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'indra/llxml/llcontrol.h') diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index a7424c6780..5d6ac33780 100755 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -101,13 +101,19 @@ public: typedef boost::signals2::signal commit_signal_t; private: + enum + { + PERSIST_NO, // don't save this var + PERSIST_YES, // save this var if differs from default + PERSIST_ALWAYS // save this var even if has default value + } mPersist; + std::string mName; std::string mComment; eControlType mType; - bool mPersist; bool mHideFromSettingsEditor; std::vector mValues; - + commit_signal_t mCommitSignal; validate_signal_t mValidateSignal; @@ -131,8 +137,8 @@ public: validate_signal_t* getValidateSignal() { return &mValidateSignal; } bool isDefault() { return (mValues.size() == 1); } - bool isSaveValueDefault(); - bool isPersisted() { return mPersist; } + bool shouldSave(bool nondefault_only); + bool isPersisted() { return mPersist != PERSIST_NO; } bool isHiddenFromSettingsEditor() { return mHideFromSettingsEditor; } LLSD get() const { return getValue(); } LLSD getValue() const { return mValues.back(); } @@ -142,7 +148,8 @@ public: void set(const LLSD& val) { setValue(val); } void setValue(const LLSD& value, bool saved_value = TRUE); void setDefaultValue(const LLSD& value); - void setPersist(bool state); + void setPersist(bool state); // persist or not depending on value + void forcePersist(); // always persist regardless of value void setHiddenFromSettingsEditor(bool hide); void setComment(const std::string& comment); -- cgit v1.2.3 From d2386652f8a44c5adcc7fbcc65741649dd90aa2b Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 25 Jul 2013 16:46:51 -0400 Subject: CHOP-962: Make LLControlVariable::setPersist() accept only enum. Initial change made LLControlVariable::mPersist an enum, but retained bool/BOOL public API. setPersist(true) set one value, setPersist(false) set another, forcePersist() set the third. Per code review, expose enum to public, make setPersist() (and LLControlVariable constructor, and LLControlGroup:: declareControl(), and all the LLControlGroup::declareMumble() methods, and all the unit-test dummy declareMumble() method bodies) accept that enum. Remove forcePersist(). Fix calls to LLControlGroup::declareMumble() accordingly. Also rename PERSIST_YES to PERSIST_NONDFT, also per code review. --- indra/llxml/llcontrol.h | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'indra/llxml/llcontrol.h') diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 5d6ac33780..e1f9be80dd 100755 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -72,8 +72,6 @@ class LLVector3d; class LLColor4; class LLColor3; -const BOOL NO_PERSIST = FALSE; - typedef enum e_control_type { TYPE_U32 = 0, @@ -100,17 +98,18 @@ public: typedef boost::signals2::signal validate_signal_t; typedef boost::signals2::signal commit_signal_t; -private: - enum + enum ePersist { PERSIST_NO, // don't save this var - PERSIST_YES, // save this var if differs from default + PERSIST_NONDFT, // save this var if differs from default PERSIST_ALWAYS // save this var even if has default value - } mPersist; + }; +private: std::string mName; std::string mComment; eControlType mType; + ePersist mPersist; bool mHideFromSettingsEditor; std::vector mValues; @@ -120,7 +119,7 @@ private: public: LLControlVariable(const std::string& name, eControlType type, LLSD initial, const std::string& comment, - bool persist = true, bool hidefromsettingseditor = false); + ePersist persist = PERSIST_NONDFT, bool hidefromsettingseditor = false); virtual ~LLControlVariable(); @@ -148,8 +147,7 @@ public: void set(const LLSD& val) { setValue(val); } void setValue(const LLSD& value, bool saved_value = TRUE); void setDefaultValue(const LLSD& value); - void setPersist(bool state); // persist or not depending on value - void forcePersist(); // always persist regardless of value + void setPersist(ePersist); void setHiddenFromSettingsEditor(bool hide); void setComment(const std::string& comment); @@ -215,18 +213,18 @@ public: }; void applyToAll(ApplyFunctor* func); - LLControlVariable* declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist, BOOL hidefromsettingseditor = FALSE); - LLControlVariable* declareU32(const std::string& name, U32 initial_val, const std::string& comment, BOOL persist = TRUE); - LLControlVariable* declareS32(const std::string& name, S32 initial_val, const std::string& comment, BOOL persist = TRUE); - LLControlVariable* declareF32(const std::string& name, F32 initial_val, const std::string& comment, BOOL persist = TRUE); - LLControlVariable* declareBOOL(const std::string& name, BOOL initial_val, const std::string& comment, BOOL persist = TRUE); - LLControlVariable* declareString(const std::string& name, const std::string &initial_val, const std::string& comment, BOOL persist = TRUE); - LLControlVariable* declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment, BOOL persist = TRUE); - LLControlVariable* declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, BOOL persist = TRUE); - LLControlVariable* declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, BOOL persist = TRUE); - LLControlVariable* declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, BOOL persist = TRUE); - LLControlVariable* declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, BOOL persist = TRUE); - LLControlVariable* declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, BOOL persist = TRUE); + LLControlVariable* declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, LLControlVariable::ePersist persist, BOOL hidefromsettingseditor = FALSE); + LLControlVariable* declareU32(const std::string& name, U32 initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareS32(const std::string& name, S32 initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareF32(const std::string& name, F32 initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareBOOL(const std::string& name, BOOL initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareString(const std::string& name, const std::string &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); std::string getString(const std::string& name); std::string getText(const std::string& name); @@ -375,7 +373,7 @@ private: init_value = convert_to_llsd(default_value); if(type < TYPE_COUNT) { - group.declareControl(name, type, init_value, comment, FALSE); + group.declareControl(name, type, init_value, comment, LLControlVariable::PERSIST_NO); return true; } return false; -- cgit v1.2.3