From 974720373d608a8cbcd3cd26c125b6487b5926a2 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Tue, 8 Jan 2013 12:21:47 -0800 Subject: CHUI-660: Problem: Upon auto-existing DND mode upon startup, the notification form elements (buttonts) were added to the form. But then deserialized form elements were also being added to the form causing duplicate buttons. As a solution, only add on the deserialized form elements that exceed the amount in the template. --- indra/llui/llnotifications.cpp | 18 +++++++++++++++++- indra/llui/llnotifications.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 386345177d..ebdb4d5024 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -320,6 +320,11 @@ void LLNotificationForm::addElement(const std::string& type, const std::string& mFormData.append(element); } +void LLNotificationForm::addElement(const LLSD& element) +{ + mFormData.append(element); +} + void LLNotificationForm::append(const LLSD& sub_form) { if (sub_form.isArray()) @@ -818,7 +823,18 @@ void LLNotification::init(const std::string& template_name, const LLSD& form_ele //mSubstitutions["_ARGS"] = get_all_arguments_as_text(mSubstitutions); mForm = LLNotificationFormPtr(new LLNotificationForm(*mTemplatep->mForm)); - mForm->append(form_elements); + + //Prevents appending elements(buttons) that the template already had + if(form_elements.isArray() + && mForm->getNumElements() < form_elements.size()) + { + LLSD::array_const_iterator it = form_elements.beginArray() + mForm->getNumElements();; + + for(; it != form_elements.endArray(); ++it) + { + mForm->addElement(*it); + } + } // apply substitution to form labels mForm->formatElements(mSubstitutions); diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 092a9acd7c..96e0a86b7f 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -246,6 +246,7 @@ public: bool getElementEnabled(const std::string& element_name) const; void setElementEnabled(const std::string& element_name, bool enabled); void addElement(const std::string& type, const std::string& name, const LLSD& value = LLSD(), bool enabled = true); + void addElement(const LLSD &element); void formatElements(const LLSD& substitutions); // appends form elements from another form serialized as LLSD void append(const LLSD& sub_form); -- cgit v1.2.3