rgheck wrote:
Abdelrazak Younes wrote:
Probably something like the bibfiles cache?
Probably a good idea.
All right, I had a quick look at this. The analogy is reasonable enough,
but it's not quite right. In that case, we basically keep a list of
timestamps and check whether the files have been modified. In this case,
what we need is a kind of "labelsChanged" boolean that we can set to
false whenever we generate the list of labels (in
Buffer::getLabelList()), and then have set to true whenever a label gets
created or deleted. This can be checked then in GuiRef::updateRefs()
before the actual updating is done. Roughly. Something like that will work.
But there are two issues. The first is simply that I don't know where
labels can be created and deleted. Part of this can be done in the
InsetLabel ctor and dtor, but it looks as if InsetMathHull creates and
destroys its own sort of labels, so I'll need some help there, but
that's not a huge problem. The second issue arises just with
InsetLabel::InsetLabel(). We want to tell the buffer that labelsChanged
needs to be set to true. But we don't have access to the buffer. I
suppose there could be just a global labelsChanged---probably there
should be, since the labels that need recalculating may be in a child
document---but, if so, where should that global variable be put?
Considering multiview, I'd prefer a solution based on signal/slot. Maybe
static signal member in InsetLabel? See attached, untested.
Abdel.
Index: InsetLabel.cpp
===================================================================
--- InsetLabel.cpp (revision 22331)
+++ InsetLabel.cpp (working copy)
@@ -27,10 +27,13 @@
namespace lyx {
+Signal InsetLabel::modified;
InsetLabel::InsetLabel(InsetCommandParams const & p)
: InsetCommand(p, "label")
-{}
+{
+ modified.fire();
+}
CommandInfo const * InsetLabel::findInfo(string const & /* cmdName */)
@@ -83,6 +86,7 @@
InsetCommand::doDispatch(cur, cmd);
break;
}
+ modified.fire();
}
Index: InsetLabel.h
===================================================================
--- InsetLabel.h (revision 22331)
+++ InsetLabel.h (working copy)
@@ -14,6 +14,7 @@
#include "InsetCommand.h"
+#include "support/SignalSlot.h"
namespace lyx {
@@ -22,6 +23,8 @@
///
InsetLabel(InsetCommandParams const &);
///
+ ~InsetLabel() { modified.fire(); }
+ ///
docstring const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
@@ -42,6 +45,10 @@
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "label"; }
+
+ ///
+ static Signal modified;
+
protected:
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
private: