[gnome-shell] Environment: don't fail in toString()



commit 1f87eb4157aa13911f7bebc2c6209d5ca4959e35
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Mar 5 21:15:45 2012 +0100

    Environment: don't fail in toString()
    
    Some objects have a resolve hooks that throw exceptions, so just
    checking "'actor' in object" can fail. In that case we should catch
    the exception and return the standard toString() value, or the
    object cannot be inspected from the looking glass.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=671410

 js/ui/environment.js |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/environment.js b/js/ui/environment.js
index fc78064..435eed1 100644
--- a/js/ui/environment.js
+++ b/js/ui/environment.js
@@ -59,10 +59,14 @@ function init() {
     let origToString = Object.prototype.toString;
     Object.prototype.toString = function() {
         let base = origToString.call(this);
-        if ('actor' in this && this.actor instanceof Clutter.Actor)
-            return base.replace(/\]$/, ' delegate for ' + this.actor.toString().substring(1));
-        else
+        try {
+            if ('actor' in this && this.actor instanceof Clutter.Actor)
+                return base.replace(/\]$/, ' delegate for ' + this.actor.toString().substring(1));
+            else
+                return base;
+        } catch(e) {
             return base;
+        }
     };
 
     // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=508783



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]