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



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

    Handle JS_InitClass throwing an error more cleanly
    
    https://bugzilla.gnome.org/show_bug.cgi?id=632159

 gi/boxed.c       |    4 +++-
 gjs/jsapi-util.c |    2 ++
 2 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/gi/boxed.c b/gi/boxed.c
index 09e252a..a5e1560 100644
--- a/gi/boxed.c
+++ b/gi/boxed.c
@@ -1170,8 +1170,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 9b80499..bf7cc6f 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]