From e93092e72b6240f087315cc8775b09d3cbcfdd32 Mon Sep 17 00:00:00 2001 From: Julien Rioux Date: Sat, 3 Dec 2011 22:58:38 +0000 Subject: [PATCH] Remove the .aux and .bbl files when we switch the citation engine or style. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40355 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 18 ++++++++++++++++++ src/Buffer.h | 3 +++ src/frontends/qt4/GuiDocument.cpp | 2 ++ src/insets/InsetBibtex.cpp | 6 +++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 17d166acea..ae3e294ff7 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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); diff --git a/src/Buffer.h b/src/Buffer.h index 068d160272..62e03a4652 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -484,6 +484,9 @@ public: /// void getLabelList(std::vector &) const; + /// This removes the .aux and .bbl files from the temp dir. + void removeBiblioTempFiles() const; + /// void changeLanguage(Language const * from, Language const * to); diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index e5dc50d74d..bb643dae45 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -2246,6 +2246,8 @@ void GuiDocument::applyView() else bp_.bibtex_command = bibtex_command + " " + bibtex_options; + buffer().removeBiblioTempFiles(); + // Indices indicesModule->apply(bp_); diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 2544a493d3..ac21162b9b 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -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; } -- 2.39.2