diff --git a/src/Buffer.cpp b/src/Buffer.cpp index f6773d59c9..c564a7dccf 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2446,15 +2446,16 @@ void Buffer::reloadBibInfoCache() const return; d->bibinfo_.clear(); - collectBibKeys(); + FileNameList checkedFiles; + collectBibKeys(checkedFiles); d->bibinfo_cache_valid_ = true; } -void Buffer::collectBibKeys() const +void Buffer::collectBibKeys(FileNameList & checkedFiles) const { for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) - it->collectBibKeys(it); + it->collectBibKeys(it, checkedFiles); } diff --git a/src/Buffer.h b/src/Buffer.h index 6d50e705eb..0bfe18f40f 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -17,6 +17,7 @@ #include "support/unique_ptr.h" #include "support/strfwd.h" #include "support/types.h" +#include "support/FileNameList.h" #include #include @@ -520,7 +521,7 @@ public: /// or just for it, if it isn't a child. BiblioInfo const & masterBibInfo() const; /// collect bibliography info from the various insets in this buffer. - void collectBibKeys() const; + void collectBibKeys(support::FileNameList &) const; /// add some BiblioInfo to our cache void addBiblioInfo(BiblioInfo const & bi) const; /// add a single piece of bibliography info to our cache diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 578a7f4d5a..94e9d1a668 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -23,6 +23,7 @@ #include "support/strfwd.h" #include "support/types.h" +#include "support/FileNameList.h" #include @@ -529,7 +530,7 @@ public: UpdateType /* utype*/, TocBackend & /* tocbackend */) const {} /// Collect BibTeX information - virtual void collectBibKeys(InsetIterator const &) const {} + virtual void collectBibKeys(InsetIterator const &, support::FileNameList &) const {} /// Update the counters of this inset and of its contents. /// The boolean indicates whether we are preparing for output, e.g., /// of XHTML. diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index afc30ae37d..d5ebaf7640 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -285,7 +285,7 @@ docstring bibitemWidest(Buffer const & buffer, OutputParams const & runparams) } -void InsetBibitem::collectBibKeys(InsetIterator const & it) const +void InsetBibitem::collectBibKeys(InsetIterator const & it, FileNameList & /*checkedFiles*/) const { docstring const key = getParam("key"); docstring const label = getParam("label"); diff --git a/src/insets/InsetBibitem.h b/src/insets/InsetBibitem.h index 41497e1849..ba33732ad0 100644 --- a/src/insets/InsetBibitem.h +++ b/src/insets/InsetBibitem.h @@ -60,7 +60,7 @@ public: /// docstring xhtml(XHTMLStream &, OutputParams const &) const; /// - void collectBibKeys(InsetIterator const &) const; + void collectBibKeys(InsetIterator const &, support::FileNameList &) const; /// update the counter of this inset void updateBuffer(ParIterator const &, UpdateType); ///@} diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index a905110773..30b169acb0 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -645,13 +645,13 @@ namespace { } // namespace -void InsetBibtex::collectBibKeys(InsetIterator const & /*di*/) const +void InsetBibtex::collectBibKeys(InsetIterator const & /*di*/, FileNameList & checkedFiles) const { - parseBibTeXFiles(); + parseBibTeXFiles(checkedFiles); } -void InsetBibtex::parseBibTeXFiles() const +void InsetBibtex::parseBibTeXFiles(FileNameList & checkedFiles) const { // This bibtex parser is a first step to parse bibtex files // more precisely. @@ -678,7 +678,14 @@ void InsetBibtex::parseBibTeXFiles() const support::FileNamePairList::const_iterator it = files.begin(); support::FileNamePairList::const_iterator en = files.end(); for (; it != en; ++ it) { - ifdocstream ifs(it->second.toFilesystemEncoding().c_str(), + FileName const bibfile = it->second; + if (find(checkedFiles.begin(), checkedFiles.end(), bibfile) != checkedFiles.end()) + // already checked this one. Skip. + continue; + else + // record that we check this. + checkedFiles.push_back(bibfile); + ifdocstream ifs(bibfile.toFilesystemEncoding().c_str(), ios_base::in, buffer().masterParams().encoding().iconvName()); char_type ch; diff --git a/src/insets/InsetBibtex.h b/src/insets/InsetBibtex.h index 3ba96a29e8..2d033464f0 100644 --- a/src/insets/InsetBibtex.h +++ b/src/insets/InsetBibtex.h @@ -57,7 +57,7 @@ public: int plaintext(odocstringstream & ods, OutputParams const & op, size_t max_length = INT_MAX) const; /// - void collectBibKeys(InsetIterator const &) const; + void collectBibKeys(InsetIterator const &, support::FileNameList &) const; /// void validate(LaTeXFeatures &) const; /// @@ -84,7 +84,7 @@ private: /// void editDatabases() const; /// - void parseBibTeXFiles() const; + void parseBibTeXFiles(support::FileNameList &) const; /// bool usingBiblatex() const; diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 6af715fb22..d6e3ae2c63 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -1072,7 +1072,7 @@ void InsetInclude::validate(LaTeXFeatures & features) const } -void InsetInclude::collectBibKeys(InsetIterator const & /*di*/) const +void InsetInclude::collectBibKeys(InsetIterator const & /*di*/, FileNameList & checkedFiles) const { Buffer * child = loadIfNeeded(); if (!child) @@ -1082,7 +1082,7 @@ void InsetInclude::collectBibKeys(InsetIterator const & /*di*/) const // But it'll have to do for now. if (child == &buffer()) return; - child->collectBibKeys(); + child->collectBibKeys(checkedFiles); } diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h index 7be5f7892d..009b49e3ac 100644 --- a/src/insets/InsetInclude.h +++ b/src/insets/InsetInclude.h @@ -92,7 +92,7 @@ public: * \param keys the list of bibkeys in the child buffer. * \param it not used here */ - void collectBibKeys(InsetIterator const &) const; + void collectBibKeys(InsetIterator const &, support::FileNameList &) const; /// bool hasSettings() const { return true; } ///