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 {
_flightVideo.state = "unpopup"
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 }
......@@ -270,6 +286,20 @@ QGCView {
anchors.left: _panel.left
anchors.bottom: _panel.bottom
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: [
State {
name: "pipMode"
......@@ -296,36 +326,41 @@ QGCView {
State {
name: "popup"
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 {
target: _flightVideo
parent: videoItem
x: 0
y: 0
width: videoWindow.width
height: videoWindow.height
}
PropertyChanges {
target: _flightVideoPipControl
inPopup: true
width: videoItem.width
height: videoItem.height
}
},
State {
name: "unpopup"
StateChangeScript {
script: QGroundControl.videoManager.stopVideo()
script: {
QGroundControl.videoManager.stopVideo()
videoPopUpTimer.running = true
}
}
ParentChange {
target: _flightVideo
parent: _panel
}
PropertyChanges {
target: _flightVideo
anchors.left: _panel.left
anchors.bottom: _panel.bottom
anchors.margins: ScreenTools.defaultFontPixelHeight
}
PropertyChanges {
target: _flightVideoPipControl
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