From 6aa1b817c9f65bad2a9af9b772d6876e30babf03 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 20 Apr 2020 17:25:14 -0700 Subject: [PATCH] messageTray: Make NotificationPolicy properties read-only These properties are never written; in the base class they are always their default values, and in the subclasses the getters are overridden. This will be necessary because GJS is adding checks to make sure that readable properties always have a getter, writable properties always have a setter, and that the variations of camelCase/snake_case are handled correctly. It's supposedly backwards compatible, but that assumes that code is not doing things like forgetting a setter on a writable property. (If the missing setter had ever been called, it might have led to a crash, which is why we've made this change.) This is the minimally invasive patch which should work with both older and newer versions of GJS. If you decide to require GJS 1.65.2, then you'll also be able to remove the getters from NotificationPolicy as well. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1205 --- js/ui/messageTray.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index fffdc786d..f4ceb0ae7 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -136,29 +136,22 @@ var FocusGrabber = class FocusGrabber { var NotificationPolicy = GObject.registerClass({ Properties: { 'enable': GObject.ParamSpec.boolean( - 'enable', 'enable', 'enable', - GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY, - true), + 'enable', 'enable', 'enable', GObject.ParamFlags.READABLE, true), 'enable-sound': GObject.ParamSpec.boolean( 'enable-sound', 'enable-sound', 'enable-sound', - GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY, - true), + GObject.ParamFlags.READABLE, true), 'show-banners': GObject.ParamSpec.boolean( 'show-banners', 'show-banners', 'show-banners', - GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY, - true), + GObject.ParamFlags.READABLE, true), 'force-expanded': GObject.ParamSpec.boolean( 'force-expanded', 'force-expanded', 'force-expanded', - GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY, - false), + GObject.ParamFlags.READABLE, false), 'show-in-lock-screen': GObject.ParamSpec.boolean( 'show-in-lock-screen', 'show-in-lock-screen', 'show-in-lock-screen', - GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY, - false), + GObject.ParamFlags.READABLE, false), 'details-in-lock-screen': GObject.ParamSpec.boolean( 'details-in-lock-screen', 'details-in-lock-screen', 'details-in-lock-screen', - GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY, - false), + GObject.ParamFlags.READABLE, false), }, }, class NotificationPolicy extends GObject.Object { // Do nothing for the default policy. These methods are only useful for the @@ -170,23 +163,23 @@ var NotificationPolicy = GObject.registerClass({ } get enableSound() { - return this.enable_sound; + return true; } get showBanners() { - return this.show_banners; + return true; } get forceExpanded() { - return this.force_expanded; + return false; } get showInLockScreen() { - return this.show_in_lock_screen; + return false; } get detailsInLockScreen() { - return this.details_in_lock_screen; + return false; } });