[gjs] Report errors in javascript property getters/setters



commit 23e33a2d87d9b0af0e97c7adf0d048b1996fb776
Author: Matt Watson <mattdangerw gmail com>
Date:   Tue May 13 19:01:11 2014 -0700

    Report errors in javascript property getters/setters
    
    When writing a Lang.Class with gobject properties, gjs will
    call getters and setters on your properties with JS_GetProperty
    and JS_SetProperty.
    
    These calls can fail if there's an error in the resulting javascript,
    and failures were being silently ignored. Now we report errors
    immediately and clear them from SpiderMonkey's pending exceptions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730101

 gi/object.cpp |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 5e07378..376dd85 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2415,11 +2415,11 @@ gjs_object_get_gproperty (GObject    *object,
     js_obj = peek_js_obj(object);
 
     underscore_name = hyphen_to_underscore((gchar *)pspec->name);
-    JS_GetProperty(context, js_obj, underscore_name, &jsvalue);
+    if (!JS_GetProperty(context, js_obj, underscore_name, &jsvalue))
+        gjs_log_exception(context);
+    else
+        gjs_value_to_g_value(context, jsvalue, value);
     g_free (underscore_name);
-
-    if (!gjs_value_to_g_value(context, jsvalue, value))
-        return;
 }
 
 static void
@@ -2443,7 +2443,8 @@ gjs_object_set_gproperty (GObject      *object,
         return;
 
     underscore_name = hyphen_to_underscore((gchar *)pspec->name);
-    JS_SetProperty(context, js_obj, underscore_name, &jsvalue);
+    if (!JS_SetProperty(context, js_obj, underscore_name, &jsvalue))
+        gjs_log_exception(context);
     g_free (underscore_name);
 }
 


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