aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2017-07-14 10:55:08 +0200
committerStig Bjørlykke <stig@bjorlykke.org>2017-07-16 19:39:35 +0000
commitd5c8145f54e8ec966f1ea1eab48e37fe248bf285 (patch)
tree1c9b4c5ac6fd72120c5c6a5b3bf81443eee9af5e /ui/qt
parent87e7bc811c78b0ab5c6243934cb0bdea6094851e (diff)
Qt: Set IO Graph display filter when having Y field
Calling setFilter() between setValueUnits() and setValueUnitField() will fail when having "Y Field" because check_field_unit() fails with inconsistent values. The display filter will then be ignored. Call setFilter() first to ensure filter_ is set before setting value units. setFilter() does not depend on the value unit when used to set the display filter. Change-Id: Ibf2d37fddcce9fcf6febebfefa0b2518ae093737 Fixes: v2.3.0rc0-2930-g0ea51ad822 ("Qt: Fix uninitialized memory access in val_units_") Reviewed-on: https://code.wireshark.org/review/22619 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/io_graph_dialog.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/ui/qt/io_graph_dialog.cpp b/ui/qt/io_graph_dialog.cpp
index c7960db4b8..2024d76684 100644
--- a/ui/qt/io_graph_dialog.cpp
+++ b/ui/qt/io_graph_dialog.cpp
@@ -404,6 +404,15 @@ void IOGraphDialog::addDefaultGraph(bool enabled, int idx)
// Sync the settings from a graphTreeWidget item to its IOGraph.
// Disables the graph if any errors are found.
+//
+// NOTE: Setting dfilter, yaxis and yfield here will all end up in setFilter() and this
+// has a chicken-and-egg problem because setFilter() depends on previous assigned
+// values for filter_, val_units_ and vu_field_. Setting values in wrong order
+// may give unpredicted results because setFilter() does not always set filter_
+// on errors.
+// TODO: The issues in the above note should be fixed and setFilter() should not be
+// called so frequently.
+
void IOGraphDialog::syncGraphSettings(QTreeWidgetItem *item)
{
if (!item) return;
@@ -414,16 +423,15 @@ void IOGraphDialog::syncGraphSettings(QTreeWidgetItem *item)
bool retap = !iog->visible() && visible;
iog->setName(item->text(name_col_));
+ iog->setFilter(item->text(dfilter_col_));
- /* dfilter and plot style depend on the value unit, so set it first. */
+ /* plot style depend on the value unit, so set it first. */
iog->setValueUnits(item->data(yaxis_col_, Qt::UserRole).toInt());
+ iog->setValueUnitField(item->text(yfield_col_));
- iog->setFilter(item->text(dfilter_col_));
iog->setColor(colors_[item->data(color_col_, Qt::UserRole).toInt() % colors_.size()]);
iog->setPlotStyle(item->data(style_col_, Qt::UserRole).toInt());
- iog->setValueUnitField(item->text(yfield_col_));
-
iog->moving_avg_period_ = item->data(sma_period_col_, Qt::UserRole).toUInt();
iog->setInterval(ui->intervalComboBox->itemData(ui->intervalComboBox->currentIndex()).toInt());