Qt: Preference editor improvements.
authorStig Bjørlykke <stig@bjorlykke.org>
Wed, 25 Jan 2017 19:28:34 +0000 (20:28 +0100)
committerAnders Broman <a.broman58@gmail.com>
Fri, 27 Jan 2017 05:04:56 +0000 (05:04 +0000)
Use correct disconnect() signature to ensure everything is disconnected
before connecting new signals.  Without this all previous connects() are
still active.  This leads to gradually more and more syntax checks being
called for each change, and possibility of a wrong syntax check
(especially for strings which has no syntax check).

Use the textEdited() signal to trigger a syntax check at startup.
This gives consistency.

Do not clear preferenceLineEdit when done because it looks weird when
the preference text disappears while the widget is hiding.  The entry
is cleared before next show anyway.

Change-Id: I21c6fd8ec6bb0ecff1b2c0b66fe97dc3eaecf9b3
Reviewed-on: https://code.wireshark.org/review/19788
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
ui/qt/preference_editor_frame.cpp

index e9c008ea1c3a9ca8eaa60f01bce8e551bd017f97..5ac034c6b41c5548671172234ce54da049812210 100644 (file)
@@ -90,29 +90,25 @@ void PreferenceEditorFrame::editPreference(preference *pref, pref_module *module
 
     ui->preferenceLineEdit->clear();
     ui->preferenceLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
-    disconnect(ui->preferenceLineEdit);
+    disconnect(ui->preferenceLineEdit, 0, 0, 0);
 
     bool show = false;
 
     switch (prefs_get_type(pref_)) {
     case PREF_UINT:
     case PREF_DECODE_AS_UINT:
-        new_uint_ = prefs_get_uint_value_real(pref_, pref_stashed);
-        connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)),
+        connect(ui->preferenceLineEdit, SIGNAL(textChanged(QString)),
                 this, SLOT(uintLineEditTextEdited(QString)));
         show = true;
         break;
     case PREF_STRING:
-        new_str_ = prefs_get_string_value(pref_, pref_stashed);
-        connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)),
+        connect(ui->preferenceLineEdit, SIGNAL(textChanged(QString)),
                 this, SLOT(stringLineEditTextEdited(QString)));
         show = true;
         break;
     case PREF_RANGE:
     case PREF_DECODE_AS_RANGE:
-        wmem_free(NULL, new_range_);
-        new_range_ = range_copy(NULL, prefs_get_range_value_real(pref_, pref_stashed));
-        connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)),
+        connect(ui->preferenceLineEdit, SIGNAL(textChanged(QString)),
                 this, SLOT(rangeLineEditTextEdited(QString)));
         show = true;
         break;
@@ -240,7 +236,6 @@ void PreferenceEditorFrame::on_buttonBox_rejected()
     module_ = NULL;
     wmem_free(NULL, new_range_);
     new_range_ = NULL;
-    ui->preferenceLineEdit->clear();
     animatedHide();
 }