[gnome-shell] Bluetooth: fix updating the device list
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Bluetooth: fix updating the device list
- Date: Wed, 16 Mar 2011 14:31:06 +0000 (UTC)
commit 7f67c34b396d9ada7d665f76e6bcd08edfc9799e
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Tue Mar 15 21:22:57 2011 +0100
Bluetooth: fix updating the device list
Inside the inner loop, use the inner iterator, not that of the outer
loop. At the same time, refactor the code to rely less on private
properties appended to foreign objects.
https://bugzilla.gnome.org/show_bug.cgi?id=644858
js/ui/status/bluetooth.js | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index 7885907..092cd1a 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -136,6 +136,7 @@ Indicator.prototype = {
_updateDevices: function() {
let devices = this._applet.get_devices();
+ let newlist = [ ];
for (let i = 0; i < this._deviceItems.length; i++) {
let item = this._deviceItems[i];
let destroy = true;
@@ -143,26 +144,20 @@ Indicator.prototype = {
// we need to deep compare because BluetoothSimpleDevice is a boxed type
// (but we take advantage of that, because _skip will disappear the next
// time get_devices() is called)
- if (this._deviceCompare(item._device, devices[i])) {
- item.label.text = devices[i].alias;
- devices[i]._skip = true;
+ if (this._deviceCompare(item._device, devices[j])) {
+ item.label.text = devices[j].alias;
+ devices[j]._skip = true;
destroy = false;
+ break;
}
}
- if (destroy) {
+ if (destroy)
item.destroy();
- item._destroyed = true;
- }
- }
-
- let newlist = [ ];
- for (let i = 0; i < this._deviceItems.length; i++) {
- let item = this._deviceItems[i];
- if (!item._destroyed)
+ else
newlist.push(item);
}
- this._deviceItems = newlist;
+ this._deviceItems = newlist;
this._hasDevices = newlist.length > 0;
for (let i = 0; i < devices.length; i++) {
let d = devices[i];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]