mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-19 05:53:35 +00:00
fix bug with natbib cite insets
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH-1_2_X@5408 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
179642b571
commit
f7bd408e7f
@ -3139,8 +3139,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
InsetCitation * inset = new InsetCitation(p);
|
||||
if (!insertInset(inset))
|
||||
delete inset;
|
||||
else
|
||||
else {
|
||||
inset->setLoadingBuffer(bv_->buffer(), false);
|
||||
updateInset(inset, true);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -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-07 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* lyxrc.C (read): treat a viewer or converter command of "none" as
|
||||
|
@ -1,3 +1,12 @@
|
||||
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-08-07 Juergen Vigna <jug@lyx.org>
|
||||
|
||||
* insettabular.C (localDispatch): make delete not put the stuff
|
||||
|
@ -49,17 +49,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;
|
||||
|
||||
if (!loading_buffer[buffer] || kit == cached_keys.end()) {
|
||||
bool loadkeys = !loading_buffer[buffer];
|
||||
if (!loadkeys) {
|
||||
CachedMap::iterator kit = cached_keys.find(buffer);
|
||||
loadkeys = kit == cached_keys.end();
|
||||
}
|
||||
|
||||
if (loadkeys) {
|
||||
// build the keylist
|
||||
typedef vector<std::pair<string, string> > InfoType;
|
||||
InfoType bibkeys = buffer->getBibkeyList();
|
||||
@ -72,7 +77,7 @@ string const getNatbibLabel(Buffer const * buffer,
|
||||
infomap[bit->first] = bit->second;
|
||||
}
|
||||
if (infomap.empty())
|
||||
return string();
|
||||
return string();
|
||||
|
||||
cached_keys[buffer] = infomap;
|
||||
}
|
||||
@ -307,12 +312,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, unsigned int)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
@ -43,6 +43,11 @@ public:
|
||||
int latex(Buffer const *, std::ostream &, bool, bool) const;
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
/** Invoked by BufferView::Pimpl::dispatch when a new citation key
|
||||
is inserted. Tells us that the buffer is no longer being loaded
|
||||
and that the cache of BibTeX keys should be reloaded in the future.
|
||||
*/
|
||||
void setLoadingBuffer(Buffer const * buffer, bool state) const;
|
||||
private:
|
||||
struct Cache {
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user