]> git.lyx.org Git - features.git/commitdiff
Fix to bug 633.
authorAngus Leeming <leeming@lyx.org>
Fri, 11 Oct 2002 12:18:55 +0000 (12:18 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 11 Oct 2002 12:18:55 +0000 (12:18 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5382 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/insets/ChangeLog
src/insets/insetcite.C

index 86621ce1499ff6388b2c7098221ce747a0ad7c08..36b457694f4eb61e7f5646d2e817fb40cee6e764 100644 (file)
@@ -1119,8 +1119,11 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
                InsetCitation * inset = new InsetCitation(p);
                if (!insertInset(inset))
                        delete inset;
-               else
+               else {
+                       inset->setLoadingBuffer(bv_->buffer(), false);
                        updateInset(inset, true);
+               }
+               
        }
        break;
 
index 69a8e685b2aef8169a5f22cb71d44d693c509fec..79cde1132069b26bbf6077ee663e693f66a349f6 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-09  Angus Leeming  <leeming@lyx.org>
+
+       * Bufferview_pimpl.C (dispatch): call InsetCitation::setLoadingBuffer
+       to turn off an optimisation if a new inset is to be inserted.
+
 2002-10-11 André Pönitz <poenitz@gmx.net>
 
        * lytext.h: make some functions public to allow access
index b8cf39e25e5d3068847d1a1261781a1e6f99120e..66e58074912309d2ee97186c042a329a5b771a9f 100644 (file)
@@ -1,3 +1,11 @@
+2002-10-09  Angus Leeming  <leeming@lyx.org>
+
+       * insetcite.[Ch] (setLoadingBuffer): new method, invoked by
+       BufferView::dispatch that turns off this optimisation when a new inset
+       is inserted.
+
+       * insetcite.C (getNatbibLabel): correct logic of when and when not to
+       reload the BibTeX keys.
 
 2002-10-11 André Pönitz <poenitz@gmx.net>
 
index 998338787bb4c355920b9879e04afe612995e5ac..1be81b58d24850d173602d5823fb9d7de621212d 100644 (file)
@@ -51,17 +51,22 @@ string const getNatbibLabel(Buffer const * buffer,
                            string const & before, string const & after,
                            bool numerical)
 {
-       // Only reload the bibkeys if we have to...
-       map<Buffer const *, bool>::iterator lit = loading_buffer.find(buffer);
-       if (lit != loading_buffer.end())
-               loading_buffer[buffer] = true;
-
        typedef std::map<Buffer const *, biblio::InfoMap> CachedMap;
        static CachedMap cached_keys;
 
-       CachedMap::iterator kit = cached_keys.find(buffer);
+       // Only load the bibkeys once if we're loading up the buffer,
+       // else load them afresh each time.
+       map<Buffer const *, bool>::iterator lit = loading_buffer.find(buffer);
+       if (lit == loading_buffer.end())
+               loading_buffer[buffer] = true;
+
+       bool loadkeys = !loading_buffer[buffer];
+       if (!loadkeys) {
+               CachedMap::iterator kit = cached_keys.find(buffer);
+               loadkeys = kit == cached_keys.end();
+       }
 
-       if (!loading_buffer[buffer] || kit == cached_keys.end()) {
+       if (loadkeys) {
                // build the keylist
                typedef vector<std::pair<string, string> > InfoType;
                InfoType bibkeys = buffer->getBibkeyList();
@@ -74,7 +79,7 @@ string const getNatbibLabel(Buffer const * buffer,
                        infomap[bit->first] = bit->second;
                }
                if (infomap.empty())
-               return string();
+                       return string();
 
                cached_keys[buffer] = infomap;
        }
@@ -310,12 +315,18 @@ string const InsetCitation::getScreenLabel(Buffer const * buffer) const
 }
 
 
+void InsetCitation::setLoadingBuffer(Buffer const * buffer, bool state) const
+{
+       // Doesn't matter if there is no bv->buffer() entry in the map.
+       loading_buffer[buffer] = state;
+}
+
+
 void InsetCitation::edit(BufferView * bv, int, int, mouse_button::state)
 {
        // A call to edit() indicates that we're no longer loading the
        // buffer but doing some real work.
-       // Doesn't matter if there is no bv->buffer() entry in the map.
-       loading_buffer[bv->buffer()] = false;
+       setLoadingBuffer(bv->buffer(), false);
 
        bv->owner()->getDialogs().showCitation(this);
 }