Sfoglia il codice sorgente

Adding same path twice was breaking ctkPathLineEdit

Julien Finet 12 anni fa
parent
commit
b277f5d4fd
1 ha cambiato i file con 9 aggiunte e 4 eliminazioni
  1. 9 4
      Libs/Widgets/ctkPathLineEdit.cpp

+ 9 - 4
Libs/Widgets/ctkPathLineEdit.cpp

@@ -519,12 +519,15 @@ void ctkPathLineEdit::addCurrentPathToHistory()
   //if more than m_MaxHistory entrees, drop the oldest.
   QString key = d->settingKey();
   QStringList history = settings.value(key).toStringList();
-  if (history.contains(this->currentPath()))
+  QString pathToAdd = this->currentPath();
+  if (history.contains(pathToAdd))
     {
-    history.removeAll(this->currentPath());
+    history.removeAll(pathToAdd);
     }
-  history.push_front(this->currentPath());
+  history.push_front(pathToAdd);
   settings.setValue(key, history);
+  // don't fire intermediate events.
+  bool wasBlocking = d->ComboBox->blockSignals(false);
   int index = d->ComboBox->findText(this->currentPath());
   if (index >= 0)
     {
@@ -534,7 +537,9 @@ void ctkPathLineEdit::addCurrentPathToHistory()
     {
     d->ComboBox->removeItem(d->ComboBox->count() - 1);
     }
-  d->ComboBox->insertItem(0, this->currentPath());
+  d->ComboBox->insertItem(0, pathToAdd);
+  d->ComboBox->setCurrentIndex(0);
+  d->ComboBox->blockSignals(wasBlocking);
 }
 
 //------------------------------------------------------------------------------