From a96201d00a638628896e0640d609cd8124715cfa Mon Sep 17 00:00:00 2001 From: Gold87 <91761103+Gold872@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:47:25 -0400 Subject: [PATCH] Update version to 2025.0.0-beta-3 (#121) Also cancel bandwidth timers when a camera stream is removed --- lib/widgets/mjpeg.dart | 6 +++++- lib/widgets/nt_widgets/multi-topic/camera_stream.dart | 4 ++-- pubspec.yaml | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/widgets/mjpeg.dart b/lib/widgets/mjpeg.dart index fedc382..fc6c1dc 100644 --- a/lib/widgets/mjpeg.dart +++ b/lib/widgets/mjpeg.dart @@ -175,7 +175,7 @@ class MjpegStreamState { }); } - void dispose() { + void dispose({bool deleting = false}) { for (StreamSubscription subscription in _subscriptions.values) { subscription.cancel(); } @@ -186,6 +186,10 @@ class MjpegStreamState { httpClient.close(); httpClient = Client(); bitCount = 0; + + if (deleting) { + bandwidthTimer.cancel(); + } } void cancelSubscription(Key key) { diff --git a/lib/widgets/nt_widgets/multi-topic/camera_stream.dart b/lib/widgets/nt_widgets/multi-topic/camera_stream.dart index 257f117..96646eb 100644 --- a/lib/widgets/nt_widgets/multi-topic/camera_stream.dart +++ b/lib/widgets/nt_widgets/multi-topic/camera_stream.dart @@ -234,7 +234,7 @@ class CameraStreamModel extends MultiTopicNTWidgetModel { if (deleting) { _lastDisplayedImage?.evict(); mjpegStream?.previousImage?.evict(); - mjpegStream?.dispose(); + mjpegStream?.dispose(deleting: deleting); } super.disposeWidget(deleting: deleting); @@ -318,7 +318,7 @@ class CameraStreamWidget extends NTWidget { if (createNewWidget) { model.lastDisplayedImage?.evict(); - model.mjpegStream?.dispose(); + model.mjpegStream?.dispose(deleting: true); model.mjpegStream = MjpegStreamState(stream: stream); } diff --git a/pubspec.yaml b/pubspec.yaml index 302d5ba..36ce075 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: elastic_dashboard description: A simple and modern dashboard for FRC. publish_to: 'none' -version: 2025.0.0-beta-2 +version: 2025.0.0-beta-3 environment: sdk: '>=3.0.2 <4.0.0'