From ee0eae238e6d819f7b38ad1cea000caf53512e1f Mon Sep 17 00:00:00 2001 From: Starlight220 <53231611+Starlight220@users.noreply.github.com> Date: Tue, 28 Mar 2023 12:52:41 +0300 Subject: [PATCH 1/3] explicitly unbox numbers --- .../plugin/cameraserver/widget/CameraServerWidget.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/widget/CameraServerWidget.java b/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/widget/CameraServerWidget.java index 7077daed7..101751c49 100644 --- a/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/widget/CameraServerWidget.java +++ b/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/widget/CameraServerWidget.java @@ -157,14 +157,16 @@ public Pane getView() { return root; } + @SuppressWarnings("UnnecessaryUnboxing") @FXML private void applySettings() { if (getSource() instanceof CameraServerSource) { CameraServerSource source = (CameraServerSource) getSource(); int compression = (int) compressionSlider.getValue(); - int fps = frameRateField.getNumber(); - int width = this.width.getNumber(); - int height = this.height.getNumber(); + // Gson uses an internal subclass of Number that can't be implicitly cast to Integer + int fps = frameRateField.getNumber().intValue(); + int width = this.width.getNumber().intValue(); + int height = this.height.getNumber().intValue(); boolean change = source.getTargetCompression() != compression || source.getTargetFps() != fps || source.getTargetResolution().isNotEqual(width, height); From 76828957329dc338798ac50d04c5603132ab06a9 Mon Sep 17 00:00:00 2001 From: Starlight220 <53231611+Starlight220@users.noreply.github.com> Date: Tue, 28 Mar 2023 13:05:19 +0300 Subject: [PATCH 2/3] bump version --- .../shuffleboard/plugin/cameraserver/CameraServerPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/CameraServerPlugin.java b/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/CameraServerPlugin.java index 938499aed..85bd27152 100644 --- a/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/CameraServerPlugin.java +++ b/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/CameraServerPlugin.java @@ -34,7 +34,7 @@ @Description( group = "edu.wpi.first.shuffleboard", name = "CameraServer", - version = "3.1.0", + version = "3.1.1", summary = "Provides sources and widgets for viewing CameraServer MJPEG streams" ) @Requires(group = "edu.wpi.first.shuffleboard", name = "NetworkTables", minVersion = "2.0.0") From 1c15fc4017ceab3b091aa7b5a2f41c173a0a58ee Mon Sep 17 00:00:00 2001 From: Starlight220 <53231611+Starlight220@users.noreply.github.com> Date: Tue, 28 Mar 2023 17:13:31 +0300 Subject: [PATCH 3/3] explicitly cast to Number --- .../cameraserver/widget/CameraServerWidget.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/widget/CameraServerWidget.java b/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/widget/CameraServerWidget.java index 101751c49..6b00725e7 100644 --- a/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/widget/CameraServerWidget.java +++ b/plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/widget/CameraServerWidget.java @@ -157,16 +157,17 @@ public Pane getView() { return root; } - @SuppressWarnings("UnnecessaryUnboxing") @FXML private void applySettings() { if (getSource() instanceof CameraServerSource) { CameraServerSource source = (CameraServerSource) getSource(); int compression = (int) compressionSlider.getValue(); - // Gson uses an internal subclass of Number that can't be implicitly cast to Integer - int fps = frameRateField.getNumber().intValue(); - int width = this.width.getNumber().intValue(); - int height = this.height.getNumber().intValue(); + // Gson uses an internal subclass of Number that can't be implicitly cast to Integer, + // and Java *really* likes implicitly casting to Integer, + // so we need to explcitly cast to Number. + int fps = ((Number) frameRateField.getNumber()).intValue(); + int width = ((Number) this.width.getNumber()).intValue(); + int height = ((Number) this.height.getNumber()).intValue(); boolean change = source.getTargetCompression() != compression || source.getTargetFps() != fps || source.getTargetResolution().isNotEqual(width, height);