[LyX/master] Fix bug #11748.

Richard Kimberly Heck rikiheck at lyx.org
Thu Feb 27 03:39:37 UTC 2020


commit 64f7da961a853f4ea60716129f0f22f39e451aa7
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Wed Feb 26 23:00:09 2020 -0500

    Fix bug #11748.
    
    Track the last chosen citation style when we clear the entries.
---
 src/frontends/qt/GuiCitation.cpp |    7 ++++++-
 src/frontends/qt/GuiCitation.h   |    2 ++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/frontends/qt/GuiCitation.cpp b/src/frontends/qt/GuiCitation.cpp
index c14d34e..7a554e7 100644
--- a/src/frontends/qt/GuiCitation.cpp
+++ b/src/frontends/qt/GuiCitation.cpp
@@ -386,6 +386,8 @@ void GuiCitation::updateStyles(BiblioInfo const & bi)
 	int curr = selectedLV->model()->rowCount() - 1;
 
 	if (curr < 0 || selected_keys.empty()) {
+		last_chosen_style_ =
+			citationStyleCO->itemData(citationStyleCO->currentIndex()).toString();
 		citationStyleCO->clear();
 		citationStyleCO->setEnabled(false);
 		citationStyleLA->setEnabled(false);
@@ -408,7 +410,10 @@ void GuiCitation::updateStyles(BiblioInfo const & bi)
 	// save old style selection
 	QString const curdata =
 		citationStyleCO->itemData(citationStyleCO->currentIndex()).toString();
-	QString const olddata = (curdata.isEmpty()) ? style_ : curdata;
+	QString const olddata = (curdata.isEmpty()) ?
+		(last_chosen_style_.isEmpty() ? style_ : last_chosen_style_): curdata;
+	// reset this
+	last_chosen_style_.clear();
 	citationStyleCO->clear();
 	BiblioInfo::CiteStringMap::const_iterator cit = sty.begin();
 	BiblioInfo::CiteStringMap::const_iterator end = sty.end();
diff --git a/src/frontends/qt/GuiCitation.h b/src/frontends/qt/GuiCitation.h
index d3a23b5..29b7b9b 100644
--- a/src/frontends/qt/GuiCitation.h
+++ b/src/frontends/qt/GuiCitation.h
@@ -182,6 +182,8 @@ private:
 
 	/// last used citation style
 	QString style_;
+        /// this is the last style chosen in the current dialog
+        QString last_chosen_style_;
 	///
 	GuiSelectionManager * selectionManager;
 	/// available keys.


More information about the lyx-cvs mailing list