Christopher Menzel writes: > > On May 23, 2011, at 3:33 PM, Enrico Forestieri wrote: > > Christopher Menzel writes: > >> > >> That is, LyX is calling the appropriate forward search command for a PDF > >> preview document, not DVI. > > > > LyX performs a forward search for the last generated format, so it means > > that you generated a pdf after the dvi, even if you quitted the pdf viewer > > and are now previewing the dvi. > > Sorry, I guess I'm confused about the semantics of "generating a format" > versus "previewing". What more do I have to do to "generate a format" > beyond previewing?
If you hit the "update" button, a given format is generated (produced) in the temp dir, but a previewer is not started. > From the documentation it appears that all I should > have to do is generate a dvi preview: > > Forward search works both with DVI and PDF output. LyX simply > checks which preview format you have used before (i.e., which > format is already there in the temporary directory) and chooses > the appropriate configuration for the respective format. > > I have done that; the only thing in the Temp directory is a DVI file > for my document. There is no sign of any PDF. So, let's see whether we can solve this mystery by looking at the code. The following is the relevant snippet in src/frontends/qt4/GuiView.cpp: if (!dviname.exists() && !pdfname.exists()) { dr.setMessage(_("Please, preview the document first.")); break; } string outname = dviname.onlyFileName(); string command = lyxrc.forward_search_dvi; if (!dviname.exists() || pdfname.lastModified() > dviname.lastModified()) { outname = pdfname.onlyFileName(); command = lyxrc.forward_search_pdf; } Firstly, LyX checks whether a dvi or pdf was generated. If not, the message "Please, preview the document first." is issued. Then, LyX assumes that you generated a dvi, but if no dvi exists or the pdf is newer than the dvi, a pdf format is assumed. Note that if no pdf exists, pdfname.lastModified() returns -1 and the check pdfname.lastModified() > dviname.lastModified() is never true. Thus, if no pdf exists a dvi forward search is always attempted. Anyway, you say that a pdf search is tried, even if no pdf is in sight. Let's se how that could happen. The lastModified() method returns a time_t type, which is a signed type on all machines and compilers I have access to. However, I don't have access to the MSVC compiler, which is the one used for the Windows version you are using, most probably. I am able to compile a Windows version with the MinGW compiler, and there it works. So, the only way that a pdf search could be attempted is if the time_t type is an unsigned type for the MSVC compiler. Indeed, in that case, the -1 would be interpreted as the greatest possible value and the check pdfname.lastModified() > dviname.lastModified() would be always true. I have no way to check that and someone building LyX with MSVC should perform that test. It would suffice adding the line lyxerr << "pdf: " << pdfname.lastModified() << endl; just before that snippet, trying a forward search with only a dvi generated and looking at what is printed. If the result is pdf: -1 the mystery remains unsolved (I always get that), but if it prints something like pdf: 2147483647 we found the bug. So, can anyone compiling LyX with MSVC perform that check? -- Enrico