On 12/03/2011 05:58 PM, [email protected] wrote:
> Author: jrioux
> Date: Sat Dec 3 23:58:38 2011
> New Revision: 40355
> URL: http://www.lyx.org/trac/changeset/40355
>
> Log:
> Remove the .aux and .bbl files when we switch the citation engine or style.
>
While you're at this, can you see if you managed to fix #4899 by
accident? or if these changes will allow an easy fix? Another related
bug may be #6494.
Richard
> Modified:
> lyx-devel/trunk/src/Buffer.cpp
> lyx-devel/trunk/src/Buffer.h
> lyx-devel/trunk/src/frontends/qt4/GuiDocument.cpp
> lyx-devel/trunk/src/insets/InsetBibtex.cpp
>
> Modified: lyx-devel/trunk/src/Buffer.cpp
> ==============================================================================
> --- lyx-devel/trunk/src/Buffer.cpp Sat Dec 3 23:44:22 2011 (r40354)
> +++ lyx-devel/trunk/src/Buffer.cpp Sat Dec 3 23:58:38 2011 (r40355)
> @@ -2036,6 +2036,24 @@
> }
>
>
> +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);
>
> Modified: lyx-devel/trunk/src/Buffer.h
> ==============================================================================
> --- lyx-devel/trunk/src/Buffer.h Sat Dec 3 23:44:22 2011 (r40354)
> +++ lyx-devel/trunk/src/Buffer.h Sat Dec 3 23:58:38 2011 (r40355)
> @@ -484,6 +484,9 @@
> ///
> 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);
>
>
> Modified: lyx-devel/trunk/src/frontends/qt4/GuiDocument.cpp
> ==============================================================================
> --- lyx-devel/trunk/src/frontends/qt4/GuiDocument.cpp Sat Dec 3 23:44:22
> 2011 (r40354)
> +++ lyx-devel/trunk/src/frontends/qt4/GuiDocument.cpp Sat Dec 3 23:58:38
> 2011 (r40355)
> @@ -2246,6 +2246,8 @@
> else
> bp_.bibtex_command = bibtex_command + " " + bibtex_options;
>
> + buffer().removeBiblioTempFiles();
> +
> // Indices
> indicesModule->apply(bp_);
>
>
> Modified: lyx-devel/trunk/src/insets/InsetBibtex.cpp
> ==============================================================================
> --- lyx-devel/trunk/src/insets/InsetBibtex.cpp Sat Dec 3 23:44:22
> 2011 (r40354)
> +++ lyx-devel/trunk/src/insets/InsetBibtex.cpp Sat Dec 3 23:58:38
> 2011 (r40355)
> @@ -59,13 +59,16 @@
> : InsetCommand(buf, p)
> {
> buffer().invalidateBibinfoCache();
> + buffer().removeBiblioTempFiles();
> }
>
>
> InsetBibtex::~InsetBibtex()
> {
> - if (isBufferLoaded())
> + if (isBufferLoaded()) {
> buffer().invalidateBibfileCache();
> + buffer().removeBiblioTempFiles();
> + }
> }
>
>
> @@ -108,6 +111,7 @@
> cur.recordUndo();
> setParams(p);
> buffer().invalidateBibfileCache();
> + buffer().removeBiblioTempFiles();
> cur.forceBufferUpdate();
> break;
> }