[gnome-shell] BluetoothStatus: don't pass NaNs to native functions
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] BluetoothStatus: don't pass NaNs to native functions
- Date: Sun, 13 Mar 2011 16:09:15 +0000 (UTC)
commit 25015c9c3a8f3b7450cd3de0fa6e9781adc5acbc
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Wed Mar 2 17:27:24 2011 +0100
BluetoothStatus: don't pass NaNs to native functions
GJS complains when a NaN is passed in place of an integer, and
parseInt returns that from non numeric string. Pass a sentinel
that cancels the operation in that case.
https://bugzilla.gnome.org/show_bug.cgi?id=642978
js/ui/status/bluetooth.js | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index 2926f97..7885907 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -471,9 +471,15 @@ PinNotification.prototype = {
this.connect('action-invoked', Lang.bind(this, function(self, action) {
if (action == 'ok') {
- if (this._numeric)
- this._applet.agent_reply_passkey(this._devicePath, parseInt(this._entry.text));
- else
+ if (this._numeric) {
+ let num = parseInt(this._entry.text);
+ if (isNaN(num)) {
+ // user reply was empty, or was invalid
+ // cancel the operation
+ num = -1;
+ }
+ this._applet.agent_reply_passkey(this._devicePath, num);
+ } else
this._applet.agent_reply_pincode(this._devicePath, this._entry.text);
} else {
if (this._numeric)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]