[osg-users] Bug in RenderBin (?)

Paul Melis paul at science.uva.nl
Thu Mar 12 03:44:36 PDT 2009


Robert Osfield wrote:
> HI David & Christof et. al,
>
> On Thu, Mar 12, 2009 at 10:13 AM, David Callu <ledocc at gmail.com> wrote:
>   
>> What is smells fishy is the use of "proto->className()" to identify the
>> renderBin prototype to remove in removeRenderBinPrototype();
>>     
>
> Well spotted David, the addRenderBinPrototype() correctly uses
> binName, while the removeRenderBinProtoype() attempts to use the
> className() as it's binName.  The later is definitely a bug, and one
> that is easy to fix...
>
>
>   
>> Instead, in "void RenderBin::removeRenderBinPrototype(RenderBin* proto)" we
>> need something like this
>>
>> <code>
>>
>> void RenderBin::removeRenderBinPrototype(const std::string & binName,
>> RenderBin* proto)
>> {
>>     RenderBinPrototypeList* list = renderBinPrototypeList();
>>     if (list && proto)
>>     {
>>         RenderBinPrototypeList::iterator itr = list->find(binName);
>>         if (itr != list->end()) list->erase(itr);
>>     }
>> }
>>
>> </code>
>>
>> Thought ?
>>     
>
> There is no need to use the binName, one just needs to search for the
> pointer in the map by hand, and remove it.
>   
But as the RenderBin instances are still stored *by name* in 
addRenderBinPrototype() doesn't this mean that one of the two instances 
is lost when the second one is added?
Or is that intended?

Paul
> I'm just tested the following code and it looks to be working properly :
>
> void RenderBin::removeRenderBinPrototype(RenderBin* proto)
> {
>     RenderBinPrototypeList* list = renderBinPrototypeList();
>     if (list && proto)
>     {
>         for(RenderBinPrototypeList::iterator itr = list->begin();
>             itr != list->end();
>             ++itr)
>         {
>             if (itr->second == proto)
>             {
>                 list->erase(itr);
>                 return;
>             }
>         }
>     }
> }
>
> I've attached the modified file.  Christof could you test this and let
> me know how you get on.  If things look fine I'll check the changes
> into svn/trunk and OSG-2.8 branch.
>
> Robert.
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>   




More information about the osg-users mailing list