diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/llui.cpp | 10 | ||||
-rw-r--r-- | indra/llui/llui.h | 4 | ||||
-rw-r--r-- | indra/llui/lluiimage.h | 1 | ||||
-rw-r--r-- | indra/llxuixml/llinitparam.cpp | 28 | ||||
-rw-r--r-- | indra/llxuixml/llinitparam.h | 43 |
5 files changed, 34 insertions, 52 deletions
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 76f07373b4..caf04339c2 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1894,7 +1894,9 @@ namespace LLInitParam blue("blue"), alpha("alpha"), control("") - {} + { + setBlockFromValue(); + } void TypedParam<LLUIColor>::setValueFromBlock() const { @@ -1939,6 +1941,7 @@ namespace LLInitParam size("size"), style("style") { + setBlockFromValue(); addSynonym(name, ""); } @@ -1979,7 +1982,9 @@ namespace LLInitParam bottom("bottom"), width("width"), height("height") - {} + { + setBlockFromValue(); + } void TypedParam<LLRect>::setValueFromBlock() const { @@ -2064,6 +2069,7 @@ namespace LLInitParam x("x"), y("y") { + setBlockFromValue(); } void TypedParam<LLCoordGL>::setValueFromBlock() const diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 5840e76f5c..af8d4ea03b 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -426,8 +426,8 @@ namespace LLInitParam { typedef BlockValue<const LLFontGL*> super_t; public: - Mandatory<std::string> name; - Optional<std::string> size, + Optional<std::string> name, + size, style; TypedParam(BlockDescriptor& descriptor, const char* name, const LLFontGL* const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count); diff --git a/indra/llui/lluiimage.h b/indra/llui/lluiimage.h index bdfc44262d..4ea0738026 100644 --- a/indra/llui/lluiimage.h +++ b/indra/llui/lluiimage.h @@ -109,6 +109,7 @@ namespace LLInitParam TypedParam(BlockDescriptor& descriptor, const char* name, super_t::value_assignment_t value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count) : super_t(descriptor, name, value, func, min_count, max_count) { + setBlockFromValue(); } void setValueFromBlock() const; diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp index fb0a04dc58..2ead5a4a57 100644 --- a/indra/llxuixml/llinitparam.cpp +++ b/indra/llxuixml/llinitparam.cpp @@ -137,7 +137,7 @@ namespace LLInitParam } - bool BaseBlock::validateBlock(bool silent) const + bool BaseBlock::validateBlock(bool emit_errors) const { const BlockDescriptor& block_data = getBlockDescriptor(); for (BlockDescriptor::param_validation_list_t::const_iterator it = block_data.mValidationList.begin(); it != block_data.mValidationList.end(); ++it) @@ -145,7 +145,7 @@ namespace LLInitParam const Param* param = getParamFromHandle(it->first); if (!it->second(param)) { - if (!silent) + if (emit_errors) { llwarns << "Invalid param \"" << getParamName(block_data, param) << "\"" << llendl; } @@ -458,7 +458,7 @@ namespace LLInitParam // take all provided params from other and apply to self // NOTE: this requires that "other" is of the same derived type as this - bool BaseBlock::overwriteFromImpl(BlockDescriptor& block_data, const BaseBlock& other) + bool BaseBlock::merge(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { bool param_changed = false; BlockDescriptor::all_params_list_t::const_iterator end_it = block_data.mAllParams.end(); @@ -471,27 +471,7 @@ namespace LLInitParam if (merge_func) { Param* paramp = getParamFromHandle(it->mParamHandle); - param_changed |= merge_func(*paramp, *other_paramp, true); - } - } - return param_changed; - } - - // take all provided params that are not already provided, and apply to self - bool BaseBlock::fillFromImpl(BlockDescriptor& block_data, const BaseBlock& other) - { - bool param_changed = false; - BlockDescriptor::all_params_list_t::const_iterator end_it = block_data.mAllParams.end(); - for (BlockDescriptor::all_params_list_t::const_iterator it = block_data.mAllParams.begin(); - it != end_it; - ++it) - { - const Param* other_paramp = other.getParamFromHandle(it->mParamHandle); - ParamDescriptor::merge_func_t merge_func = it->mMergeFunc; - if (merge_func) - { - Param* paramp = getParamFromHandle(it->mParamHandle); - param_changed |= merge_func(*paramp, *other_paramp, false); + param_changed |= merge_func(*paramp, *other_paramp, overwrite); } } return param_changed; diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index d264cea3b2..c9c1d4af90 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -407,7 +407,7 @@ namespace LLInitParam class BaseBlock { public: - // "Multiple" constraint types + // "Multiple" constraint types, put here in root class to avoid ambiguity during use struct AnyAmount { static U32 minCount() { return 0; } @@ -452,7 +452,7 @@ namespace LLInitParam bool submitValue(const Parser::name_stack_t& name_stack, Parser& p, bool silent=false); param_handle_t getHandleFromParam(const Param* param) const; - bool validateBlock(bool silent = false) const; + bool validateBlock(bool emit_errors = true) const; Param* getParamFromHandle(const param_handle_t param_handle) { @@ -500,10 +500,7 @@ namespace LLInitParam // take all provided params from other and apply to self - bool overwriteFromImpl(BlockDescriptor& block_data, const BaseBlock& other); - - // take all provided params that are not already provided, and apply to self - bool fillFromImpl(BlockDescriptor& block_data, const BaseBlock& other); + bool merge(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite); // can be updated in getters mutable S32 mChangeVersion; @@ -805,7 +802,7 @@ namespace LLInitParam if (Param::getProvided() && mData.mValidatedVersion < T::getLastChangeVersion()) { // a sub-block is "provided" when it has been filled in enough to be valid - mData.mValidated = T::validateBlock(true); + mData.mValidated = T::validateBlock(false); mData.mValidatedVersion = T::getLastChangeVersion(); } return Param::getProvided() && mData.mValidated; @@ -1236,7 +1233,7 @@ namespace LLInitParam it != mValues.end(); ++it) { - if(it->validateBlock(true)) count++; + if(it->validateBlock(false)) count++; } return count; } @@ -1286,7 +1283,7 @@ namespace LLInitParam bool overwriteFrom(const self_t& other) { mCurChoice = other.mCurChoice; - return BaseBlock::overwriteFromImpl(blockDescriptor(), other); + return BaseBlock::merge(blockDescriptor(), other, true); } // take all provided params that are not already provided, and apply to self @@ -1413,13 +1410,13 @@ namespace LLInitParam // take all provided params from other and apply to self bool overwriteFrom(const self_t& other) { - return BaseBlock::overwriteFromImpl(blockDescriptor(), other); + return BaseBlock::merge(blockDescriptor(), other, true); } // take all provided params that are not already provided, and apply to self bool fillFrom(const self_t& other) { - return BaseBlock::fillFromImpl(blockDescriptor(), other); + return BaseBlock::merge(blockDescriptor(), other, false); } protected: Block() @@ -1710,7 +1707,7 @@ namespace LLInitParam // if cached value is stale, regenerate from params if (Param::getProvided() && mData.mLastParamVersion < BaseBlock::getLastChangeVersion()) { - if (block_t::validateBlock(true)) + if (block_t::validateBlock(false)) { static_cast<const DERIVED*>(this)->setValueFromBlock(); // clear stale keyword associated with old value @@ -1769,7 +1766,7 @@ namespace LLInitParam if (Param::getProvided() && (mData.mLastParamVersion < BaseBlock::getLastChangeVersion())) { // go ahead and issue warnings at this point if any param is invalid - if(block_t::validateBlock(false)) + if(block_t::validateBlock(true)) { static_cast<const DERIVED*>(this)->setValueFromBlock(); mData.clearKey(); @@ -1797,25 +1794,23 @@ namespace LLInitParam private: static bool mergeWith(Param& dst, const Param& src, bool overwrite) { - const self_t& src_param = static_cast<const self_t&>(src); + const self_t& src_typed_param = static_cast<const self_t&>(src); self_t& dst_typed_param = static_cast<self_t&>(dst); - if (src_param.isProvided() + if (src_typed_param.isProvided() && (overwrite || !dst_typed_param.isProvided())) { // assign individual parameters - if (overwrite) - { - dst_typed_param.BaseBlock::overwriteFromImpl(block_t::blockDescriptor(), src_param); - } - else - { - dst_typed_param.BaseBlock::fillFromImpl(block_t::blockDescriptor(), src_param); - } + dst_typed_param.BaseBlock::merge(block_t::blockDescriptor(), src_typed_param, overwrite); + // then copy actual value - dst_typed_param.mData.mValue = src_param.get(); + dst_typed_param.mData.mValue = src_typed_param.get(); dst_typed_param.mData.clearKey(); dst_typed_param.setProvided(true); + + // Propagate value back to block params since the value was updated during this merge. + // This will result in mData.mValue and the block params being in sync. + static_cast<DERIVED&>(dst_typed_param).setBlockFromValue(); return true; } return false; |