]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/PreviewLoader.cpp
whitespace only
[lyx.git] / src / graphics / PreviewLoader.cpp
index cec05ed714c717df4e21fe59eb3756bb03a699c7..88320e4517b5106ce3cd1d13f7177b2a9a4cdcef 100644 (file)
@@ -411,8 +411,13 @@ PreviewLoader::Impl::Impl(PreviewLoader & p, Buffer const & b)
        : parent_(p), buffer_(b), finished_generating_(true)
 {
        font_scaling_factor_ = int(buffer_.fontScalingFactor());
-       fg_color_ = strtol(theApp()->hexName(foregroundColor()).c_str(), 0, 16);
-       bg_color_ = strtol(theApp()->hexName(backgroundColor()).c_str(), 0, 16);
+       if (theApp()) {
+               fg_color_ = strtol(theApp()->hexName(foregroundColor()).c_str(), 0, 16);
+               bg_color_ = strtol(theApp()->hexName(backgroundColor()).c_str(), 0, 16);
+       } else {
+               fg_color_ = 0x0;
+               bg_color_ = 0xffffff;
+       }
        if (!pconverter_)
                pconverter_ = setConverter("lyxpreview");
 
@@ -439,8 +444,12 @@ PreviewImage const *
 PreviewLoader::Impl::preview(string const & latex_snippet) const
 {
        int fs = int(buffer_.fontScalingFactor());
-       int fg = strtol(theApp()->hexName(foregroundColor()).c_str(), 0, 16);
-       int bg = strtol(theApp()->hexName(backgroundColor()).c_str(), 0, 16);
+       int fg = 0x0;
+       int bg = 0xffffff;
+       if (theApp()) {
+               fg = strtol(theApp()->hexName(foregroundColor()).c_str(), 0, 16);
+               bg = strtol(theApp()->hexName(backgroundColor()).c_str(), 0, 16);
+       }
        if (font_scaling_factor_ != fs || fg_color_ != fg || bg_color_ != bg) {
                // Schedule refresh of all previews on zoom or color changes.
                // The previews are regenerated only after the zoom factor
@@ -630,6 +639,11 @@ void PreviewLoader::Impl::startLoading(bool wait)
        }
        of << "\\batchmode\n";
 
+       // Set \jobname of previews to the document name (see bug 9627)
+       of << "\\def\\jobname{"
+          << from_utf8(changeExtension(buffer_.latexName(true), ""))
+          << "}\n";
+
        LYXERR(Debug::LATEX, "Format = " << buffer_.params().getDefaultOutputFormat());
        string latexparam = "";
        bool docformat = !buffer_.params().default_output_format.empty()