]> git.lyx.org Git - features.git/commitdiff
Allowing direct, read-write access to the references cache just seems
authorRichard Heck <rgheck@lyx.org>
Mon, 18 Mar 2013 23:32:30 +0000 (19:32 -0400)
committerRichard Heck <rgheck@lyx.org>
Mon, 18 Mar 2013 23:32:30 +0000 (19:32 -0400)
like a bad idea.

src/Buffer.cpp
src/Buffer.h
src/insets/InsetLabel.cpp
src/insets/InsetRef.cpp
src/mathed/InsetMathRef.cpp

index 2455b808fb8baf6580ec7e1db03fcbeab5674664..c6a8c2202b4bc28ce5a5e30c1ed70b1e98d4e0bb 100644 (file)
@@ -3269,10 +3269,10 @@ void Buffer::listParentMacros(MacroSet & macros, LaTeXFeatures & features) const
 }
 
 
-Buffer::References & Buffer::references(docstring const & label)
+Buffer::References & Buffer::getReferenceCache(docstring const & label)
 {
        if (d->parent())
-               return const_cast<Buffer *>(masterBuffer())->references(label);
+               return const_cast<Buffer *>(masterBuffer())->getReferenceCache(label);
 
        RefCache::iterator it = d->ref_cache_.find(label);
        if (it != d->ref_cache_.end())
@@ -3288,7 +3288,14 @@ Buffer::References & Buffer::references(docstring const & label)
 
 Buffer::References const & Buffer::references(docstring const & label) const
 {
-       return const_cast<Buffer *>(this)->references(label);
+       return const_cast<Buffer *>(this)->getReferenceCache(label);
+}
+
+
+void Buffer::addReference(docstring const & label, Inset * inset, ParIterator it)
+{
+       References & refs = getReferenceCache(label);
+       refs.push_back(make_pair(inset, it));
 }
 
 
index cd0540cb7bfd029d6694448274840f7c2ecdbc68..e30a09a9c5a65572b8a1918d23bf56d328ac809b 100644 (file)
@@ -660,10 +660,15 @@ public:
 
        ///
        typedef std::vector<std::pair<Inset *, ParIterator> > References;
-       References & references(docstring const & label);
+       ///
        References const & references(docstring const & label) const;
+       ///
+       void addReference(docstring const & label, Inset * inset, ParIterator it);
+       ///
        void clearReferenceCache() const;
+       ///
        void setInsetLabel(docstring const & label, InsetLabel const * il);
+       ///
        InsetLabel const * insetLabel(docstring const & label) const;
 
        /// return a list of all used branches (also in children)
@@ -713,6 +718,8 @@ private:
        /// mark the buffer as busy exporting something, or not
        void setExportStatus(bool e) const;
 
+       ///
+       References & getReferenceCache(docstring const & label);
        /// Change name of buffer. Updates "read-only" flag.
        void setFileName(support::FileName const & fname);
        ///
index c2ef896b866f53ef6aaab7fa1f8655362b0826ed..4dfbc96448a628fb8e34c1bea7a9fd1cd4fd1d47 100644 (file)
@@ -109,9 +109,9 @@ void InsetLabel::updateLabelAndRefs(docstring const & new_label,
 void InsetLabel::updateReferences(docstring const & old_label,
                docstring const & new_label)
 {
-       Buffer::References & refs = buffer().references(old_label);
-       Buffer::References::iterator it = refs.begin();
-       Buffer::References::iterator end = refs.end();
+       Buffer::References const & refs = buffer().references(old_label);
+       Buffer::References::const_iterator it = refs.begin();
+       Buffer::References::const_iterator end = refs.end();
        for (; it != end; ++it) {
                buffer().undo().recordUndo(CursorData(it->second));
                if (it->first->lyxCode() == MATH_REF_CODE) {
index 0c8e471d5c9d045e5986a108a5fc03c45337067f..42e7fabe1a69074e8c8a3650e7940db0d372bd5c 100644 (file)
@@ -270,7 +270,7 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType)
 {
        docstring const & ref = getParam("reference");
        // register this inset into the buffer reference cache.
-       buffer().references(ref).push_back(make_pair(this, it));
+       buffer().addReference(ref, this, it);
 
        docstring label;
        for (int i = 0; !types[i].latex_name.empty(); ++i) {
index ae1768351c426d20af4ab680e98282ad9c864222..ef08cbcd3d0610d95c8b9446e85b5959261822fe 100644 (file)
@@ -184,7 +184,7 @@ void InsetMathRef::updateBuffer(ParIterator const & it, UpdateType /*utype*/)
                return;
        }
        // register this inset into the buffer reference cache.
-       buffer().references(getTarget()).push_back(make_pair(this, it));
+       buffer().addReference(getTarget(), this, it);
 }