On Friday 11 October 2002 1:06 pm, Jean-Marc Lasgouttes wrote: > >>>>> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: > > Angus> Any chance of a yeah or nay on this one: > Angus> > http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg45713.h >tml > > Angus> Michael has tested it and says it cures the problem > (bug 633). > > How sure are you that it works? I want to be extra careful. > And also, how grave is the problem?
Starting at the front ;-) The problem is not grave. Sometimes citation labels do not appear in 'natbib' style when the user expects them to do so. We use a flag to tell the citation inset that we are in the process of loading the buffer and so it should NOT try and reload the bibtex data base whilst this is going on. Thereafter, we tell the citation inset that loading has stopped and that it should 'assume the worst' and reload the bibtex database every time it regenerates the label. The trick is when to tell the citation inset that loading of the buffer has stopped. I managed to catch the editing of an existing inset, but forgot about the insertion of a new one. That's what the patch now does. The only possible regression is that we might reload the bibtex database multiple times during the initial loading of the buffer. That would be BAD. However, I was extra careful about the logic. I reproduce the code fragment here. loading_buffer[buffer] is set to false by the call to edit() or by BufferView::disptach(INSERT_CITATION). If you can find anything unsafe below, then don't apply it. Else it's safe. Angus std::map<Buffer const *, bool> loading_buffer; string const getNatbibLabel(Buffer const * buffer, ...) { typedef std::map<Buffer const *, biblio::InfoMap> CachedMap; static CachedMap cached_keys; // Only load the bibkeys once if we're loading up the buffer, // else load them afresh each time. // Ascertain whether we're loading the buffer or not. map<Buffer const *, bool>::iterator lit = loading_buffer.find(buffer); if (lit == loading_buffer.end()) loading_buffer[buffer] = true; // If we're not loading the buffer, then loadkeys every time bool loadkeys = !loading_buffer[buffer]; if (!loadkeys) { // We are loading the buffer, but have we loaded // the bibtex keys yet? CachedMap::iterator kit = cached_keys.find(buffer); loadkeys = kit == cached_keys.end(); } if (loadkeys) { // build the keylist }