fix(hyprland): same fix but with a simpler Qt.callLater approach

This commit is contained in:
Lemmy
2026-03-17 09:28:58 -04:00
parent 3062797165
commit 08ed43d9a8
+12 -20
View File
@@ -32,21 +32,13 @@ Item {
onTriggered: safeUpdate() onTriggered: safeUpdate()
} }
// Coalesces workspace updates: onRawEvent calls refreshWorkspaces() which // Deferred via Qt.callLater to coalesce workspace updates: onRawEvent calls
// triggers onValuesChanged synchronously in the same call stack, then // refreshWorkspaces() which triggers onValuesChanged synchronously in the
// onRawEvent itself also restarts this timer — without deferral the // same call stack — without deferral the ListModel gets cleared+repopulated
// ListModel gets cleared+repopulated twice per event. The timer coalesces // twice per event. Qt.callLater deduplicates by function identity.
// these into a single update and avoids synchronous ListModel mutations function _deferredWorkspaceUpdate() {
// during signal cascades that can crash the V4 engine (SIGSEGV in safeUpdateWorkspaces();
// QV4::Object::insertMember). workspaceChanged();
Timer {
id: workspaceUpdateTimer
interval: 0
repeat: false
onTriggered: {
safeUpdateWorkspaces();
workspaceChanged();
}
} }
// Initialization // Initialization
@@ -488,7 +480,7 @@ Item {
target: Hyprland.workspaces target: Hyprland.workspaces
enabled: initialized enabled: initialized
function onValuesChanged() { function onValuesChanged() {
workspaceUpdateTimer.restart(); Qt.callLater(_deferredWorkspaceUpdate);
} }
} }
@@ -506,10 +498,10 @@ Item {
function onRawEvent(event) { function onRawEvent(event) {
Hyprland.refreshWorkspaces(); Hyprland.refreshWorkspaces();
Hyprland.refreshToplevels(); Hyprland.refreshToplevels();
// Workspace and window updates are deferred via timers to avoid // Workspace and window updates are deferred — refreshWorkspaces()/
// re-entrant incubation — refreshWorkspaces()/refreshToplevels() // refreshToplevels() trigger onValuesChanged which also calls
// trigger onValuesChanged which restarts the respective timers. // Qt.callLater, so the deduplication coalesces into one update.
workspaceUpdateTimer.restart(); Qt.callLater(_deferredWorkspaceUpdate);
updateTimer.restart(); updateTimer.restart();
const monitorsEvents = ["configreloaded", "monitoradded", "monitorremoved", "monitoraddedv2", "monitorremovedv2"]; const monitorsEvents = ["configreloaded", "monitoradded", "monitorremoved", "monitoraddedv2", "monitorremovedv2"];