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 <[email protected]>
> HI David & Christof et. al,
>
> On Thu, Mar 12, 2009 at 10:13 AM, David Callu <[email protected]> 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
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org