[gjs] Object: don't register modules in a constructor



commit db3219b0781242056e1ddcf03810cc30a588f0ea
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Wed May 23 18:56:02 2012 +0200

    Object: don't register modules in a constructor
    
    Registering the private _gi module with the normal macro causes it to be
    done before main() and before the app initialized the context.
    A side effect of this was that gjs initialized logging before
    gnome-shell set up the necessary environment variables, breaking it
    unless enabled from outside.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676664

 gi/object.c   |    9 ++++-----
 gjs/context.c |    1 +
 gjs/gi.h      |    2 ++
 3 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gi/object.c b/gi/object.c
index 825c61f..e2bd014 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -25,6 +25,7 @@
 
 #include <string.h>
 
+#include <gjs/gi.h>
 #include "object.h"
 #include "gtype.h"
 #include "arg.h"
@@ -2316,9 +2317,9 @@ gjs_signal_new(JSContext *cx,
     return ret;
 }
 
-static JSBool
-gjs_define_stuff(JSContext *context,
-                    JSObject  *module_obj)
+JSBool
+gjs_define_private_gi_stuff(JSContext *context,
+                            JSObject  *module_obj)
 {
     if (!JS_DefineFunction(context, module_obj,
                            "register_type",
@@ -2352,5 +2353,3 @@ gjs_define_stuff(JSContext *context,
 
     return JS_TRUE;
 }
-
-GJS_REGISTER_NATIVE_MODULE("_gi", gjs_define_stuff)
diff --git a/gjs/context.c b/gjs/context.c
index f833856..06b8af2 100644
--- a/gjs/context.c
+++ b/gjs/context.c
@@ -357,6 +357,7 @@ gjs_context_class_init(GjsContextClass *klass)
                                       G_TYPE_NONE, 0);
 
     gjs_register_native_module("byteArray", gjs_define_byte_array_stuff, 0);
+    gjs_register_native_module("_gi", gjs_define_private_gi_stuff, 0);
 }
 
 static void
diff --git a/gjs/gi.h b/gjs/gi.h
index b6c1455..b3705e2 100644
--- a/gjs/gi.h
+++ b/gjs/gi.h
@@ -34,6 +34,8 @@ G_BEGIN_DECLS
 
 JSBool        gjs_define_gi_stuff     (JSContext      *context,
                                        JSObject       *module_obj);
+JSBool        gjs_define_private_gi_stuff   (JSContext     *context,
+                                             JSObject      *module_obj);
 
 G_END_DECLS
 



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