]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
InsetTabular.cpp: multirows inherit the width and the alignment from the column;...
[lyx.git] / src / Buffer.cpp
index 6115a4076285c1410473ec748bc6ba3bff69935b..5bd73da715315da24f5f00effdb0757f195ba092 100644 (file)
@@ -414,9 +414,8 @@ Buffer::~Buffer()
                        from_utf8(d->temppath.absFileName())));
        }
 
-       // Remove any previewed LaTeX snippets associated with this buffer.
        if (!isClone())
-               thePreviews().removeLoader(*this);
+               removePreviews();
 
        delete d;
 }
@@ -889,6 +888,7 @@ Buffer::ReadStatus Buffer::readFile(FileName const & fn)
        lyxvc().file_found_hook(fn);
        d->read_only = !fname.isWritable();
        params().compressed = fname.isZippedFile();
+       saveCheckSum();
        return ReadSuccess;
 }
 
@@ -905,6 +905,19 @@ void Buffer::setFullyLoaded(bool value)
 }
 
 
+void Buffer::updatePreviews() const
+{
+       if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
+               thePreviews().generateBufferPreviews(*this);
+}
+
+
+void Buffer::removePreviews() const
+{
+       thePreviews().removeLoader(*this);
+}
+
+
 Buffer::ReadStatus Buffer::parseLyXFormat(Lexer & lex,
        FileName const & fn, int & file_format) const
 {
@@ -1071,7 +1084,7 @@ bool Buffer::writeFile(FileName const & fname) const
        // see bug 6587
        // removeAutosaveFile();
 
-       saveCheckSum(d->filename);
+       saveCheckSum();
        message(str + _(" done."));
 
        return true;
@@ -2369,8 +2382,9 @@ bool Buffer::isExternallyModified(CheckMethod method) const
 }
 
 
-void Buffer::saveCheckSum(FileName const & file) const
+void Buffer::saveCheckSum() const
 {
+       FileName const & file = d->filename;
        if (file.exists()) {
                d->timestamp_ = file.lastModified();
                d->checksum_ = file.checksum();
@@ -2761,8 +2775,11 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
                        }
 
                        InsetMath * im = iit->inset->asInsetMath();
-                       if (doing_export && im)
-                               im->asHullInset()->recordLocation(it);
+                       if (doing_export && im)  {
+                               InsetMathHull * hull = im->asHullInset();
+                               if (hull)
+                                       hull->recordLocation(it);
+                       }
 
                        if (iit->inset->lyxCode() != MATHMACRO_CODE)
                                continue;
@@ -3632,7 +3649,6 @@ Buffer::ReadStatus Buffer::loadEmergency(FileName const & fn)
                ReadStatus const ret_llf = loadThisLyXFile(emergencyFile);
                bool const success = (ret_llf == ReadSuccess);
                if (success) {
-                       saveCheckSum(fn);
                        markDirty();
                        str = _("Document was successfully recovered.");
                } else
@@ -3689,7 +3705,6 @@ Buffer::ReadStatus Buffer::loadAutosave(FileName const & fn)
                // the file is not saved if we load the autosave file.
                if (ret_llf == ReadSuccess) {
                        markDirty();
-                       saveCheckSum(fn);
                        return ReadSuccess;
                }
                return ReadAutosaveFailure;
@@ -4093,7 +4108,7 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & to,
 }
 
 
-bool Buffer::reload()
+Buffer::ReadStatus Buffer::reload()
 {
        setBusy(true);
        // c.f. bug 6587
@@ -4102,23 +4117,21 @@ bool Buffer::reload()
        d->filename.refresh();
        docstring const disp_fn = makeDisplayPath(d->filename.absFileName());
 
-       bool const success = (loadLyXFile(d->filename) == ReadSuccess);
-       if (success) {
+       ReadStatus const status = loadLyXFile(d->filename);
+       if (status == ReadSuccess) {
                updateBuffer();
                changed(true);
                updateTitles();
                markClean();
-               saveCheckSum(d->filename);
                message(bformat(_("Document %1$s reloaded."), disp_fn));
        } else {
                message(bformat(_("Could not reload document %1$s."), disp_fn));
        }       
        setBusy(false);
-       thePreviews().removeLoader(*this);
-       if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
-               thePreviews().generateBufferPreviews(*this);
+       removePreviews();
+       updatePreviews();
        errors("Parse");
-       return success;
+       return status;
 }