Serialize display recovery checks

This commit is contained in:
Gabriel Brown
2026-08-18 02:55:43 -04:00
parent 0a18290137
commit c2cd79b547
2 changed files with 34 additions and 9 deletions
+17 -8
View File
@@ -85,7 +85,8 @@ Singleton {
if (!root.awaitingConfirmation)
return;
if (root.revertQueued) {
root.performRevert();
if (!query.running)
root.performRevert();
return;
}
if (exitCode !== 0) {
@@ -93,6 +94,7 @@ Singleton {
return;
}
verifyTimer.attempts = 0;
verifyTimer.ticks = 0;
verifyTimer.restart();
}
}
@@ -104,17 +106,20 @@ Singleton {
// success without applying a value, so exact readback decides.
root.revertVerificationActive = true;
revertVerifyTimer.attempts = 0;
revertVerifyTimer.ticks = 0;
revertVerifyTimer.restart();
}
}
Component.onCompleted: root.refresh()
function refresh(): void {
function refresh(): bool {
if (!query.running) {
query.generation = root.operationGeneration;
query.running = true;
return true;
}
return false;
}
function parse(text: string, generation: int): void {
@@ -411,26 +416,29 @@ Singleton {
Timer {
id: verifyTimer
property int attempts: 0
property int ticks: 0
interval: 120
repeat: true
onTriggered: {
attempts++;
if (attempts > 25) {
ticks++;
if (ticks > 50) {
root.revertWithMessage("The display did not apply that setting, so Panama restored the previous one.");
return;
}
root.refresh();
if (root.refresh())
attempts++;
}
}
Timer {
id: revertVerifyTimer
property int attempts: 0
property int ticks: 0
interval: 120
repeat: true
onTriggered: {
attempts++;
if (attempts > 25) {
ticks++;
if (ticks > 50) {
stop();
root.revertVerificationActive = false;
root.revertGeneration = -1;
@@ -439,7 +447,8 @@ Singleton {
root.lastError = "The previous display setting could not be verified. Open Displays and restore it manually.";
return;
}
root.refresh();
if (root.refresh())
attempts++;
}
}