summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2023-03-02 21:03:42 -0800
committerPhilip Chimento <philip.chimento@gmail.com>2023-03-04 23:40:32 -0800
commit92ec9c84334406a32cfd97767efd6a12a5409a79 (patch)
tree2792a11eb73d9ffab00a6948884ab8e2866b2981
parent9d7b57221d405fda3a317949b4aadfa2d1116210 (diff)
downloadgjs-92ec9c84334406a32cfd97767efd6a12a5409a79.tar.gz
repo: Define namespace property on imports.gi after looking up _init()
We don't need the imports.gi.NameSpace property defined during the property lookup of _init(), only when executing it. Defining it slightly later allows us to roll back the import more effectively if the lookup fails.
-rw-r--r--gi/repo.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 92d67d65..20f445df 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -126,16 +126,16 @@ static bool resolve_namespace_object(JSContext* context,
JS::RootedObject gi_namespace(context,
gjs_create_ns(context, ns_name.get()));
+ JS::RootedValue override(context);
+ if (!lookup_override_function(context, ns_id, &override))
+ return false;
+
/* Define the property early, to avoid reentrancy issues if
the override module looks for namespaces that import this */
if (!JS_DefinePropertyById(context, repo_obj, ns_id, gi_namespace,
GJS_MODULE_PROP_FLAGS))
return false;
- JS::RootedValue override(context);
- if (!lookup_override_function(context, ns_id, &override))
- return false;
-
JS::RootedValue result(context);
if (!override.isUndefined() &&
!JS_CallFunctionValue (context, gi_namespace, /* thisp */