Commit 2acdf6cf authored by Patrick J.P's avatar Patrick J.P Committed by Patrick José Pereira

FlightDisplayView: Correct windows crash with video popup

Signed-off-by: 's avatarPatrick J.P <patrickelectric@gmail.com>
parent e7381f6c
...@@ -212,7 +212,23 @@ QGCView { ...@@ -212,7 +212,23 @@ QGCView {
_flightVideo.state = "unpopup" _flightVideo.state = "unpopup"
videoWindow.visible = false videoWindow.visible = false
} }
}
/* This timer will startVideo again after the popup window appears and is loaded.
* Such approach was the only one to avoid a crash for windows users
*/
Timer {
id: videoPopUpTimer
interval: 2000;
running: false;
repeat: false
onTriggered: {
// If state is popup, the next one will be popup-finished
if (_flightVideo.state == "popup") {
_flightVideo.state = "popup-finished"
}
QGroundControl.videoManager.startVideo()
}
} }
QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true } QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true }
...@@ -270,6 +286,20 @@ QGCView { ...@@ -270,6 +286,20 @@ QGCView {
anchors.left: _panel.left anchors.left: _panel.left
anchors.bottom: _panel.bottom anchors.bottom: _panel.bottom
visible: QGroundControl.videoManager.hasVideo && (!_mainIsMap || _isPipVisible) visible: QGroundControl.videoManager.hasVideo && (!_mainIsMap || _isPipVisible)
onParentChanged: {
/* If video comes back from popup
* correct anchors.
* Such thing is not possible with ParentChange.
*/
if(parent == _panel) {
// Do anchors again after popup
anchors.left = _panel.left
anchors.bottom = _panel.bottom
anchors.margins = ScreenTools.defaultFontPixelHeight
}
}
states: [ states: [
State { State {
name: "pipMode" name: "pipMode"
...@@ -296,36 +326,41 @@ QGCView { ...@@ -296,36 +326,41 @@ QGCView {
State { State {
name: "popup" name: "popup"
StateChangeScript { StateChangeScript {
script: QGroundControl.videoManager.stopVideo() script: {
// Stop video, restart it again with Timer
// Avoiding crashs if ParentChange is not yet done
QGroundControl.videoManager.stopVideo()
videoPopUpTimer.running = true
}
}
PropertyChanges {
target: _flightVideoPipControl
inPopup: true
} }
},
State {
name: "popup-finished"
ParentChange { ParentChange {
target: _flightVideo target: _flightVideo
parent: videoItem parent: videoItem
x: 0 x: 0
y: 0 y: 0
width: videoWindow.width width: videoItem.width
height: videoWindow.height height: videoItem.height
}
PropertyChanges {
target: _flightVideoPipControl
inPopup: true
} }
}, },
State { State {
name: "unpopup" name: "unpopup"
StateChangeScript { StateChangeScript {
script: QGroundControl.videoManager.stopVideo() script: {
QGroundControl.videoManager.stopVideo()
videoPopUpTimer.running = true
}
} }
ParentChange { ParentChange {
target: _flightVideo target: _flightVideo
parent: _panel parent: _panel
} }
PropertyChanges {
target: _flightVideo
anchors.left: _panel.left
anchors.bottom: _panel.bottom
anchors.margins: ScreenTools.defaultFontPixelHeight
}
PropertyChanges { PropertyChanges {
target: _flightVideoPipControl target: _flightVideoPipControl
inPopup: false inPopup: false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment