From 2dc6f70aed27ae3c2af769fcf0559b18f0cd2fbe Mon Sep 17 00:00:00 2001 From: rncbc Date: Fri, 26 Aug 2022 18:57:09 +0100 Subject: [PATCH] - Tiny fix on the main options dialog (re. combo-box item history) --- src/qtractorOptions.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/qtractorOptions.cpp b/src/qtractorOptions.cpp index fc16c4da2..32ca10207 100644 --- a/src/qtractorOptions.cpp +++ b/src/qtractorOptions.cpp @@ -969,23 +969,26 @@ void qtractorOptions::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) { const bool bBlockSignals = pComboBox->blockSignals(true); - // Add current text as latest item... - const QString sCurrentText = pComboBox->currentText(); int iCount = pComboBox->count(); - for (int i = 0; i < iCount; ++i) { - const QString& sText = pComboBox->itemText(i); - if (sText == sCurrentText) { - pComboBox->removeItem(i); - --iCount; - break; + // Add current text as latest item (if not blank)... + const QString& sCurrentText = pComboBox->currentText(); + if (!sCurrentText.isEmpty()) { + for (int i = 0; i < iCount; ++i) { + const QString& sText = pComboBox->itemText(i); + if (sText == sCurrentText) { + pComboBox->removeItem(i); + --iCount; + break; + } } + pComboBox->insertItem(0, sCurrentText); + pComboBox->setCurrentIndex(0); + ++iCount; } + while (iCount >= iLimit) pComboBox->removeItem(--iCount); - pComboBox->insertItem(0, sCurrentText); - pComboBox->setCurrentIndex(0); - ++iCount; // Save combobox list to configuration settings file... m_settings.beginGroup("/History/" + pComboBox->objectName());