mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-15 21:22:40 +00:00
Properly manage the lifetime of polling in the AppView and PcView
This commit is contained in:
+13
-7
@@ -17,14 +17,20 @@ GridView {
|
||||
cellWidth: 225; cellHeight: 350;
|
||||
focus: true
|
||||
|
||||
Component.onCompleted: {
|
||||
// Start polling when this view is shown
|
||||
ComputerManager.startPolling()
|
||||
}
|
||||
// The StackView will trigger a visibility change when
|
||||
// we're pushed onto it, causing our onVisibleChanged
|
||||
// routine to run, but only if we start as invisible
|
||||
visible: false
|
||||
|
||||
Component.onDestruction: {
|
||||
// Stop polling when this view is destroyed
|
||||
ComputerManager.stopPollingAsync()
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
// Start polling when this view is shown
|
||||
ComputerManager.startPolling()
|
||||
}
|
||||
else {
|
||||
// Stop polling when this view is not on top
|
||||
ComputerManager.stopPollingAsync()
|
||||
}
|
||||
}
|
||||
|
||||
function createModel()
|
||||
|
||||
+14
-6
@@ -19,17 +19,25 @@ GridView {
|
||||
focus: true
|
||||
objectName: "Computers"
|
||||
|
||||
Component.onCompleted: {
|
||||
// Start polling when this view is shown
|
||||
ComputerManager.startPolling()
|
||||
// The StackView will trigger a visibility change when
|
||||
// we're pushed onto it, causing our onVisibleChanged
|
||||
// routine to run, but only if we start as invisible
|
||||
visible: false
|
||||
|
||||
Component.onCompleted: {
|
||||
// Setup signals on CM
|
||||
ComputerManager.computerAddCompleted.connect(addComplete)
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
// Stop polling when this view is destroyed
|
||||
ComputerManager.stopPollingAsync()
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
// Start polling when this view is shown
|
||||
ComputerManager.startPolling()
|
||||
}
|
||||
else {
|
||||
// Stop polling when this view is not top-most
|
||||
ComputerManager.stopPollingAsync()
|
||||
}
|
||||
}
|
||||
|
||||
function pairingComplete(error)
|
||||
|
||||
Reference in New Issue
Block a user