From 5ac0b9debc100a5a4d14e9eaad1a6542c927a275 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 23 Mar 2024 00:17:29 +0200 Subject: viewer#951 Crash at LLScrollingPanelParam::draw I'm not sure what causes this, but 1. Calling expensive getChild inside draw is not a good idea 2. I hope that simplified draw will capture a bit more info in bugsplat or will shift callctack elsewhere --- indra/newview/llscrollingpanelparam.cpp | 71 +++++++++++++++------------------ indra/newview/llscrollingpanelparam.h | 9 +++++ 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp index a77c387573..833eaaf8ca 100644 --- a/indra/newview/llscrollingpanelparam.cpp +++ b/indra/newview/llscrollingpanelparam.cpp @@ -53,44 +53,39 @@ LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_param LLViewerJointMesh* mesh, LLViewerVisualParam* param, bool allow_modify, LLWearable* wearable, LLJoint* jointp, bool use_hints ) : LLScrollingPanelParamBase( panel_params, mesh, param, allow_modify, wearable, jointp, use_hints) { - // *HACK To avoid hard coding texture position, lets use border's position for texture. - LLViewBorder* left_border = getChild("left_border"); - + mLessBtn = getChild("less"); + mMoreBtn = getChild("more"); + mLeftBorder = getChild("left_border"); + mRightBorder = getChild("right_border"); + mMinParamText = getChild("min param text"); + mMaxParamText = getChild("max param text"); + + // *HACK To avoid hard coding texture position, lets use border's position for texture. static LLUICachedControl slider_ctrl_height ("UISliderctrlHeight", 0); - S32 pos_x = left_border->getRect().mLeft + left_border->getBorderWidth(); - S32 pos_y = left_border->getRect().mBottom + left_border->getBorderWidth(); + S32 pos_x = mLeftBorder->getRect().mLeft + mLeftBorder->getBorderWidth(); + S32 pos_y = mLeftBorder->getRect().mBottom + mLeftBorder->getBorderWidth(); F32 min_weight = param->getMinWeight(); F32 max_weight = param->getMaxWeight(); mHintMin = new LLVisualParamHint( pos_x, pos_y, PARAM_HINT_WIDTH, PARAM_HINT_HEIGHT, mesh, (LLViewerVisualParam*) wearable->getVisualParam(param->getID()), wearable, min_weight, jointp); - pos_x = getChild("right_border")->getRect().mLeft + left_border->getBorderWidth(); + pos_x = mRightBorder->getRect().mLeft + mLeftBorder->getBorderWidth(); mHintMax = new LLVisualParamHint( pos_x, pos_y, PARAM_HINT_WIDTH, PARAM_HINT_HEIGHT, mesh, (LLViewerVisualParam*) wearable->getVisualParam(param->getID()), wearable, max_weight, jointp ); mHintMin->setAllowsUpdates( false ); mHintMax->setAllowsUpdates( false ); - std::string min_name = LLTrans::getString(param->getMinDisplayName()); - std::string max_name = LLTrans::getString(param->getMaxDisplayName()); - getChild("min param text")->setValue(min_name); - getChild("max param text")->setValue(max_name); + mMinParamText->setValue(LLTrans::getString(param->getMinDisplayName())); + mMaxParamText->setValue(LLTrans::getString(param->getMaxDisplayName())); - LLButton* less = getChild("less"); - if (less) - { - less->setMouseDownCallback( LLScrollingPanelParam::onHintMinMouseDown, this ); - less->setMouseUpCallback( LLScrollingPanelParam::onHintMinMouseUp, this ); - less->setHeldDownCallback( LLScrollingPanelParam::onHintMinHeldDown, this ); - less->setHeldDownDelay( PARAM_STEP_TIME_THRESHOLD ); - } + mLessBtn->setMouseDownCallback(LLScrollingPanelParam::onHintMinMouseDown, this); + mLessBtn->setMouseUpCallback(LLScrollingPanelParam::onHintMinMouseUp, this); + mLessBtn->setHeldDownCallback(LLScrollingPanelParam::onHintMinHeldDown, this); + mLessBtn->setHeldDownDelay(PARAM_STEP_TIME_THRESHOLD); - LLButton* more = getChild("more"); - if (more) - { - more->setMouseDownCallback( LLScrollingPanelParam::onHintMaxMouseDown, this ); - more->setMouseUpCallback( LLScrollingPanelParam::onHintMaxMouseUp, this ); - more->setHeldDownCallback( LLScrollingPanelParam::onHintMaxHeldDown, this ); - more->setHeldDownDelay( PARAM_STEP_TIME_THRESHOLD ); - } + mMoreBtn->setMouseDownCallback(LLScrollingPanelParam::onHintMaxMouseDown, this); + mMoreBtn->setMouseUpCallback(LLScrollingPanelParam::onHintMaxMouseUp, this); + mMoreBtn->setHeldDownCallback(LLScrollingPanelParam::onHintMaxHeldDown, this); + mMoreBtn->setHeldDownDelay(PARAM_STEP_TIME_THRESHOLD); setVisible(false); setBorderVisible( false ); @@ -110,8 +105,8 @@ void LLScrollingPanelParam::updatePanel(bool allow_modify) mHintMin->requestUpdate( sUpdateDelayFrames++ ); mHintMax->requestUpdate( sUpdateDelayFrames++ ); - getChildView("less")->setEnabled(mAllowModify); - getChildView("more")->setEnabled(mAllowModify); + mLessBtn->setEnabled(mAllowModify); + mMoreBtn->setEnabled(mAllowModify); } void LLScrollingPanelParam::setVisible( bool visible ) @@ -141,16 +136,16 @@ void LLScrollingPanelParam::draw() return; } - getChildView("less")->setVisible( mHintMin->getVisible()); - getChildView("more")->setVisible( mHintMax->getVisible()); + mLessBtn->setVisible( mHintMin->getVisible()); + mMoreBtn->setVisible( mHintMax->getVisible()); // hide borders if texture has been loaded - getChildView("left_border")->setVisible( !mHintMin->getVisible()); - getChildView("right_border")->setVisible( !mHintMax->getVisible()); + mLeftBorder->setVisible( !mHintMin->getVisible()); + mRightBorder->setVisible( !mHintMax->getVisible()); // Draw all the children except for the labels - getChildView("min param text")->setVisible( false ); - getChildView("max param text")->setVisible( false ); + mMinParamText->setVisible( false ); + mMaxParamText->setVisible( false ); LLPanel::draw(); // If we're in a focused floater, don't apply the floater's alpha to visual param hint, @@ -176,11 +171,11 @@ void LLScrollingPanelParam::draw() // Draw labels on top of the buttons - getChildView("min param text")->setVisible( true ); - drawChild(getChild("min param text")); + mMinParamText->setVisible( true ); + drawChild(mMinParamText); - getChildView("max param text")->setVisible( true ); - drawChild(getChild("max param text")); + mMaxParamText->setVisible( true ); + drawChild(mMaxParamText); } // static diff --git a/indra/newview/llscrollingpanelparam.h b/indra/newview/llscrollingpanelparam.h index 6a510026da..1ebf89f483 100644 --- a/indra/newview/llscrollingpanelparam.h +++ b/indra/newview/llscrollingpanelparam.h @@ -30,6 +30,8 @@ #include "llscrollingpanelparambase.h" +class LLBorder; +class LLButton; class LLViewerJointMesh; class LLViewerVisualParam; class LLWearable; @@ -80,6 +82,13 @@ protected: LLTimer mMouseDownTimer; // timer for how long mouse has been held down on a hint. F32 mLastHeldTime; bool mAllowModify; + + LLButton* mLessBtn; + LLButton* mMoreBtn; + LLViewBorder* mLeftBorder; + LLViewBorder* mRightBorder; + LLUICtrl* mMinParamText; + LLUICtrl* mMaxParamText; }; #endif -- cgit v1.2.3