From db4847804f0c50d02ae9d4cd0418b453a635ff8e Mon Sep 17 00:00:00 2001 From: jnomikos Date: Mon, 20 Nov 2023 20:17:25 -0600 Subject: [PATCH] PhotoVideoControl.qml: Fixed if bug based on odd qt qml behavior --- src/FlightMap/Widgets/PhotoVideoControl.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/FlightMap/Widgets/PhotoVideoControl.qml b/src/FlightMap/Widgets/PhotoVideoControl.qml index c81b7b41a36..73eeee415e0 100644 --- a/src/FlightMap/Widgets/PhotoVideoControl.qml +++ b/src/FlightMap/Widgets/PhotoVideoControl.qml @@ -101,7 +101,19 @@ Rectangle { function toggleShooting() { console.log("toggleShooting", _anyVideoStreamAvailable) - if (_mavlinkCamera && (_mavlinkCamera.capturesVideo || _mavlinkCamera.capturesPhotos) ) { + + // This whole mavlinkCameraCaptureVideoOrPhotos stuff is to work around some strange qml boolean testing + // behavior which wasn't working correctly. This should work: + // if (_mavlinkCamera && (_mavlinkCamera.capturesVideo || _mavlinkCamera.capturesPhotos) ) { + // but it doesn't for some strange reason. Hence all the stuff below... + var mavlinkCameraCaptureVideoOrPhotos = false + if (_mavlinkCamera) { + if (_mavlinkCamera.capturesVideo || _mavlinkCamera.capturesPhotos) { + mavlinkCameraCaptureVideoOrPhotos = true + } + } + + if (mavlinkCameraCaptureVideoOrPhotos) { if(_mavlinkCameraInVideoMode) { _mavlinkCamera.toggleVideo() } else {