Removing some more undefined behavior. Testing for a 'null-reference' (no such thing in C++) is undefined behavior and the compiler will optimize the case where the reference is invalid away.
After disussing with Nat remove that check and introduce new companion methods get...ref which fail in case an invalid reference would be returned.meow-7.2.2
parent
03e9b73780
commit
3c8a71c017
|
|
@ -219,6 +219,11 @@ LLTextureEntry* LLPrimitive::getTE(const U8 index) const
|
|||
return mTextureList.getTexture(index);
|
||||
}
|
||||
|
||||
LLTextureEntry& LLPrimitive::getTEref( const U8 te_num ) const
|
||||
{
|
||||
return mTextureList.getTextureRef( te_num );
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
void LLPrimitive::setNumTEs(const U8 num_tes)
|
||||
{
|
||||
|
|
@ -713,7 +718,7 @@ void LLPrimitive::copyTEs(const LLPrimitive *primitivep)
|
|||
}
|
||||
for (i = 0; i < num_tes; i++)
|
||||
{
|
||||
mTextureList.copyTexture(i, *(primitivep->getTE(i)));
|
||||
mTextureList.copyTexture(i, primitivep->getTEref(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -805,7 +810,7 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
|
|||
if (old_face_mask & cur_mask)
|
||||
{
|
||||
S32 te_index = face_index_from_id(cur_mask, old_faces);
|
||||
old_tes.copyTexture(face_bit, *(getTE(te_index)));
|
||||
old_tes.copyTexture(face_bit, getTEref(te_index));
|
||||
//LL_INFOS() << face_bit << ":" << te_index << ":" << old_tes[face_bit].getID() << LL_ENDL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -357,7 +357,8 @@ public:
|
|||
|
||||
// Modify texture entry properties
|
||||
inline BOOL validTE(const U8 te_num) const;
|
||||
LLTextureEntry* getTE(const U8 te_num) const;
|
||||
LLTextureEntry* getTE( const U8 te_num ) const;
|
||||
LLTextureEntry& getTEref( const U8 te_num ) const;
|
||||
|
||||
virtual void setNumTEs(const U8 num_tes);
|
||||
virtual void setAllTESelected(bool sel);
|
||||
|
|
|
|||
|
|
@ -137,14 +137,8 @@ S32 LLPrimTextureList::copyTexture(const U8 index, const LLTextureEntry& te)
|
|||
// we're changing an existing entry
|
||||
llassert(mEntryList[index]);
|
||||
delete (mEntryList[index]);
|
||||
if (&te)
|
||||
{
|
||||
mEntryList[index] = te.newCopy();
|
||||
}
|
||||
else
|
||||
{
|
||||
mEntryList[index] = LLPrimTextureList::newTextureEntry();
|
||||
}
|
||||
mEntryList[index] = te.newCopy();
|
||||
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
|
||||
|
|
@ -176,6 +170,17 @@ LLTextureEntry* LLPrimTextureList::getTexture(const U8 index) const
|
|||
return NULL;
|
||||
}
|
||||
|
||||
LLTextureEntry& LLPrimTextureList::getTextureRef( const U8 index ) const
|
||||
{
|
||||
if( index >= mEntryList.size() )
|
||||
{
|
||||
LL_ERRS() << "Texture index out of bounds, index: " << (U32)index << " mEntryList.size(): " << mEntryList.size() << LL_ENDL;
|
||||
}
|
||||
|
||||
return *mEntryList[ index ];
|
||||
}
|
||||
|
||||
|
||||
//virtual
|
||||
//S32 setTE(const U8 index, const LLTextureEntry& te) = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ public:
|
|||
// void copyTexture(const U8 index, const LLTextureEntry* entry);
|
||||
|
||||
// returns pointer to texture at 'index' slot
|
||||
LLTextureEntry* getTexture(const U8 index) const;
|
||||
LLTextureEntry* getTexture( const U8 index ) const;
|
||||
LLTextureEntry& getTextureRef( const U8 index ) const;
|
||||
|
||||
S32 setID(const U8 index, const LLUUID& id);
|
||||
S32 setColor(const U8 index, const LLColor3& color);
|
||||
|
|
|
|||
Loading…
Reference in New Issue