[sldev] Why won't isAvatar() work?

Dale Glass dale at daleglass.net
Thu Oct 4 05:22:20 PDT 2007


On Wed, Oct 03, 2007 at 09:58:30PM -0400, Michael Miller wrote:
> At the end of the processObjectUpdate method(in llviewerobjectlist.cpp), I
> check to see if the object is an avatar(after everything in the "stock"
> source is done). The check looks like this:
> 
> if(objectp && objectp->isAvatar()){
> // Do stuff here
> }
> 
> The problem lies in the objectp->isAvatar(). I've run this through gdb(I'm
> on Mac OSX "non-10.4 platform"), and the isAvatar() method keeps throwing
> EXEC_BAD_ACCESS exceptions whenever the method is run(when calling
> isAvatar()). Is this because the objectp variable is "destroyed" or
> otherwise made inaccessible? How might I remedy this problem?
> 
> Thanks,
> Mike

I looked a bit at the code. Do you do it at the end of the function,
before the last line?

Note how the function declares:
LLViewerObject *objectp;

Which isn't initialized.

objectp remains uninitialized until:
objectp = findObject(fullid);


If for some reason the update affects 0 objects (don't know if that may
ever happen), then objectp may remain uninitialized at the end of the
function. But you should be adding your code somewhere inside the loop
anyway, after objectp gets initialized.


Change the declaration to:
LLViewerObject *objectp = NULL;

Crashes on NULL pointers are much easier to debug.

> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> /index.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.secondlife.com/pipermail/sldev/attachments/20071004/c435eb2b/attachment.pgp


More information about the SLDev mailing list