Crash in LLPanelEditWearable::isDirty(): Make sure there's no dangling pointer to a LLWearable.
parent
f10e23cf36
commit
2c4a3e7610
|
|
@ -60,6 +60,9 @@ LLWearable::LLWearable()
|
|||
// virtual
|
||||
LLWearable::~LLWearable()
|
||||
{
|
||||
for (std::set< LLWearableObserver* >::iterator itr = mObservers.begin(); itr != mObservers.end(); ++itr )
|
||||
(*itr)->onDestroyed( this );
|
||||
|
||||
for (visual_param_index_map_t::iterator vpIter = mVisualParamIndexMap.begin(); vpIter != mVisualParamIndexMap.end(); ++vpIter)
|
||||
{
|
||||
LLVisualParam* vp = vpIter->second;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,21 @@ class LLAvatarAppearance;
|
|||
// Abstract class.
|
||||
class LLWearable
|
||||
{
|
||||
// <FS:ND> Try to see if this fixes the crash in LLPanelEditWearable::isDirty, that is the wearable dets destroyed before the panel
|
||||
public:
|
||||
class LLWearableObserver
|
||||
{
|
||||
public:
|
||||
virtual void onDestroyed(LLWearable const * ) = 0;
|
||||
};
|
||||
|
||||
public:
|
||||
void registerObserver(LLWearableObserver *aObserver){ mObservers.insert(aObserver); }
|
||||
void unregisterObserver(LLWearableObserver *aObserver){ mObservers.erase(aObserver); }
|
||||
private:
|
||||
std::set< LLWearableObserver* > mObservers;
|
||||
// </FS:ND>
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Constructors and destructors
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -653,7 +653,8 @@ LLPanelEditWearable::LLPanelEditWearable()
|
|||
//virtual
|
||||
LLPanelEditWearable::~LLPanelEditWearable()
|
||||
{
|
||||
|
||||
if (mWearablePtr)
|
||||
mWearablePtr->unregisterObserver(this);
|
||||
}
|
||||
|
||||
bool LLPanelEditWearable::changeHeightUnits(const LLSD& new_value)
|
||||
|
|
@ -883,7 +884,11 @@ void LLPanelEditWearable::setVisible(BOOL visible)
|
|||
void LLPanelEditWearable::setWearable(LLViewerWearable *wearable, BOOL disable_camera_switch)
|
||||
{
|
||||
showWearable(mWearablePtr, FALSE, disable_camera_switch);
|
||||
mWearablePtr = wearable;
|
||||
if (mWearablePtr)
|
||||
mWearablePtr->unregisterObserver(this);
|
||||
mWearablePtr = wearable;
|
||||
if( mWearablePtr )
|
||||
mWearablePtr->registerObserver( this );
|
||||
showWearable(mWearablePtr, TRUE, disable_camera_switch);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "llavatarappearancedefines.h"
|
||||
#include "llwearabletype.h"
|
||||
|
||||
#include "llwearable.h" // <FS:ND/> for LLWearable::LLWearableObserver
|
||||
class LLAccordionCtrl;
|
||||
class LLCheckBoxCtrl;
|
||||
class LLViewerWearable;
|
||||
|
|
@ -45,8 +46,12 @@ class LLAccordionCtrlTab;
|
|||
class LLJoint;
|
||||
class LLLineEditor;
|
||||
|
||||
class LLPanelEditWearable : public LLPanel
|
||||
class LLPanelEditWearable : public LLPanel, public LLWearable::LLWearableObserver
|
||||
{
|
||||
// <FS:ND> Try to see if this fixes the crash in LLPanelEditWearable::isDirty, that is the wearable dets destroyed before the panel
|
||||
virtual void onDestroyed(LLWearable const *) { mWearablePtr = NULL; }
|
||||
// </FS:ND>
|
||||
|
||||
public:
|
||||
LLPanelEditWearable( );
|
||||
virtual ~LLPanelEditWearable();
|
||||
|
|
|
|||
Loading…
Reference in New Issue