The problem is that GuiBox::setSpecial doesn't refill the width unit combo box 
correctly (i.e., the data part of it).

In trunk, the bug was fixed due to a more extensive rewrite of the LengthCombo 
handling (r28152).

I apply to branch if there are no objections.

Jürgen
Index: src/frontends/qt4/LengthCombo.cpp
===================================================================
--- src/frontends/qt4/LengthCombo.cpp	(Revision 31826)
+++ src/frontends/qt4/LengthCombo.cpp	(Arbeitskopie)
@@ -24,14 +24,7 @@
 LengthCombo::LengthCombo(QWidget * parent)
 	: QComboBox(parent)
 {
-	for (int i = 0; i < lyx::num_units; i++) {
-		// mu does not make sense usually
-		// so it must be added manually, if needed
-		if (lyx::unit_name[i] == "mu")
-			continue;
-		QComboBox::addItem(lyx::qt_(lyx::unit_name_gui[i]),
-			lyx::toqstr(lyx::unit_name[i]));
-	}
+	reset();
 
 	connect(this, SIGNAL(activated(int)),
 		this, SLOT(has_activated(int)));
@@ -129,4 +122,18 @@
 	QComboBox::addItem(item);
 }
 
+
+void LengthCombo::reset()
+{
+	clear();
+	for (int i = 0; i < lyx::num_units; i++) {
+		// mu does not make sense usually
+		// so it must be added manually, if needed
+		if (lyx::unit_name[i] == "mu")
+			continue;
+		QComboBox::addItem(lyx::qt_(lyx::unit_name_gui[i]),
+			lyx::toqstr(lyx::unit_name[i]));
+	}
+}
+
 #include "LengthCombo_moc.cpp"
Index: src/frontends/qt4/GuiBox.cpp
===================================================================
--- src/frontends/qt4/GuiBox.cpp	(Revision 31826)
+++ src/frontends/qt4/GuiBox.cpp	(Arbeitskopie)
@@ -423,11 +423,8 @@
 		for (int i = 1; i < gui_names_spec_.size(); ++i)
 			widthUnitsLC->addItem(gui_names_spec_[i]);
 	// ... or remove 'em if needed
-	} else if (ibox && has_special) {
-		widthUnitsLC->clear();
-		for (int i = 0; i != num_units; ++i)
-			widthUnitsLC->addItem(qt_(unit_name_gui[i]));
-	}
+	} else if (ibox && has_special)
+		widthUnitsLC->reset();
 	// restore selected text, if possible
 	int const idx = widthUnitsLC->findText(current_text);
 	if (idx != -1)
Index: src/frontends/qt4/LengthCombo.h
===================================================================
--- src/frontends/qt4/LengthCombo.h	(Revision 31826)
+++ src/frontends/qt4/LengthCombo.h	(Arbeitskopie)
@@ -46,6 +46,8 @@
 	virtual void addItem(lyx::Length::UNIT unit);
 	/// add an item to the combo
 	virtual void addItem(QString const item);
+	/// reset to initial state
+	virtual void reset();
 
 protected Q_SLOTS:
 	virtual void has_activated(int index);

Reply via email to