Skip to content

Commit fb1b308

Browse files
committed
Move ownership/control of debug signal to GObject
We've been having a problem in GNOME 46 with GSConnect not responding to the toggling of the "debug" setting, seemingly not being delivered the `changed::debug` signal at all. Let's make it a property of the `GSConnectManager` GObject instead.
1 parent 0a06025 commit fb1b308

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

src/service/init.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,17 @@ const _debugFunc = function (error, prefix = null) {
138138
});
139139
};
140140

141-
// Swap the function out for a no-op anonymous function for speed
141+
globalThis._debugFunc = _debugFunc;
142+
142143
const settings = new Gio.Settings({
143144
settings_schema: Config.GSCHEMA.lookup(Config.APP_ID, true),
144145
});
145-
146-
settings.connect('changed::debug', (settings, key) => {
147-
globalThis.debug = settings.get_boolean(key) ? _debugFunc : () => {};
148-
});
149-
150-
if (settings.get_boolean('debug'))
151-
globalThis.debug = _debugFunc;
152-
else
146+
if (settings.get_boolean('debug')) {
147+
globalThis.debug = globalThis._debugFunc;
148+
} else {
149+
// Swap the function out for a no-op anonymous function for speed
153150
globalThis.debug = () => {};
154-
151+
}
155152

156153
/**
157154
* Start wl_clipboard if not under Gnome

src/service/manager.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ const Manager = GObject.registerClass({
3535
GObject.ParamFlags.READABLE,
3636
false
3737
),
38+
'debug': GObject.ParamSpec.boolean(
39+
'debug',
40+
'Debug',
41+
'Whether debug logging is enabled in GSConnect',
42+
GObject.ParamFlags.READWRITE,
43+
false
44+
),
3845
'discoverable': GObject.ParamSpec.boolean(
3946
'discoverable',
4047
'Discoverable',
@@ -85,6 +92,21 @@ const Manager = GObject.registerClass({
8592
return this._backends;
8693
}
8794

95+
get debug() {
96+
if (this._debug === undefined)
97+
this._debug = this.settings.get_boolean('debug');
98+
99+
return this._debug;
100+
}
101+
102+
set debug(value) {
103+
if (this._debug === value)
104+
return;
105+
106+
this._debug = value;
107+
this._onDebugChanged(this._debug);
108+
}
109+
88110
get devices() {
89111
if (this._devices === undefined)
90112
this._devices = new Map();
@@ -203,11 +225,20 @@ const Manager = GObject.registerClass({
203225
this.settings.set_string('name', GLib.get_host_name());
204226

205227
// Bound Properties
228+
this.settings.bind('debug', this, 'debug', 0);
206229
this.settings.bind('discoverable', this, 'discoverable', 0);
207230
this.settings.bind('id', this, 'id', 0);
208231
this.settings.bind('name', this, 'name', 0);
209232
}
210233

234+
_onDebugChanged(debug = false) {
235+
// If debugging is disabled, install a no-op for speed
236+
if (debug && globalThis._debugFunc !== undefined)
237+
globalThis.debug = globalThis._debugFunc;
238+
else
239+
globalThis.debug = () => {};
240+
}
241+
211242
/*
212243
* Backends
213244
*/
@@ -512,4 +543,3 @@ const Manager = GObject.registerClass({
512543
});
513544

514545
export default Manager;
515-

0 commit comments

Comments
 (0)