diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2020-08-05 22:42:24 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2020-08-05 21:31:13 +0000 |
commit | 4ac54e27b0c3f6d75d3e33714e0e3440b583aab7 (patch) | |
tree | a6f50ce3072a0633669b88d5bde29c5cbc0a7edd | |
parent | 12242e147e25cdd05bc0977c353b37b9eedf6c24 (diff) |
Qt: Fix status message issues in find packet search
Fix some status message and tooltip issues introduced when enabling
autocomplete on find packet search in g0162ba73.
1. Enable or disable completion only when search type is changed.
This setting is used in checkDisplayFilter(), which used to be
called *before* changing allowCompletion in updateWidgets(), and
this was causing issues with wrong status messages.
2. Check filter (usually triggered by changes in the search line)
or reset filter syntax (added by DisplayFilterEdit) when search
type is changed. This will trigger an update of the status message
and the tooltip.
3. Stop checking display filter if not doing completion (not display
filter search). This will avoid setting a status message from a
previous illegal display filter.
Ping-Bug: 16638
Change-Id: I1534d9494cc4d7b7a0583cb845c091ae709458ae
Reviewed-on: https://code.wireshark.org/review/38061
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | ui/qt/search_frame.cpp | 14 | ||||
-rw-r--r-- | ui/qt/widgets/display_filter_edit.cpp | 5 | ||||
-rw-r--r-- | ui/qt/widgets/field_filter_edit.cpp | 3 | ||||
-rw-r--r-- | ui/qt/widgets/syntax_line_edit.cpp | 8 | ||||
-rw-r--r-- | ui/qt/widgets/syntax_line_edit.h | 2 |
5 files changed, 21 insertions, 11 deletions
diff --git a/ui/qt/search_frame.cpp b/ui/qt/search_frame.cpp index ef20ec16b6..feea246b5c 100644 --- a/ui/qt/search_frame.cpp +++ b/ui/qt/search_frame.cpp @@ -274,9 +274,6 @@ void SearchFrame::updateWidgets() return; } - // Enable completion only for display filter search. - sf_ui_->searchLineEdit->allowCompletion(search_type == df_search_); - if (sf_ui_->searchLineEdit->text().isEmpty() || sf_ui_->searchLineEdit->syntaxState() == SyntaxLineEdit::Invalid) { sf_ui_->findButton->setEnabled(false); } else { @@ -343,7 +340,16 @@ void SearchFrame::on_searchTypeComboBox_currentIndexChanged(int idx) break; } - wsApp->popStatus(WiresharkApplication::FilterSyntax); + // Enable completion only for display filter search. + sf_ui_->searchLineEdit->allowCompletion(idx == df_search_); + + if (idx == df_search_) { + sf_ui_->searchLineEdit->checkFilter(); + } else { + sf_ui_->searchLineEdit->setToolTip(QString()); + wsApp->popStatus(WiresharkApplication::FilterSyntax); + } + updateWidgets(); } diff --git a/ui/qt/widgets/display_filter_edit.cpp b/ui/qt/widgets/display_filter_edit.cpp index dc77e2a9ca..e87bfdc394 100644 --- a/ui/qt/widgets/display_filter_edit.cpp +++ b/ui/qt/widgets/display_filter_edit.cpp @@ -341,8 +341,8 @@ void DisplayFilterEdit::checkFilter(const QString& filter_text) } emit popFilterSyntaxStatus(); - setToolTip(QString()); - checkDisplayFilter(filter_text); + if (!checkDisplayFilter(filter_text)) + return; switch (syntaxState()) { case Deprecated: @@ -359,6 +359,7 @@ void DisplayFilterEdit::checkFilter(const QString& filter_text) break; } default: + setToolTip(QString()); break; } diff --git a/ui/qt/widgets/field_filter_edit.cpp b/ui/qt/widgets/field_filter_edit.cpp index 9795eb7e70..6d5fd8a9b2 100644 --- a/ui/qt/widgets/field_filter_edit.cpp +++ b/ui/qt/widgets/field_filter_edit.cpp @@ -94,7 +94,8 @@ bool FieldFilterEdit::checkFilter() void FieldFilterEdit::checkFilter(const QString& filter_text) { popFilterSyntaxStatus(); - checkDisplayFilter(filter_text); + if (!checkDisplayFilter(filter_text)) + return; switch (syntaxState()) { case Deprecated: diff --git a/ui/qt/widgets/syntax_line_edit.cpp b/ui/qt/widgets/syntax_line_edit.cpp index 187f432ee8..9d8b954517 100644 --- a/ui/qt/widgets/syntax_line_edit.cpp +++ b/ui/qt/widgets/syntax_line_edit.cpp @@ -155,15 +155,15 @@ void SyntaxLineEdit::insertFilter(const QString &filter) insert(padded_filter); } -void SyntaxLineEdit::checkDisplayFilter(QString filter) +bool SyntaxLineEdit::checkDisplayFilter(QString filter) { if (!completion_enabled_) { - return; + return false; } if (filter.isEmpty()) { setSyntaxState(SyntaxLineEdit::Empty); - return; + return true; } dfilter_t *dfp = NULL; @@ -200,6 +200,8 @@ void SyntaxLineEdit::checkDisplayFilter(QString filter) g_free(err_msg); } dfilter_free(dfp); + + return true; } void SyntaxLineEdit::checkFieldName(QString field) diff --git a/ui/qt/widgets/syntax_line_edit.h b/ui/qt/widgets/syntax_line_edit.h index cc1b8461e3..c63af3de26 100644 --- a/ui/qt/widgets/syntax_line_edit.h +++ b/ui/qt/widgets/syntax_line_edit.h @@ -44,7 +44,7 @@ public slots: void insertFilter(const QString &filter); // Built-in syntax checks. Connect textChanged to these as needed. - void checkDisplayFilter(QString filter); + bool checkDisplayFilter(QString filter); void checkFieldName(QString field); void checkCustomColumn(QString fields); void checkInteger(QString number); |