Skip to content
Snippets Groups Projects
Commit 85efb85a authored by Alexander Gavriliuk's avatar Alexander Gavriliuk Committed by Guru
Browse files

SL-19299 Viewer crashes after change 'Pick a physics model:' dropdown

parent 72050459
No related branches found
No related tags found
No related merge requests found
...@@ -129,16 +129,6 @@ template <class Type> class LLPointer ...@@ -129,16 +129,6 @@ template <class Type> class LLPointer
void ref(); void ref();
void unref(); void unref();
#else #else
void assign(const LLPointer<Type>& ptr)
{
if( mPointer != ptr.mPointer )
{
unref();
mPointer = ptr.mPointer;
ref();
}
}
void ref() void ref()
{ {
if (mPointer) if (mPointer)
...@@ -161,7 +151,18 @@ template <class Type> class LLPointer ...@@ -161,7 +151,18 @@ template <class Type> class LLPointer
} }
} }
} }
#endif #endif // LL_LIBRARY_INCLUDE
void assign(const LLPointer<Type>& ptr)
{
if (mPointer != ptr.mPointer)
{
unref();
mPointer = ptr.mPointer;
ref();
}
}
protected: protected:
Type* mPointer; Type* mPointer;
}; };
...@@ -264,7 +265,7 @@ template <class Type> class LLConstPointer ...@@ -264,7 +265,7 @@ template <class Type> class LLConstPointer
#ifdef LL_LIBRARY_INCLUDE #ifdef LL_LIBRARY_INCLUDE
void ref(); void ref();
void unref(); void unref();
#else #else // LL_LIBRARY_INCLUDE
void ref() void ref()
{ {
if (mPointer) if (mPointer)
...@@ -277,9 +278,9 @@ template <class Type> class LLConstPointer ...@@ -277,9 +278,9 @@ template <class Type> class LLConstPointer
{ {
if (mPointer) if (mPointer)
{ {
const Type *tempp = mPointer; const Type *temp = mPointer;
mPointer = NULL; mPointer = NULL;
tempp->unref(); temp->unref();
if (mPointer != NULL) if (mPointer != NULL)
{ {
LL_WARNS() << "Unreference did assignment to non-NULL because of destructor" << LL_ENDL; LL_WARNS() << "Unreference did assignment to non-NULL because of destructor" << LL_ENDL;
...@@ -287,7 +288,7 @@ template <class Type> class LLConstPointer ...@@ -287,7 +288,7 @@ template <class Type> class LLConstPointer
} }
} }
} }
#endif #endif // LL_LIBRARY_INCLUDE
protected: protected:
const Type* mPointer; const Type* mPointer;
}; };
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "llerror.h" #include "llerror.h"
// maximum reference count before sounding memory leak alarm // maximum reference count before sounding memory leak alarm
const S32 gMaxRefCount = S32_MAX; const S32 gMaxRefCount = LL_REFCOUNT_FREE;
LLRefCount::LLRefCount(const LLRefCount& other) LLRefCount::LLRefCount(const LLRefCount& other)
: mRef(0) : mRef(0)
......
...@@ -51,21 +51,17 @@ class LL_COMMON_API LLRefCount ...@@ -51,21 +51,17 @@ class LL_COMMON_API LLRefCount
public: public:
LLRefCount(); LLRefCount();
inline void validateRefCount() const
{
llassert(mRef > 0); // ref count below 0, likely corrupted
llassert(mRef < gMaxRefCount); // ref count excessive, likely memory leak
}
inline void ref() const inline void ref() const
{ {
llassert(mRef != LL_REFCOUNT_FREE); // object is deleted
mRef++; mRef++;
validateRefCount(); llassert(mRef < gMaxRefCount); // ref count excessive, likely memory leak
} }
inline S32 unref() const inline S32 unref() const
{ {
validateRefCount(); llassert(mRef != LL_REFCOUNT_FREE); // object is deleted
llassert(mRef > 0); // ref count below 1, likely corrupted
if (0 == --mRef) if (0 == --mRef)
{ {
mRef = LL_REFCOUNT_FREE; // set to nonsense yet recognizable value to aid in debugging mRef = LL_REFCOUNT_FREE; // set to nonsense yet recognizable value to aid in debugging
......
...@@ -270,6 +270,7 @@ void LLModelPreview::rebuildUploadData() ...@@ -270,6 +270,7 @@ void LLModelPreview::rebuildUploadData()
{ {
assert_main_thread(); assert_main_thread();
mDefaultPhysicsShapeP = NULL;
mUploadData.clear(); mUploadData.clear();
mTextureSet.clear(); mTextureSet.clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment