Quick follow-up:
osgDB::Registry::instance()->addEntryToObjectCache(file_name, result_node);
suffers the same problem.
I was able to circumvent the issue by applying
osgDB::Registry::instance()->getOptions() as the default option.
My proposed fix would be to simply skip the comparison of nullptr
options in the ObjectCache::ClassComp::operator().
Cheers
Sebastian
Hi Robert, Ralf
This actually introduces a subtle bug:
In case the implicit NULL-option variant is used:
getRefFromObjectCache(const std::string& fileName, constOptions
*options = NULL);
the comparison-operator will dereference a nullptr (of rhs.second)
when performing the lookup in
<code>
bool ObjectCache::ClassComp::operator() (const
ObjectCache::FileNameOptionsPair& lhs, const
ObjectCache::FileNameOptionsPair& rhs) const
{
return lhs.first < rhs.first || *lhs.second < *rhs.second;
}
</code>
I can try to produce a minimal example demonstrating the problem, but
basically calling
osgDB::Registry::instance()->getFromObjectCache(file_name)
with valid entries in the cache will cause the nullptr-deref.
Cheers
Sebastian
Hi Ralf,
I'm just catching up on submissions again after a Coverity squishing
expedition at the end of last week.
I'm currently look at your commit:
https://github.com/rhabacker/osg/commit/33aca40d00b8de692bc5858a15f8a53833c7d85c
Most of the changes look fine to me, the only odd thing is that the
date for the commit on this page is "committed on 15 Jan 2014" rather
than 4th of June it looks like it was pushed to your osg github
repository.
Something odd going on with dates?
--
On the issue about osgviewer not robustly handling -O, the options is
something that has been of add on rather than a full blown
implementation. The command line parsing that osgviewer and the rest
of the example provide is not meant to be a be all and end of command
line parsing. Even osgviewer is really just an example. Given this
I'm not too worried about it not supporting all the combination you
might be able to come up with w.r.t individual O options.
Personally I'd not try to make things too sophisticated, examples are
example not full blown applications. The main issue I see with the
examples not handling complex combinations of option usage is in
testing of the new feature of pairing objects in the cache with
Options. This feature is very specific to your application so far -
perhaps down the line others will start taking advantage of this
extended capability but for now it's not something that will affect
other users.
I believe the code changes in your commit are the best way to hand the
object cache so am happy to merge, but changes to the command line
parsing I'm happy to leave as it is originally, not general purpose
but at least provides a crude means of passing in options.
Robert.
On 6 June 2016 at 11:28, Ralf Habacker<[email protected]> wrote:
Am 03.06.2016 um 11:30 schrieb Ralf Habacker:
Am 02.06.2016 um 13:01 schrieb Robert Osfield:
One would simply use a osg::clone(options) to generate the options
object to store in the cache, this would insulate the cache from being
invalidated by changes to the original Options object passed in,
Got it, thanks :-)
I added initial support to class ObjectCache, see
https://github.com/rhabacker/osg/commit/e3539ea0185a4013514850c3577180aaa38c895d
While trying to test the implementation with osgviewer it turns out that
it is not possible to setup a testcase using command line.
I used
osgviewer -O convertToFeed test-file1.flt -O convertToKilometers
test-file2.flt
and got always empty options.
Adding test1.flt with options '' to ObjectCache 0x15fadb0
A quick check shows that in Registry::readCommandLine() all -O options
are read and saved in one Options instance in Registry::_options.
void Registry::readCommandLine(osg::ArgumentParser& arguments)
...
while(arguments.read("-O",value))
{
setOptions(new Options(value));
}
So I thought there may be a change to get options using one file:
osgviewer -O convertToFeed test-file1.flt
but still got
adding test1.flt with options '' to ObjectCache 0x12b9db0
Any idea what's going wrong and how to fix ?
Beside the that the mentioned command line should be
osgviewer -O convertToFeed test.flt
to match to debug output
and an incomplete patch from my side, which is fixed
inhttps://github.com/rhabacker/osg/commit/33aca40d00b8de692bc5858a15f8a53833c7d85c
it looks that there are conflicts in osgviewer command line handling relating
to the object cache.
On command line the object cache is enabled with --enable-object-cache, which
is handled in osgviewer.cpp:89 ff [2]
// Enable caching?
while (arguments.read("--enable-object-cache"))
{
if (osgDB::Registry::instance()->getOptions()==0)
osgDB::Registry::instance()->setOptions(new osgDB::Options());
osgDB::Registry::instance()->getOptions()->setObjectCacheHint(osgDB::Options::CACHE_ALL);
}
Adding -O <options> to command line in frot of a filename is handled in
void Registry::readCommandLine(osg::ArgumentParser& arguments)
...
while(arguments.read("-O",value))
{
setOptions(new Options(value));
}
The problem here is that the newly created option overwrites CACHE_ALL setting
from [2].
Second this code only adds the latest -O option and overwrites the previous
one, which breaks command line using multiple -O options like
osgviewer -O <options1> file1 -O <option2> <file2>
The appended sequence diagram shows the related calls.
Do you have any advice how to fix this issue(s) ?
Cheers
Ralf
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org