Closed rcmz closed 1 year ago
What's the precise error message?
I wonder if this is caused by it trying to read the STL while the library is partway through writing it.
That was my thought as well; although the fileChanged
signal from the QFileSystemWatcher
shouldn't be emitted until after the file is modified. That should be after writing is done right?
That's what I thought too, but I did some testing and it doesn't appear to be the case. I could be wrong thought.
The error message is : Window::on_bad_stl()
@rcmz Would you be willing to share the python code your using to cause the issue to occur?
Sure, the python code is just a wrapper around libfive.h
.
Here is a important bit :
def save_mesh(self, region, resolution, file_name):
return libfive.libfive_tree_save_mesh(self.ptr, region, resolution, str.encode(file_name))
The full code is available at https://gitlab.com/rcmz0/libfivepy/blob/master/libfive/kernel.py
Yeah, the fact that you don't see the error when you open it manually makes me think that there's something going wrong in the autoreloading. If you're interested in debugging, I'd recommend putting a few logging statements around the file load function to see what's causing that error message to be emitted.
I suspect that it's reading the first few bytes of the file (which tell how long the file is) before libfive
is done writing all of its data, but I'm not sure how to guarantee when the "file modified" signal is emitted.
I too am having this issue, Compiling STL's from OpenSCAD. FSTL is popping up with this error about half a second before my console says it's finished. Then FSTL reloads the file perfectly simultaneous with the console finishing, Off the top of my head either reloading on the second fileChanged
or adding a delay could jerry-rig it for these situations, but both rely on either what is potentially essentially a glitch in the other program or an arbitrary number that could easily be too small or too large for any given file.
Perhaps in lieu of a real solution a toggle for my first suggestion could help for the time being. (Assuming of course the file reloading properly is because it retriggers the fileChanged
and isn't just a delayed reaction)
It needs to write to a tempfile first, then rename it to the file fstl is loading. Thats the only way to be atomic.
Hi all,
I just merged in a PR that should address this issue. If anyone can test and confirm I would be grateful. Closing this for now
If you open an libfivepy generated stl file with fstl and set it to auto-reload; every time you regenerate the stl (with libfivepy) fstl say it is corrupted. Which is strange because it display the stl fine and it doesn't occur when you load the file manually.
This is probably a libfivepy issue but here is a post anyway.
Link to the thread on libfivepy: https://gitlab.com/rcmz0/libfivepy/issues/4