[RFC][PATCH] Change to buffer lookup for given temporary files

Stephan Witt st.witt at gmx.net
Tue Feb 18 08:43:07 UTC 2020


Hi all,

because of a change in behavior of Qt on Mac we have to make the
buffer lookup for a given temporary file more robust.

The root cause of this is the fact that on Mac temporary files
are reachable by more then one file name because of directory
/var being a symbolic link to /private/var. So the file names
/var/tmp/foo/bar.tex and /private/var/tmp/foo/bar.tex are fact
pointing to the same file.

The existing implementation GuiView::goToFileRow() assumes if there
is a difference between the temp directory (e.g. /var/tmp) and its
real path name (/private/var/tmp) than the file name of the
temporary file has to be adjusted to be based on temp directory
for buffer lookup because of buffers are using this directory.

The real life shows there is another possible combination here:
the query for the system temporary directory may return the real
path name instead of the shorter logical temp directory (on Mac
this happens with Qt 5.12.6 at least). Nevertheless it’s legal
to pass the shorter file name as argument to LyX’s command
LFUN_SERVER_GOTO_FILE_ROW and this happens also on Mac with Skim
on SyncTeX reverse search (PDF viewer => TeX editor/LyX).

Now the buffer lookup fails because of the file name being too
short. One solution is to convert the file name to real path name
and convert it to the short one back in case of temporary directory
having the shorter logical path name. The more stable and easier to
read solution would be to use real path names on buffer lookup
always, IMO. The attached patch does this. It works very well on Mac.

Because I’m unable to test it with other PDF viewers with SyncTeX
support and/or to test it on Linux and Windows I post the patch
and it would be nice if you can test if it breaks something used
to work.

[Note: the patch contains a simplification to the lyxeditor script
to stop fiddling with the file name. This was a hack in the past, IMO.
It was not needed anymore and had no effect because of Skim passing the
logical file name to lyxeditor already and because of LyX binary doing
the same file name adjustment.]

Thanks,
Stephan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: goToFileRow-5.patch
Type: application/octet-stream
Size: 3790 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20200218/82ba8b08/attachment.obj>


More information about the lyx-devel mailing list