]> git.lyx.org Git - lyx.git/commitdiff
Remove the .aux and .bbl files when we switch the citation engine or style.
authorJulien Rioux <jrioux@lyx.org>
Sat, 3 Dec 2011 22:58:38 +0000 (22:58 +0000)
committerJulien Rioux <jrioux@lyx.org>
Sat, 3 Dec 2011 22:58:38 +0000 (22:58 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40355 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Buffer.h
src/frontends/qt4/GuiDocument.cpp
src/insets/InsetBibtex.cpp

index 17d166aceaad1f716184617d6bab406745571fe2..ae3e294ff79ab1edd6c0ee8e262297e29b9cd748 100644 (file)
@@ -2036,6 +2036,24 @@ bool Buffer::citeLabelsValid() const
 }
 
 
+void Buffer::removeBiblioTempFiles() const
+{
+       // We remove files that contain LaTeX commands specific to the
+       // particular bibliographic style being used, in order to avoid
+       // LaTeX errors when we switch style.
+       FileName const aux_file(addName(temppath(), changeExtension(latexName(),".aux")));
+       FileName const bbl_file(addName(temppath(), changeExtension(latexName(),".bbl")));
+       LYXERR(Debug::FILES, "Removing the .aux file " << aux_file);
+       aux_file.removeFile();
+       LYXERR(Debug::FILES, "Removing the .bbl file " << bbl_file);
+       bbl_file.removeFile();
+       // Also for the parent buffer
+       Buffer const * const pbuf = parent();
+       if (pbuf)
+               pbuf->removeBiblioTempFiles();
+}
+
+
 bool Buffer::isDepClean(string const & name) const
 {
        DepClean::const_iterator const it = d->dep_clean.find(name);
index 068d160272c4033d3fb4844b610a6ffafe7a54f6..62e03a4652a8418b7666a4f44c63a8bd81ab06a6 100644 (file)
@@ -484,6 +484,9 @@ public:
        ///
        void getLabelList(std::vector<docstring> &) const;
 
+       /// This removes the .aux and .bbl files from the temp dir.
+       void removeBiblioTempFiles() const;
+
        ///
        void changeLanguage(Language const * from, Language const * to);
 
index e5dc50d74d9da6aa2782c633deff12e0ade2a9e7..bb643dae45893201f688ddabf995cb21f1b87242 100644 (file)
@@ -2246,6 +2246,8 @@ void GuiDocument::applyView()
        else
                bp_.bibtex_command = bibtex_command + " " + bibtex_options;
 
+       buffer().removeBiblioTempFiles();
+
        // Indices
        indicesModule->apply(bp_);
 
index 2544a493d39a686588557b44d291fae989c0d337..ac21162b9b59c259d6b170fc8bf63e32fbb8d070 100644 (file)
@@ -59,13 +59,16 @@ InsetBibtex::InsetBibtex(Buffer * buf, InsetCommandParams const & p)
        : InsetCommand(buf, p)
 {
        buffer().invalidateBibinfoCache();
+       buffer().removeBiblioTempFiles();
 }
 
 
 InsetBibtex::~InsetBibtex()
 {
-       if (isBufferLoaded())
+       if (isBufferLoaded()) {
                buffer().invalidateBibfileCache();
+               buffer().removeBiblioTempFiles();
+       }
 }
 
 
@@ -108,6 +111,7 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.recordUndo();
                setParams(p);
                buffer().invalidateBibfileCache();
+               buffer().removeBiblioTempFiles();
                cur.forceBufferUpdate();
                break;
        }