Hi Robert,
I guess what I am trying to convey is that the successful (FILE_SAVED)
code paths works correctly, the Chain-Of-Responsibility for that case
works fine (first to succeed wins). The problem is when I try to write a
file that is not writable (i.e. try to write to a file that is open by
another process, or a file that I do not have permission to write to).
That is, the case where no ReaderWriter can succeed because the file is
simply not writable.
The following paragraphs are within the context of the
osgDB::Registry::writeNodeImplementation() function.
For example, when attempting to export a scene to an *.osgb file, the
first loop tries to call writeNode() on a single ReaderWriter.
NOT_IMPLEMENTED status gets pushed on the result vector and the vector
is cleared. Then, 2 plugins are explicitly loaded when loadLibrary() is
called. The 2 plugins that are loaded are associated with the
OSGReaderWriter, and ReaderWriterOSG2 classes. The
OSGReaderWriter::writeNode() call fails with FILE_NOT_HANDED (which is
correct since we requested *.osgb file extension) and the result is
pushed onto the result vector. Then, ReaderWriterOSG2::writeNode() fails
with ERROR_IN_WRITING file (ok, this makes sense). The problem is that
the function returns results.front() which is the error code associated
with OSGReaderWriter (in this case FILE_NOT_HANDLED with message
"Warning: Write to "filename" not supported"). It should have returned
the error associated with ReaderWriterOSG2 (the *.osgb writer) which
returned an error status of ERROR_IN_WRITING "Warning: Error in writing
to "filename".".
Now, the second time through (export the same file again), the following
happens. All of the writers fail with various error statuses (same
statuses as before). The result vector is cleared, and no plugins are
loaded (since they were loaded the first time the export was attempted).
The results vector is empty, so the function returns "Warning: Could not
find plugin to write nodes to file..." with error status of
FILE_NOT_HANDLED. However, that error status and message are not correct
because the file extension (*.osgb) is handled and the plugin was found
and loaded... it just could not be written.
I hope this makes sense. Let me know if I can clarify anything.
Regards,
Judson
On 6/10/2013 4:47 PM, Robert Osfield wrote:
Hi Judson,
On 10 June 2013 21:12, Judson Weissert <[email protected]> wrote:
One of the major behavior changes is that once ERROR_IN_WRITING_FILE is
encountered, no more attempts are made to write the file.
This breaks the Chain-Of-Responsibility design pattern used by the
plugins, it's up to plugins whether or not that can handle a
particular file or not, it's not the position of the Registry to not
call plugins in case of another plugins failure, it's up to the
plugins themselves. I am not about to merge changes that breaks this
long standing mechanism.
If you want to override the Registry to change this mechanism then I'm
open to making the appropriate methods virtual if they aren't already.
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