systemActions: Create SensorProxy unconditionally
When plugging in a device with sensors that are unsupported by iio-sensor-proxy, the proxy may quit so fast that the name disappears from the bus before we get to construct the SensorProxy in response to the name-appeared handler, resulting in the following warning: JS ERROR: TypeError: this._sensorProxy is null _sensorProxyAppeared/this._sensorProxy<@resource:///org/gnome/shell/misc/systemActions.js:217:17 _makeProxyWrapper/</<@resource:///org/gnome/gjs/modules/overrides/Gio.js:243:21 Address this by creating the proxy unconditionally instead of monitoring the bus name, and using the g-name-owner property to determine whether iio-sensor-proxy is active. https://gitlab.gnome.org/GNOME/gnome-shell/issues/1357
This commit is contained in:
parent
f50cac3005
commit
928b49705f
@ -174,13 +174,21 @@ const SystemActions = GObject.registerClass({
|
|||||||
});
|
});
|
||||||
Main.layoutManager.connect('monitors-changed',
|
Main.layoutManager.connect('monitors-changed',
|
||||||
() => this._updateOrientationLock());
|
() => this._updateOrientationLock());
|
||||||
Gio.DBus.system.watch_name(SENSOR_BUS_NAME,
|
this._sensorProxy = new SensorProxy(Gio.DBus.system,
|
||||||
Gio.BusNameWatcherFlags.NONE,
|
SENSOR_BUS_NAME,
|
||||||
() => this._sensorProxyAppeared(),
|
SENSOR_OBJECT_PATH,
|
||||||
() => {
|
(proxy, error) => {
|
||||||
this._sensorProxy = null;
|
if (error)
|
||||||
this._updateOrientationLock();
|
log(error.message);
|
||||||
});
|
},
|
||||||
|
null,
|
||||||
|
Gio.DBusProxyFlags.DO_NOT_AUTO_START);
|
||||||
|
this._sensorProxy.connect('g-properties-changed', () => {
|
||||||
|
this._updateOrientationLock();
|
||||||
|
});
|
||||||
|
this._sensorProxy.connect('notify::g-name-owner', () => {
|
||||||
|
this._updateOrientationLock();
|
||||||
|
});
|
||||||
this._updateOrientationLock();
|
this._updateOrientationLock();
|
||||||
this._updateOrientationLockIcon();
|
this._updateOrientationLockIcon();
|
||||||
|
|
||||||
@ -223,22 +231,9 @@ const SystemActions = GObject.registerClass({
|
|||||||
return this._actions.get(LOCK_ORIENTATION_ACTION_ID).iconName;
|
return this._actions.get(LOCK_ORIENTATION_ACTION_ID).iconName;
|
||||||
}
|
}
|
||||||
|
|
||||||
_sensorProxyAppeared() {
|
|
||||||
this._sensorProxy = new SensorProxy(Gio.DBus.system, SENSOR_BUS_NAME, SENSOR_OBJECT_PATH,
|
|
||||||
(proxy, error) => {
|
|
||||||
if (error) {
|
|
||||||
log(error.message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._sensorProxy.connect('g-properties-changed',
|
|
||||||
() => this._updateOrientationLock());
|
|
||||||
this._updateOrientationLock();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateOrientationLock() {
|
_updateOrientationLock() {
|
||||||
let available = false;
|
let available = false;
|
||||||
if (this._sensorProxy)
|
if (this._sensorProxy.g_name_owner)
|
||||||
available = this._sensorProxy.HasAccelerometer &&
|
available = this._sensorProxy.HasAccelerometer &&
|
||||||
this._monitorManager.get_is_builtin_display_on();
|
this._monitorManager.get_is_builtin_display_on();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user