Attached is my latest attempt at this patch. It still proceeds along the original lines. It may be that the time is being spent creating the strings, but this still seems to me like the correct approach, in general. Why update the list of labels if we don't have to do so?

Anyway, it still won't compile. I had to change the connect() method is SignalSlot to Connect(), as otherwise it wouldn't work: The compiler went looking for QObject::connect, for some reason. (Is that a macro?) But even with that change, and even after making sure that the static objects are all declared---making them non-static doesn't help---I'm still getting linking errors:

support/.libs/liblyxsupport.a(SignalSlot.o): In function `SlotImpl':
/cvs/lyx-devel/trunk/src/support/../../src/support/SignalSlotPrivate.h:37: undefined reference to `vtable for lyx::SlotImpl'
support/.libs/liblyxsupport.a(SignalSlot.o): In function `SignalImpl':
/cvs/lyx-devel/trunk/src/support/../../src/support/SignalSlotPrivate.h:23: undefined reference to `vtable for lyx::SignalImpl' support/.libs/liblyxsupport.a(SignalSlot.o): In function `lyx::Signal::fire()': /cvs/lyx-devel/trunk/src/support/SignalSlot.cpp:38: undefined reference to `lyx::SignalImpl::fire()'
support/.libs/liblyxsupport.a(SignalSlot.o): In function `SlotImpl':
/cvs/lyx-devel/trunk/src/support/../../src/support/SignalSlotPrivate.h:37: undefined reference to `vtable for lyx::SlotImpl'
support/.libs/liblyxsupport.a(SignalSlot.o): In function `SignalImpl':
/cvs/lyx-devel/trunk/src/support/../../src/support/SignalSlotPrivate.h:23: undefined reference to `vtable for lyx::SignalImpl'
collect2: ld returned 1 exit status

Part of the problem seems to be that moc isn't being run on SignalSlotPrivate.h, but even doing that manually doesn't fix things. There must be some other issue.

Richard

Index: src/support/SignalSlot.h
===================================================================
--- src/support/SignalSlot.h	(revision 22337)
+++ src/support/SignalSlot.h	(working copy)
@@ -28,7 +28,7 @@
 	Signal(Signal const &);
 	void operator=(Signal const &);
 	SignalImpl * impl;
-	friend void connect(Signal & sig, Slot & slot);
+	friend void Connect(Signal & sig, Slot & slot);
 };
 
 class Slot
@@ -41,10 +41,10 @@
 	Slot(Slot const &);
 	void operator=(Slot const &);
 	SlotImpl * impl;
-	friend void connect(Signal & sig, Slot & slot);
+	friend void Connect(Signal & sig, Slot & slot);
 };
 
-void connect(Signal & sig, Slot & slot);
+void Connect(Signal & sig, Slot & slot);
 
 } // namespace lyx
 
Index: src/support/SignalSlot.cpp
===================================================================
--- src/support/SignalSlot.cpp	(revision 22337)
+++ src/support/SignalSlot.cpp	(working copy)
@@ -66,7 +66,7 @@
 //
 /////////////////////////////////////////////////////////////////////
 
-void connect(Signal & sig, Slot & slot)
+void Connect(Signal & sig, Slot & slot)
 {
 	QObject::connect(sig.impl, SIGNAL(fire()), slot.impl, SLOT(called()));
 }
Index: src/frontends/qt4/GuiRef.h
===================================================================
--- src/frontends/qt4/GuiRef.h	(revision 22337)
+++ src/frontends/qt4/GuiRef.h	(working copy)
@@ -16,6 +16,7 @@
 #include "Dialog.h"
 #include "ui_RefUi.h"
 #include "insets/InsetCommandParams.h"
+#include "support/SignalSlot.h"
 
 #include <vector>
 
@@ -30,6 +31,7 @@
 
 public:
 	GuiRef(GuiView & lv);
+	static void markLabelsModified() { labelsModified_ = true; }
 
 private Q_SLOTS:
 	void changed_adaptor();
@@ -75,6 +77,11 @@
 	/// update references
 	void updateRefs();
 
+	class GuiRefSlot : public Slot 
+	{
+		virtual void called() { GuiRef::markLabelsModified(); }
+	};
+	
 	/// sort or not persistent state
 	bool sort_;
 	/// went to a reference ?
@@ -85,6 +92,10 @@
 	int restored_buffer_;
 	/// the references
 	std::vector<docstring> refs_;
+	/// whether labels have been modified and need regenerating
+	static bool labelsModified_;
+	///
+	static GuiRefSlot guirefslot;
 };
 
 } // namespace frontend
Index: src/frontends/qt4/GuiRef.cpp
===================================================================
--- src/frontends/qt4/GuiRef.cpp	(revision 22337)
+++ src/frontends/qt4/GuiRef.cpp	(working copy)
@@ -20,6 +20,7 @@
 #include "qt_helpers.h"
 
 #include "insets/InsetRef.h"
+#include "insets/InsetLabel.h"
 
 #include "support/FileName.h"
 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
@@ -37,6 +38,9 @@
 
 namespace lyx {
 namespace frontend {
+	
+bool GuiRef::labelsModified_ = true;
+GuiRef::GuiRefSlot GuiRef::guirefslot;
 
 GuiRef::GuiRef(GuiView & lv)
 	: GuiCommand(lv, "ref")
@@ -47,12 +51,14 @@
 	sort_ = false;
 	at_ref_ = false;
 
+	//connect buttons
 	connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
 	connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
 	connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
 	connect(closePB, SIGNAL(clicked()), this, SLOT(reset_dialog()));
 	connect(this, SIGNAL(rejected()), this, SLOT(reset_dialog()));
 
+	//connect other widgets
 	connect(typeCO, SIGNAL(activated(int)),
 		this, SLOT(changed_adaptor()));
 	connect(referenceED, SIGNAL(textChanged(QString)),
@@ -74,6 +80,9 @@
 	connect(bufferCO, SIGNAL(activated(int)),
 		this, SLOT(updateClicked()));
 
+	//connection for 
+	Connect(InsetLabel::modified, guirefslot);
+
 	setFocusProxy(refsLW);
 
 	bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
@@ -166,6 +175,7 @@
 
 void GuiRef::updateClicked()
 {
+	labelsModified_ = true; //force update
 	updateRefs();
 }
 
@@ -338,10 +348,13 @@
 
 void GuiRef::updateRefs()
 {
+	if (!labelsModified_)
+		return;
 	refs_.clear();
 	string const name = theBufferList().getFileNames()[bufferCO->currentIndex()];
 	Buffer const * buf = theBufferList().getBuffer(makeAbsPath(name).absFilename());
 	buf->getLabelList(refs_);
+	labelsModified_ = false;
 	sortCB->setEnabled(!refs_.empty());
 	refsLW->setEnabled(!refs_.empty());
 	gotoPB->setEnabled(!refs_.empty());
Index: src/insets/InsetLabel.h
===================================================================
--- src/insets/InsetLabel.h	(revision 22337)
+++ src/insets/InsetLabel.h	(working copy)
@@ -13,8 +13,8 @@
 #define INSET_LABEL_H
 
 #include "InsetCommand.h"
+#include "support/SignalSlot.h"
 
-
 namespace lyx {
 
 class InsetLabel : public InsetCommand {
@@ -22,6 +22,8 @@
 	///
 	InsetLabel(InsetCommandParams const &);
 	///
+	~InsetLabel() { modified.fire(); }
+	///
 	docstring const getScreenLabel(Buffer const &) const;
 	///
 	EDITABLE editable() const { return IS_EDITABLE; }
@@ -42,6 +44,8 @@
 	///
 	static bool isCompatibleCommand(std::string const & s) 
 		{ return s == "label"; }
+	///
+	static Signal modified;
 protected:
 	virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
 private:
Index: src/insets/InsetLabel.cpp
===================================================================
--- src/insets/InsetLabel.cpp	(revision 22337)
+++ src/insets/InsetLabel.cpp	(working copy)
@@ -27,10 +27,14 @@
 
 namespace lyx {
 
+Signal InsetLabel::modified;
 
+
 InsetLabel::InsetLabel(InsetCommandParams const & p)
 	: InsetCommand(p, "label")
-{}
+{
+	modified.fire();
+}
 
 
 CommandInfo const * InsetLabel::findInfo(string const & /* cmdName */)
@@ -76,6 +80,7 @@
 			cur.bv().buffer().changeRefsIfUnique(params()["name"],
 					p["name"], REF_CODE);
 		setParams(p);
+		modified.fire();
 		break;
 	}
 
Index: src/mathed/InsetMathHull.cpp
===================================================================
--- src/mathed/InsetMathHull.cpp	(revision 22337)
+++ src/mathed/InsetMathHull.cpp	(working copy)
@@ -423,14 +423,17 @@
 {
 	//lyxerr << "setting label '" << label << "' for row " << row << endl;
 	label_[row] = label;
+	InsetLabel::modified.fire();
 }
 
 
 void InsetMathHull::numbered(row_type row, bool num)
 {
 	nonum_[row] = !num;
-	if (nonum_[row])
+	if (nonum_[row]) {
 		label_[row].clear();
+		InsetLabel::modified.fire();
+	}
 }
 
 
@@ -613,6 +616,7 @@
 	nonum_.insert(nonum_.begin() + row + 1, !numberedType());
 	label_.insert(label_.begin() + row + 1, docstring());
 	InsetMathGrid::addRow(row);
+	InsetLabel::modified.fire();
 }
 
 

Reply via email to