mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-01 19:18:28 -04:00
fix(notifications): dismiss popup reliably on user-initiated close paths (#2761)
The notification popup's close button (X), action button clicks, and the cardClick body's else branch all set notificationData.popup = false directly. This relies on wrapperConn.onPopupChanged firing startExit(), which can be interrupted by four races: 1. enterDelay (160 ms Timer) starts notificationData.timer after the user clicks, on an already-orphan wrapper. 2. The dismiss Timer keeps running post-click and flips popup again. 3. wrapperConn.target is set imperatively in onNotificationDataChanged (line 293) and may be stale after NotificationPopupManager._sync() reorders wrappers. 4. exiting or _isDestroying stuck true gates wrapperConn.enabled. Introduce a single helper dismissPopupReliably() that stops the timer, sets popup = false, and kicks off startExit() via Qt.callLater as a belt-and-suspenders fallback. Apply to the three vulnerable handlers. This matches the existing upstream pattern used in the hover, contextMenu, and Component.onDestruction paths (which all stop the timer before mutating popup state). Closes #2760
This commit is contained in:
@@ -168,6 +168,19 @@ PanelWindow {
|
||||
popupContextMenuLoader.active = false;
|
||||
}
|
||||
|
||||
function dismissPopupReliably() {
|
||||
if (!notificationData || win.exiting || win._isDestroying)
|
||||
return;
|
||||
if (notificationData.timer)
|
||||
notificationData.timer.stop();
|
||||
notificationData.popup = false;
|
||||
// Fallback if wrapperConn.onPopupChanged doesn't reach startExit.
|
||||
Qt.callLater(() => {
|
||||
if (!win.exiting && !win._isDestroying)
|
||||
startExit();
|
||||
});
|
||||
}
|
||||
|
||||
visible: !_finalized
|
||||
WlrLayershell.layer: {
|
||||
const shouldUseOverlay = notificationData && (SettingsData.notificationOverlayEnabled || notificationData.urgency === NotificationUrgency.Critical);
|
||||
@@ -1007,8 +1020,7 @@ PanelWindow {
|
||||
z: 15
|
||||
|
||||
onClicked: {
|
||||
if (notificationData && !win.exiting)
|
||||
notificationData.popup = false;
|
||||
dismissPopupReliably();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1080,8 +1092,7 @@ PanelWindow {
|
||||
onClicked: {
|
||||
if (modelData && modelData.invoke)
|
||||
modelData.invoke();
|
||||
if (notificationData && !win.exiting)
|
||||
notificationData.popup = false;
|
||||
dismissPopupReliably();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1163,7 +1174,7 @@ PanelWindow {
|
||||
notificationData.actions[0].invoke();
|
||||
NotificationService.dismissNotification(notificationData);
|
||||
} else {
|
||||
notificationData.popup = false;
|
||||
dismissPopupReliably();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user