[gjs/wip/xulrunner-2-rebase2: 8/9] Handle JS_InitClass throwing an error more cleanly



commit 6b0eb1117be7bc1af9efab8ee0f4974b1136e21c
Author: Colin Walters <walters verbum org>
Date:   Fri Oct 22 11:45:13 2010 -0400

    Handle JS_InitClass throwing an error more cleanly

 gi/boxed.c       |    5 +++--
 gjs/jsapi-util.c |    2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gi/boxed.c b/gi/boxed.c
index 27c2f38..70c108e 100644
--- a/gi/boxed.c
+++ b/gi/boxed.c
@@ -426,7 +426,6 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(boxed)
 
     GJS_INC_COUNTER(boxed);
 
-    g_assert(priv_from_js(context, object) == NULL);
     JS_SetPrivate(context, object, priv);
 
     gjs_debug_lifecycle(GJS_DEBUG_GBOXED,
@@ -1172,8 +1171,10 @@ gjs_define_boxed_class(JSContext    *context,
                                           NULL,
                                           /* funcs of constructor, MyConstructor.myfunc() */
                                           NULL);
-    if (prototype == NULL)
+    if (prototype == NULL) {
+        gjs_log_exception(context, NULL);
         gjs_fatal("Can't init class %s", constructor_name);
+    }
 
     g_assert(gjs_object_has_property(context, in_object, constructor_name));
 
diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
index 94e081c..4695ec0 100644
--- a/gjs/jsapi-util.c
+++ b/gjs/jsapi-util.c
@@ -535,6 +535,8 @@ gjs_init_class_dynamic(JSContext      *context,
                                  constructor, nargs,
                                  ps, fs,
                                  static_ps, static_fs);
+        if (prototype == NULL)
+            goto error;
 
         /* Retrieve the property again so we can define it in
          * in_object



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