From 92ec9c84334406a32cfd97767efd6a12a5409a79 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 2 Mar 2023 21:03:42 -0800 Subject: 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. --- gi/repo.cpp | 8 ++++---- 1 file 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 */ -- cgit v1.2.1