From f6df34e40a9d0d348215bbdf861ebfe8d42b9dd2 Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Wed, 26 Jun 2013 11:16:44 -0400 Subject: [PATCH] Remove mCommitCallback, mValidateCallback, and mCallbackUserData and related functions from LLUICtrl and derived classes --- indra/llui/llmultisliderctrl.cpp | 8 +++----- indra/llui/llpanel.cpp | 4 ++-- indra/llui/llpanel.h | 2 +- indra/llui/llsliderctrl.cpp | 8 +++----- indra/llui/llspinctrl.cpp | 10 +++------- indra/llui/lltextbox.h | 1 - indra/llui/lluictrl.cpp | 10 ---------- indra/llui/lluictrl.h | 14 -------------- 8 files changed, 12 insertions(+), 45 deletions(-) diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp index 1cd91c3a4..29fe889d3 100644 --- a/indra/llui/llmultisliderctrl.cpp +++ b/indra/llui/llmultisliderctrl.cpp @@ -291,9 +291,8 @@ void LLMultiSliderCtrl::onEditorCommit(const LLSD& value) val = (F32) atof( text.c_str() ); if( mMultiSlider->getMinValue() <= val && val <= mMultiSlider->getMaxValue() ) { - setCurSliderValue( val ); - if( (!mValidateCallback || mValidateCallback( this, mCallbackUserData )) && - (!mValidateSignal || (*(mValidateSignal))(this, val))) + setCurSliderValue( val ); // set the value temporarily so that the callback can retrieve it. + if( !mValidateSignal || (*(mValidateSignal))( this, val ) ) { success = TRUE; } @@ -322,8 +321,7 @@ void LLMultiSliderCtrl::onSliderCommit(const LLSD& value) F32 new_val = mMultiSlider->getCurSliderValue(); mCurValue = new_val; // set the value temporarily so that the callback can retrieve it. - if( (!mValidateCallback || mValidateCallback( this, mCallbackUserData )) && - (!mValidateSignal || (*mValidateSignal)(this, new_val ) )) + if( !mValidateSignal || (*(mValidateSignal))( this, new_val ) ) { success = TRUE; } diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index eb5362a88..dd388e719 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -767,9 +767,9 @@ void LLPanel::childSetCommitCallback(const std::string& id, boost::function cb) { - LLUICtrl* child = getChild(id, true); + LLUICtrl* child = findChild(id); if (child) { child->setValidateBeforeCommit(cb); diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index eac7d12a8..5700d1606 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -176,7 +176,7 @@ public: // a named callback and reference it in XML. void childSetCommitCallback(const std::string& id, boost::function cb, void* data = NULL); - void childSetValidate(const std::string& id, BOOL (*cb)(LLUICtrl*, void*) ); + void childSetValidate(const std::string& id, boost::function cb ); void childSetColor(const std::string& id, const LLColor4& color); void childSetAlpha(const std::string& id, F32 alpha); diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp index 53f54d75c..df1acf62a 100644 --- a/indra/llui/llsliderctrl.cpp +++ b/indra/llui/llsliderctrl.cpp @@ -227,9 +227,8 @@ void LLSliderCtrl::onEditorCommit( LLUICtrl* ctrl, const LLSD& userdata ) val = (F32) atof( text.c_str() ); if( self->mSlider->getMinValue() <= val && val <= self->mSlider->getMaxValue() ) { - self->setValue( val ); - if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) && - (!self->mValidateSignal || (*(self->mValidateSignal))( self, val ))) + self->setValue( val ); // set the value temporarily so that the callback can retrieve it. + if( !self->mValidateSignal || (*(self->mValidateSignal))( self, val ) ) { success = TRUE; } @@ -263,8 +262,7 @@ void LLSliderCtrl::onSliderCommit( LLUICtrl* ctrl, const LLSD& userdata ) F32 new_val = self->mSlider->getValueF32(); self->mValue = new_val; // set the value temporarily so that the callback can retrieve it. - if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) && - (!self->mValidateSignal || (*(self->mValidateSignal))( self, new_val ))) + if( !self->mValidateSignal || (*(self->mValidateSignal))( self, new_val ) ) { success = TRUE; } diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp index a7950ccbf..44f6a607e 100644 --- a/indra/llui/llspinctrl.cpp +++ b/indra/llui/llspinctrl.cpp @@ -198,8 +198,7 @@ void LLSpinCtrl::onUpBtn( const LLSD& data ) F32 saved_val = (F32)getValue().asReal(); setValue(val); - if( (mValidateCallback && !mValidateCallback( this, mCallbackUserData ) ) || - (mValidateSignal && !(*mValidateSignal)( this, val ) )) + if( mValidateSignal && !(*mValidateSignal)( this, val ) ) { setValue( saved_val ); reportInvalidData(); @@ -227,8 +226,7 @@ void LLSpinCtrl::onDownBtn( const LLSD& data ) F32 saved_val = (F32)getValue().asReal(); setValue(val); - if( (mValidateCallback && !mValidateCallback( this, mCallbackUserData ) ) || - (mValidateSignal && !(*mValidateSignal)( this, val ) )) + if( mValidateSignal && !(*mValidateSignal)( this, val ) ) { setValue( saved_val ); reportInvalidData(); @@ -317,9 +315,7 @@ void LLSpinCtrl::onEditorCommit( const LLSD& data ) F32 saved_val = mValue; mValue = val; - - if( (!mValidateCallback || mValidateCallback( this, mCallbackUserData )) && - (!mValidateSignal || (*mValidateSignal)(this, val) )) + if( !mValidateSignal || (*mValidateSignal)( this, val ) ) { success = TRUE; onCommit(); diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h index de3e0c6e5..17abe2742 100644 --- a/indra/llui/lltextbox.h +++ b/indra/llui/lltextbox.h @@ -139,7 +139,6 @@ private: std::vector mLineLengthList; callback_t mClickedCallback; - void* mCallbackUserData; }; #endif diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 71e226f85..9f7ccc12a 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -45,9 +45,6 @@ LLUICtrl::LLUICtrl() : mViewModel(LLViewModelPtr(new LLViewModel)), mCommitSignal(NULL), mValidateSignal(NULL), - mCommitCallback(NULL), - mValidateCallback(NULL), - mCallbackUserData(NULL), mTentative(FALSE), mTabStop(TRUE), mIsChrome(FALSE) @@ -62,10 +59,7 @@ LLUICtrl::LLUICtrl(const std::string& name, const LLRect rect, BOOL mouse_opaque LLView( name, rect, mouse_opaque, reshape ), mCommitSignal(NULL), mValidateSignal(NULL), - mCommitCallback(NULL), mViewModel(LLViewModelPtr(new LLViewModel)), - mValidateCallback( NULL ), - mCallbackUserData( NULL ), mTentative( FALSE ), mTabStop( TRUE ), mIsChrome(FALSE) @@ -90,10 +84,6 @@ LLUICtrl::~LLUICtrl() void LLUICtrl::onCommit() { - if( mCommitCallback ) - { - mCommitCallback( this, mCallbackUserData ); - } if (mCommitSignal) (*mCommitSignal)(this, getValue()); } diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index ed3ea6244..954f1a688 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -50,9 +50,6 @@ public: typedef boost::signals2::signal commit_signal_t; typedef boost::signals2::signal enable_signal_t; - typedef void (*LLUICtrlCallback)(LLUICtrl* ctrl, void* userdata); - typedef BOOL (*LLUICtrlValidate)(LLUICtrl* ctrl, void* userdata); - LLUICtrl(); LLUICtrl( const std::string& name, const LLRect rect = LLRect(), BOOL mouse_opaque = TRUE, commit_callback_t commit_callback = NULL, @@ -126,13 +123,6 @@ public: boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb ); boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb ); - // *TODO: Deprecate; for backwards compatability only: - //Keeping userdata around with legacy setCommitCallback because it's used ALL OVER THE PLACE. - void* getCallbackUserData() const { return mCallbackUserData; } - void setCallbackUserData( void* data ) { mCallbackUserData = data; } - - void setCommitCallback( void (*cb)(LLUICtrl*, void*) ) { mCommitCallback = cb; } - void setValidateBeforeCommit( BOOL(*cb)(LLUICtrl*, void*) ) { mValidateCallback = cb; } // *TODO: Deprecate; for backwards compatability only: boost::signals2::connection setCommitCallback( boost::function cb, void* data); boost::signals2::connection setValidateBeforeCommit( boost::function cb ); @@ -155,10 +145,6 @@ protected: enable_signal_t* mValidateSignal; LLViewModelPtr mViewModel; - void (*mCommitCallback)( LLUICtrl* ctrl, void* userdata ); - BOOL (*mValidateCallback)( LLUICtrl* ctrl, void* userdata ); - - void* mCallbackUserData; private: