Fix #2648 - Studio: shapes imported after "Save As" fail with "Error reading" - #2651
Merged
Merged
Conversation
boost::filesystem::is_regular_file() opens a file handle on Windows and reports false whenever that fails, so files that VTK and ITK read without trouble were rejected before the reader ever saw them. Use vtksys for the existence checks, which queries attributes and only opens a handle for reparse points, and imbue boost's path with a UTF-8 codecvt at startup so the remaining boost calls stop mangling non-ASCII paths. Also makes Project::set_project_path tolerant when a path can't be re-anchored to a new project location, so one awkward path no longer silently skips the rewrite or fails the entire save.
Including boost/nowide/utf8_codecvt.hpp emits the auto-link pragma for boost_nowide.lib, which the Windows dependency build does not produce, failing the link. The codecvt facet is entirely header-only, so define BOOST_NOWIDE_NO_LIB ahead of every Boost header to opt out of auto-linking.
VTK's legacy .vtk reader stats the file before opening it, and on Windows that stat deliberately omits the \\?\ prefix, so a path beyond MAX_PATH can be written but never read back. The STL reader and writer go through SystemTools::Fopen, which applies the prefix, so they exercise what the test is actually about: that the existence check no longer rejects such a path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make file existence checks agree with the mesh and image readers
boost::filesystem::is_regular_file() opens a file handle on Windows and reports false whenever that fails, so files that VTK and ITK read without trouble were rejected before the reader ever saw them. Use vtksys for the existence checks, which queries attributes and only opens a handle for reparse points, and imbue boost's path with a UTF-8 codecvt at startup so the remaining boost calls stop mangling non-ASCII paths.
Also makes Project::set_project_path tolerant when a path can't be re-anchored to a new project location, so one awkward path no longer silently skips the rewrite or fails the entire save.