Blob Blame History Raw
From 9ce09f7afb08a32eff1f6664d7893c49237a45c7 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 14 Jun 2017 16:41:41 -0400
Subject: [PATCH 2/2] objectManager: handle object manager sending empty array

If the service implementing the object manager returns
a 0 length array we currently throw an exception.

This commit fixes that.
---
 js/misc/objectManager.js | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/js/misc/objectManager.js b/js/misc/objectManager.js
index 5db7588b6..835057f5e 100644
--- a/js/misc/objectManager.js
+++ b/js/misc/objectManager.js
@@ -181,60 +181,65 @@ const ObjectManager = new Lang.Class({
 
         if (Object.keys(this._interfaceInfos).length == 0) {
             this._tryToCompleteLoad();
             return;
         }
 
         this._managerProxy.connect('notify::g-name-owner', Lang.bind(this, function() {
             if (this._managerProxy.g_name_owner)
                 this._onNameAppeared();
             else
                 this._onNameVanished();
         }));
 
         if (this._managerProxy.g_name_owner)
             this._onNameAppeared();
     },
 
     _onNameAppeared: function() {
         this._managerProxy.GetManagedObjectsRemote(Lang.bind(this, function(result, error) {
             if (!result) {
                 if (error) {
                    logError(error, 'could not get remote objects for service ' + this._serviceName + ' path ' + this._managerPath);
                 }
 
                 this._tryToCompleteLoad();
                 return;
             }
 
             let [objects] = result;
 
+            if (!objects) {
+                this._tryToCompleteLoad();
+                return;
+            }
+
             let objectPaths = Object.keys(objects);
             for (let i = 0; i < objectPaths.length; i++) {
                 let objectPath = objectPaths[i];
                 let object = objects[objectPath];
 
                 let interfaceNames = Object.getOwnPropertyNames(object);
                 for (let j = 0; j < interfaceNames.length; j++) {
                     let interfaceName = interfaceNames[j];
 
                     // Prevent load from completing until the interface is loaded
                     this._numLoadInhibitors++;
                     this._addInterface(objectPath,
                                        interfaceName,
                                        Lang.bind(this, this._tryToCompleteLoad));
                 }
             }
             this._tryToCompleteLoad();
         }));
     },
 
     _onNameVanished: function() {
         let objectPaths = Object.keys(this._objects);
         for (let i = 0; i < objectPaths.length; i++) {
             let object = this._objects[objectPaths];
 
             let interfaceNames = Object.keys(object);
             for (let j = 0; i < interfaceNames.length; i++) {
                 let interfaceName = interfaceNames[i];
 
                 if (object[interfaceName])
-- 
2.13.0