]> git.lyx.org Git - features.git/commitdiff
In the meantime that we decide whether to introduce menu choices for
authorEnrico Forestieri <forenr@lyx.org>
Sun, 18 Apr 2010 10:54:43 +0000 (10:54 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sun, 18 Apr 2010 10:54:43 +0000 (10:54 +0000)
both dvi and pdf, let's allow switching forward search from one format
to the other through a timestamp check, such that the most recent
generated format will be used.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34200 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.cpp

index 204b3568e01edf9f9d77c6d393f1a8f77a0c9a21..98169a9964189bff2c115b8de9fc97cd4eca52f1 100644 (file)
@@ -3223,20 +3223,27 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        break;
 
                case LFUN_FORWARD_SEARCH: {
-                       string command = lyxrc.forward_search_dvi;
                        FileName const path(doc_buffer->temppath());
                        string const texname = doc_buffer->latexName();
-                       string outname = support::changeExtension(texname, "dvi");
-                       if (!FileName(addName(path.absFilename(), outname)).exists()) {
-                               outname = support::changeExtension(texname, "pdf");
+                       FileName const dviname(addName(path.absFilename(),
+                                   support::changeExtension(texname, "dvi")));
+                       FileName const pdfname(addName(path.absFilename(),
+                                   support::changeExtension(texname, "pdf")));
+                       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;
-                               if (!FileName(addName(path.absFilename(), outname)).exists())
-                                       break;
                        }
 
                        int row = doc_buffer->texrow().getRowFromIdPos(bv->cursor().paragraph().id(), bv->cursor().pos());
                        LYXERR(Debug::ACTION, "Forward search: row:" << row
-                                               << " id:" << bv->cursor().paragraph().id() << "\n");
+                               << " id:" << bv->cursor().paragraph().id());
                        if (!row || command.empty()) {
                                dr.setMessage(_("Couldn't proceed."));
                                break;