commit 74160640337b63b1fb21c9690289f0ebb29c0820
Author: Scott Kostyshak <skost...@lyx.org>
Date:   Fri Mar 20 00:13:50 2015 -0400

    Assert if successful export but no output file
    
    If LyX thinks the export was successful but no output file was
    produced for preview, then something is wrong (most likely LyX
    did not detect an error that occurred during export).
    
    Also clean up some logic.

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index e045e01..dd18db2 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -4213,9 +4213,21 @@ Buffer::ExportStatus Buffer::preview(string const & 
format, bool includeall) con
        // (2) export with included children only
        ExportStatus const status = doExport(format, true, false, result_file);
        FileName const previewFile(result_file);
-       if (previewFile.exists() && !formats.view(*this, previewFile, format))
-               return PreviewError;
-       return (status == ExportSuccess) ? PreviewSuccess : status;
+       if (previewFile.exists()) {
+               if (!formats.view(*this, previewFile, format))
+                       return PreviewError;
+               else if (status == ExportSuccess)
+                       return PreviewSuccess;
+               else
+                       return status;
+       }
+       else {
+               // Successful export but no output file?
+               // Probably a bug in error detection.
+               LATTEST (status != ExportSuccess);
+
+               return status;
+       }
 }
 
 
diff --git a/src/Buffer.h b/src/Buffer.h
index 9ff7752..05cf8aa 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -134,7 +134,10 @@ public:
                ExportTexPathHasSpaces,
                ExportConverterError,
                // preview
+               // Implies ExportSuccess.
                PreviewSuccess,
+               // The exported file exists but there was an error when opening
+               // it in a viewer.
                PreviewError
        };
 

Reply via email to