[osg-users] Bug in RenderBin (?)

David Callu ledocc at gmail.com
Thu Mar 12 03:46:19 PDT 2009


Hi Robert


What about the case of register two prototype with the same name. There are
any warning message for the user.
I fix this like that


void RenderBin::addRenderBinPrototype(const std::string& binName, RenderBin*
proto)
{
    RenderBinPrototypeList* list = renderBinPrototypeList();
    if (list && proto)
    {
        RenderBinPrototypeList::iterator itr = list->find(binName);
        if (itr != list->end())
            osg::notify(osg::WARN) << "Warning: RenderBinPrototype named
\""<< binName <<"\" already registered" << std::endl;
        else
            (*list)[binName] = proto;
    }
}

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())
        {
            if (itr->second != proto)
                osg::notify(osg::WARN) << "Warning: Registered
RenderBinPrototype named \"" << binName << "\" not match the instance " <<
proto << std::endl;
            else
                list->erase(itr);
        }
    }
}


thought ?

David

2009/3/12 Robert Osfield <robert.osfield at gmail.com>

> 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.
>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20090312/ea1df490/attachment-0003.htm>


More information about the osg-users mailing list