I came across strange behavior today on master branch (master because
the LFUN I reference below was only implemented on master):

1. type "abc" and view a PDF.
2. close the PDF that is opened.
3. execute "buffer-view-cache" in the mini-buffer.
4. close the PDF and then delete the file from the terminal.
5. execute "buffer-view-cache" in the mini-buffer.

After (5), the PDF viewer is opened for a file that does not exist.
This should not happen because LFUN_BUFFER_VIEW_CACHE is only enabled
if the file exists, but exists() returns true. I think the reason for
this is explained by the following:

-----
(source: http://doc.qt.io/qt-4.8/qfileinfo.html)
To speed up performance, QFileInfo caches information about the file.
Because files can be changed by other users or programs, or even by
other parts of the same program, there is a function that refreshes
the file information: refresh(). If you want to switch off a
QFileInfo's caching and force it to access the file system every time
you request information from it call setCaching(false).
-----

Indeed, adding d->fi.refresh(); before the call to QFileInfo's
exists() in our FileName::exists() method does "fix" the behavior I
describe above.

I understand that caching exists for good reason, but since LyX relies
on so many external programs, I wonder if QFileInfo's caching is right
for LyX's purposes.

The use case that lead to my example given at the top is not a common
one. However, I wonder if there could be other bugs that are more
serious that result from this behavior.

Any thoughts?

Scott

Reply via email to