Skip to content

Commit c238cef

Browse files
committed
Merge #805: Avoid hidden network traffic graph updates
35fecc9 qml: avoid shadowing LineGraph fillColor (johnny9) 5f00942 qml: avoid hidden network traffic updates (johnny9) Pull request description: ## What changed - move network traffic sampling, smoothing, and history retention onto an owned worker thread - publish immutable traffic snapshots back to the GUI thread only while the Network Traffic page is active - retain raw samples while hidden and rebuild the requested range when the page becomes active again - lazy-load the Network Traffic settings page so its graphs do not exist while another settings section is selected - preserve byte totals as 64-bit values - rename the native graph gradient property so it no longer shadows `QQuickPaintedItem::fillColor` - add C++ and QML coverage for thread affinity, hidden-page suppression, retained history, range changes, page lifecycle, and destruction while active ## Why The previous timer was moved to a background thread, but its timeout updated a GUI-thread model every second regardless of whether the Network Traffic page was visible. That kept smoothing, full-history copies, signal delivery, and graph bindings active in the background. Timer/thread ownership was also not explicit during shutdown. This keeps the inexpensive raw sample collection running off-thread while avoiding hidden GUI work and making worker shutdown deterministic. `LineGraph` also declared its own `fillColor` property over the property inherited from `QQuickPaintedItem`, producing a QML property-cache warning. The native property is now named `gradientColor`; the public `NetworkTrafficGraph.fillColor` API and rendering behavior are unchanged. ## User impact Opening Network Traffic still shows the samples collected while the page was hidden, and changing the graph range rebuilds the visible history without losing totals. Other settings pages no longer pay for traffic graph updates or retain the graph objects. ## Issue Fixes #611. Fixes #801. Graph reset behavior was split from #611 into #806 and is intentionally not included here. ## Validation - full RelWithDebInfo build with app tests enabled - `qmllint -I qml -I test/mocks/qml qml/components/NetworkTrafficGraph.qml qml/pages/node/NetworkTraffic.qml qml/pages/node/NodeSettings.qml test/qml/tst_nodesettings.qml` - `bitcoinqml_qmltests`: 380 passed, 0 failed - `NetworkTrafficTowerTests`: 6 passed, 0 failed - `git diff --check origin/qt6...HEAD` The aggregate unit executable was also run locally. Its Network Traffic suite passed; unrelated existing OptionsModel tests could not write the default Bitcoin data directory inside the managed filesystem sandbox. ACKs for top commit: jarolrod: ACK 35fecc9 Tree-SHA512: 765de9435d4b73942bd4f85bfdfe082b1ad360c950c853fd6aa14c6d8bc6f011f2ffad3d0b7cb361dd40d701a63bfe9a4ca47bd4cf107017cc6f7b9741b730de
2 parents 4799fdf + 35fecc9 commit c238cef

12 files changed

Lines changed: 565 additions & 138 deletions

qml/bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ int QmlGuiMain(int argc, char* argv[])
592592
}, Qt::QueuedConnection);
593593
QObject::connect(&init_executor, &QmlInitExecutor::runawayException, &node_model, &NodeModel::handleRunawayException);
594594

595-
NetworkTrafficTower network_traffic_tower{node_model};
595+
NetworkTrafficTower network_traffic_tower{*node};
596596
NetworkStatusModel network_status_model;
597597
#ifdef __ANDROID__
598598
AndroidNotifier android_notifier{node_model};

qml/components/NetworkTrafficGraph.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Item {
1414
id: root
1515
property alias backgroundColor: trafficGraph.backgroundColor
1616
property alias borderColor: trafficGraph.borderColor
17-
property alias fillColor: trafficGraph.fillColor
17+
property alias fillColor: trafficGraph.gradientColor
1818
property alias lineColor: trafficGraph.lineColor
1919
property alias markerLineColor: trafficGraph.markerLineColor
2020
property alias maxSamples: trafficGraph.maxSamples
@@ -31,7 +31,7 @@ Item {
3131
width: root.width
3232
backgroundColor: root.backgroundColor
3333
borderColor: root.borderColor
34-
fillColor: root.fillColor
34+
gradientColor: root.fillColor
3535
lineColor: root.lineColor
3636
markerLineColor: root.markerLineColor
3737
maxSamples: root.maxSamples
@@ -46,7 +46,7 @@ Item {
4646
ColorAnimation { duration: 150 }
4747
}
4848

49-
Behavior on fillColor {
49+
Behavior on gradientColor {
5050
ColorAnimation { duration: 150 }
5151
}
5252

qml/controls/linegraph.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
LineGraph::LineGraph(QQuickItem *parent)
1818
: QQuickPaintedItem(parent)
1919
{
20-
setFillColor(m_background_color);
20+
setGradientColor(m_background_color);
2121
}
2222

2323
void LineGraph::setBackgroundColor(QColor color)
2424
{
2525
m_background_color = color;
26-
setFillColor(color);
26+
setGradientColor(color);
2727
}
2828

2929
void LineGraph::setBorderColor(QColor color)
@@ -32,9 +32,9 @@ void LineGraph::setBorderColor(QColor color)
3232
update();
3333
}
3434

35-
void LineGraph::setFillColor(QColor color)
35+
void LineGraph::setGradientColor(QColor color)
3636
{
37-
m_fill_color = color;
37+
m_gradient_color = color;
3838
update();
3939
}
4040

@@ -135,7 +135,7 @@ void LineGraph::paintTraffic(QPainter * painter)
135135
void LineGraph::setupGradient(QPainterPath * painter_path)
136136
{
137137
QLinearGradient gradient(painter_path->boundingRect().topLeft(), painter_path->boundingRect().bottomLeft());
138-
gradient.setColorAt(0, QColor(m_fill_color.red(), m_fill_color.green(), m_fill_color.blue(), 191));
138+
gradient.setColorAt(0, QColor(m_gradient_color.red(), m_gradient_color.green(), m_gradient_color.blue(), 191));
139139
gradient.setColorAt(1, QColor("transparent"));
140140
m_fill_gradient = gradient;
141141
}

qml/controls/linegraph.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class LineGraph : public QQuickPaintedItem
1616
Q_OBJECT
1717
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
1818
Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
19-
Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor)
19+
Q_PROPERTY(QColor gradientColor READ gradientColor WRITE setGradientColor)
2020
Q_PROPERTY(QColor lineColor READ lineColor WRITE setLineColor)
2121
Q_PROPERTY(QColor markerLineColor READ markerLineColor WRITE setMarkerLineColor)
2222
Q_PROPERTY(int maxSamples READ maxSamples WRITE setMaxSamples)
@@ -29,7 +29,7 @@ class LineGraph : public QQuickPaintedItem
2929

3030
QColor backgroundColor() const { return m_background_color; };
3131
QColor borderColor() const { return m_border_color; };
32-
QColor fillColor() const { return m_fill_color; };
32+
QColor gradientColor() const { return m_gradient_color; };
3333
QColor lineColor() const { return m_line_color; };
3434
QColor markerLineColor() const { return m_marker_line_color; };
3535
int maxSamples() const { return m_max_samples; };
@@ -39,7 +39,7 @@ class LineGraph : public QQuickPaintedItem
3939
public Q_SLOTS:
4040
void setBackgroundColor(QColor color);
4141
void setBorderColor(QColor color);
42-
void setFillColor(QColor color);
42+
void setGradientColor(QColor color);
4343
void setLineColor(QColor color);
4444
void setMarkerLineColor(QColor color);
4545
void setMaxSamples(int max_samples);
@@ -55,7 +55,7 @@ class LineGraph : public QQuickPaintedItem
5555

5656
QColor m_background_color{"#2D2D2D"};
5757
QColor m_border_color{"#000000"};
58-
QColor m_fill_color{"#000000"};
58+
QColor m_gradient_color{"#000000"};
5959
QLinearGradient m_fill_gradient{0, 0, 0, 0};
6060
QColor m_line_color{"#000000"};
6161
QColor m_marker_line_color{"#000000"};

0 commit comments

Comments
 (0)