]> git.lyx.org Git - features.git/commitdiff
Proper fix now for bug #6846. The idea, due to JMarc, is to collect
authorRichard Heck <rgheck@comcast.net>
Fri, 3 Dec 2010 19:29:46 +0000 (19:29 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 3 Dec 2010 19:29:46 +0000 (19:29 +0000)
bibliography information in updateBuffer(), rather than doing a wholly
separate traversal. We still do a separate traversal in two cases, as a
full updateBuffer() call just isn't needed there.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36696 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Buffer.h
src/insets/InsetBibitem.cpp
src/insets/InsetBibtex.cpp
src/insets/InsetBibtex.h

index c840564574e07f8ebd9114f7316d6ffed58358da..505dcddf956a80084aa5cc2a46992aa471f67ac8 100644 (file)
@@ -1809,8 +1809,21 @@ BiblioInfo const & Buffer::masterBibInfo() const
 }
 
 
+BiblioInfo & Buffer::masterBibInfo()
+{
+       Buffer * tmp = const_cast<Buffer *>(masterBuffer());
+       if (tmp != this)
+               return tmp->masterBibInfo();
+       return d->bibinfo_;
+}
+
+
 bool Buffer::isBibInfoCacheValid() const
 {
+       // use the master's cache
+       Buffer const * const tmp = masterBuffer();
+       if (tmp != this)
+               return tmp->isBibInfoCacheValid();
        return d->bibinfo_cache_valid_;
 }
 
@@ -3845,7 +3858,7 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
        
        // do this only if we are the top-level Buffer
        if (master == this)
-               reloadBibInfoCache();
+               checkIfBibInfoCacheIsValid();
 
        // keep the buffers to be children in this set. If the call from the
        // master comes back we can see which of them were actually seen (i.e.
index 355ff332896575b18ad8a53320c16f645070761f..4d3021261109288a009fe863e4716bf73b41fd0c 100644 (file)
@@ -445,12 +445,16 @@ public:
        /// whether the cache is valid. If so, we do nothing. If not, then we
        /// reload all the BibTeX info.
        /// Note that this operates on the master document.
+       /// Normally, this is done (more cheaply) in updateBuffer(), but there are
+       /// times when we need to force it to be done and don't need a full buffer
+       /// update. This is in GuiCitation and in changeRefsIfUnique() now.
        void reloadBibInfoCache() const;
        /// Was the cache valid the last time we checked?
        bool isBibInfoCacheValid() const;
        /// \return the bibliography information for this buffer's master,
        /// or just for it, if it isn't a child.
        BiblioInfo const & masterBibInfo() const;
+       BiblioInfo & masterBibInfo();
        ///
        void fillWithBibKeys(BiblioInfo & keys) const;
        ///
index a685ca0cac1ee36f5ecf34c627cf776bf2ea4325..5da47510386c94c929f67a3a7ebc9bfb8af314ee 100644 (file)
@@ -334,6 +334,14 @@ void InsetBibitem::updateBuffer(ParIterator const & it, UpdateType utype)
        } else {
                autolabel_ = from_ascii("??");
        }
+       if (!buffer().isBibInfoCacheValid()) {
+               BiblioInfo bi = buffer().masterBibInfo();
+               docstring const key = getParam("key");
+               BibTeXInfo keyvalmap(false);
+               keyvalmap.label(bibLabel());
+               keyvalmap[from_ascii("ref")] = it.paragraph().asString();
+               bi[key] = keyvalmap;
+       }
 }
 
 
index 8f1af04f50967d120906c6d9cf8b33c58ddb8f3c..daff1119983f5c9ed18b3790c1ba79c4f8939b58 100644 (file)
@@ -234,6 +234,15 @@ static string normalizeName(Buffer const & buffer,
 }
 
 
+void InsetBibtex::updateBuffer(ParIterator const &, UpdateType)
+{
+       if (buffer().isBibInfoCacheValid())
+               return;
+       BiblioInfo & bi = buffer().masterBibInfo();
+       fillWithBibKeys(bi);
+}
+
+
 int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
 {
        // the sequence of the commands:
@@ -669,9 +678,14 @@ namespace {
 }
 
 
-// This method returns a comma separated list of Bibtex entries
 void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist,
        InsetIterator const & /*di*/) const
+{
+       fillWithBibKeys(keylist);
+}
+
+
+void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist) const
 {
        // This bibtex parser is a first step to parse bibtex files
        // more precisely.
index 5ede7aaa45081bf99996b5e6f6fb11f2633a8867..ec6ed3a7070e77693ef67f1722328d167f22646d 100644 (file)
@@ -52,6 +52,8 @@ public:
        ///
        int latex(odocstream &, OutputParams const &) const;
        ///
+       void updateBuffer(ParIterator const &, UpdateType);
+       ///
        void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
        ///
        void validate(LaTeXFeatures &) const;
@@ -78,6 +80,8 @@ private:
                getBibTeXPath(docstring const & filename, Buffer const & buf);
        ///
        void editDatabases() const;
+       ///
+       void fillWithBibKeys(BiblioInfo &) const;
 
        /// \name Private functions inherited from Inset class
        //@{