oclass = g_type_class_ref (type);
+ // Check for an exception in class init (which may have just been called
+ // by g_type_class_ref, if this is the first construction of this class).
+ // Bubble up the exception, and clear it from the class's qdata so that
+ // this doesn't happen on subsequent construction.
+ GQuark class_init_exception_q =
+ g_quark_from_static_string("type-class-init-exception");
+ JSValueRef class_init_exception =
+ (JSValueRef)g_type_get_qdata(type, class_init_exception_q);
+ if(class_init_exception)
+ {
+ *exception = class_init_exception;
+ g_type_set_qdata(type, class_init_exception_q, NULL);
+ return (JSObjectRef) JSValueMakeNull (ctx);
+ }
+
if (argumentCount > 1)
{
seed_make_exception (ctx, exception, "ArgumentError",
JSContextRef ctx;
JSValueRef jsargs[2];
GType type;
- gchar *mes;
JSValueRef exception = NULL;
int initial_prop_count = 1;
+ GQuark class_init_exception_q =
+ g_quark_from_static_string("type-class-init-exception");
priv = (SeedGClassPrivates *) class_data;
JSGlobalContextRelease ((JSGlobalContextRef) ctx);
if (exception)
{
- mes = seed_exception_to_string (ctx, exception);
- g_warning ("Exception in class init closure. %s \n", mes);
- g_free (mes);
+ g_type_set_qdata(type, class_init_exception_q, (gpointer)exception);
}
return;
}
JSObjectCallAsFunction (ctx, priv->func, 0, 2, jsargs, &exception);
if (exception)
{
- mes = seed_exception_to_string (ctx, exception);
- g_warning ("Exception in class init closure. %s \n", mes);
- g_free (mes);
+ g_type_set_qdata(type, class_init_exception_q, (gpointer)exception);
}
JSGlobalContextRelease ((JSGlobalContextRef) ctx);
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:\n\*\* \(seed:[0-9]+\): WARNING \*\*: Exception in class init closure\. Line 14 in .*\/gtype-class-init-exception\.js: ReferenceError Can't find variable: notAVariable
testsuite = imports.testsuite
Gtk = imports.gi.Gtk
catch(e)
{
testsuite.assert(e instanceof ReferenceError)
- // TODO: THIS TEST DOESN'T WORK EITHER!
- // what's going on with chained exception stuff
}
-//testsuite.checkAsserts(1)
+testsuite.checkAsserts(1)
-print("This test doesn't work yet...")