]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
HTML for comments and colors.
[lyx.git] / src / Buffer.cpp
index 5236a627acc9d0377a596d77be038a95e44371f8..1a47fdf5bded72eaab8c0524a35b35b7518cd508 100644 (file)
@@ -126,7 +126,7 @@ namespace {
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-int const LYX_FORMAT = 378; // ps: rev insetinfo
+int const LYX_FORMAT = 381; // vfr: new parameters for xymatrix
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@@ -975,6 +975,17 @@ Buffer::ReadStatus Buffer::readFile(Lexer & lex, FileName const & filename,
 // Should probably be moved to somewhere else: BufferView? GuiView?
 bool Buffer::save() const
 {
+       // ask if the disk file has been externally modified (use checksum method)
+       if (fileName().exists() && isExternallyModified(checksum_method)) {
+               docstring const file = makeDisplayPath(absFileName(), 20);
+               docstring text = bformat(_("Document %1$s has been externally modified. Are you sure "
+                                                            "you want to overwrite this file?"), file);
+               int const ret = Alert::prompt(_("Overwrite modified file?"),
+                       text, 1, 1, _("&Overwrite"), _("&Cancel"));
+               if (ret == 1)
+                       return false;
+       }
+
        // We don't need autosaves in the immediate future. (Asger)
        resetAutosaveTimers();
 
@@ -990,7 +1001,7 @@ bool Buffer::save() const
                        backupName = FileName(addName(lyxrc.backupdir_path,
                                                      mangledName));
                }
-               if (fileName().copyTo(backupName)) {
+               if (fileName().moveTo(backupName)) {
                        madeBackup = true;
                } else {
                        Alert::error(_("Backup failure"),
@@ -1001,17 +1012,6 @@ bool Buffer::save() const
                }
        }
 
-       // ask if the disk file has been externally modified (use checksum method)
-       if (fileName().exists() && isExternallyModified(checksum_method)) {
-               docstring const file = makeDisplayPath(absFileName(), 20);
-               docstring text = bformat(_("Document %1$s has been externally modified. Are you sure "
-                                                            "you want to overwrite this file?"), file);
-               int const ret = Alert::prompt(_("Overwrite modified file?"),
-                       text, 1, 1, _("&Overwrite"), _("&Cancel"));
-               if (ret == 1)
-                       return false;
-       }
-
        if (writeFile(d->filename)) {
                markClean();
                return true;
@@ -1050,7 +1050,8 @@ bool Buffer::writeFile(FileName const & fname) const
                return false;
        }
 
-       removeAutosaveFile();
+       // see bug 6587
+       // removeAutosaveFile();
 
        saveCheckSum(d->filename);
        message(str + _(" done."));
@@ -2971,11 +2972,11 @@ void Buffer::getSourceCode(odocstream & os, pit_type par_begin,
 ErrorList & Buffer::errorList(string const & type) const
 {
        static ErrorList emptyErrorList;
-       map<string, ErrorList>::iterator I = d->errorLists.find(type);
-       if (I == d->errorLists.end())
+       map<string, ErrorList>::iterator it = d->errorLists.find(type);
+       if (it == d->errorLists.end())
                return emptyErrorList;
 
-       return I->second;
+       return it->second;
 }
 
 
@@ -3300,17 +3301,26 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
        bool const success = theConverters().convert(this, FileName(filename),
                tmp_result_file, FileName(absFileName()), backend_format, format,
                error_list);
-       // Emit the signal to show the error list.
+
+       // Emit the signal to show the error list or copy it back to the
+       // cloned Buffer so that it cab be emitted afterwards.
        if (format != backend_format) {
-               errors(error_type);
+               if (d->cloned_buffer_) {
+                       d->cloned_buffer_->d->errorLists[error_type] = 
+                               d->errorLists[error_type];
+               } else 
+                       errors(error_type);
                // also to the children, in case of master-buffer-view
                std::vector<Buffer *> clist = getChildren();
                for (vector<Buffer *>::const_iterator cit = clist.begin();
-                    cit != clist.end(); ++cit)
-                       (*cit)->errors(error_type, true);
+                       cit != clist.end(); ++cit) {
+                       if (d->cloned_buffer_) {
+                               (*cit)->d->cloned_buffer_->d->errorLists[error_type] = 
+                                       (*cit)->d->errorLists[error_type];
+                       } else
+                               (*cit)->errors(error_type, true);
+               }
        }
-       if (!success)
-               return false;
 
        if (d->cloned_buffer_) {
                // Enable reverse dvi or pdf to work by copying back the texrow
@@ -3318,8 +3328,13 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
                // FIXME: There is a possibility of concurrent access to texrow
                // here from the main GUI thread that should be securized.
                d->cloned_buffer_->d->texrow = d->texrow;
+               string const error_type = bufferFormat();
+               d->cloned_buffer_->d->errorLists[error_type] = d->errorLists[error_type];
        }
 
+       if (!success)
+               return false;
+
        if (put_in_tempdir) {
                result_file = tmp_result_file.absFilename();
                return true;
@@ -3854,8 +3869,7 @@ void Buffer::updateBuffer(ParIterator & parit, UpdateType utype) const
                InsetList::const_iterator end = parit->insetList().end();
                for (; iit != end; ++iit) {
                        parit.pos() = iit->pos;
-                       if (!parit->isDeleted(iit->pos))
-                               iit->inset->updateBuffer(parit, utype);
+                       iit->inset->updateBuffer(parit, utype);
                }
        }
 }
@@ -3914,6 +3928,9 @@ bool Buffer::reload()
                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);
        errors("Parse");
        return success;
 }