Robert Osfield wrote:
HI David & Christof et. al,

On Thu, Mar 12, 2009 at 10:13 AM, David Callu <led...@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@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to