diff options
Diffstat (limited to 'gjs/context.cpp')
-rw-r--r-- | gjs/context.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gjs/context.cpp b/gjs/context.cpp index 83d5bedc..06f43e31 100644 --- a/gjs/context.cpp +++ b/gjs/context.cpp @@ -75,6 +75,7 @@ #include "gjs/importer.h" #include "gjs/internal.h" #include "gjs/jsapi-util.h" +#include "gjs/mainloop.h" #include "gjs/mem.h" #include "gjs/module.h" #include "gjs/native.h" @@ -453,6 +454,7 @@ void GjsContextPrivate::dispose(void) { delete m_fundamental_table; delete m_gtype_table; delete m_atoms; + delete m_main_loop; /* Tear down JS */ JS_DestroyContext(m_cx); @@ -564,6 +566,8 @@ GjsContextPrivate::GjsContextPrivate(JSContext* cx, GjsContext* public_context) m_atoms = new GjsAtoms(); + m_main_loop = new Gjs::MainLoop(); + if (ObjectBox::gtype() == 0) g_error("Failed to initialize JSObject GType"); @@ -1264,6 +1268,9 @@ bool GjsContextPrivate::eval(const char* script, ssize_t script_len, JS::RootedValue retval(m_cx); bool ok = eval_with_scope(nullptr, script, script_len, filename, &retval); + if (ok) + m_main_loop->spin(m_public_context); + /* The promise job queue should be drained even on error, to finish * outstanding async tasks before the context is torn down. Drain after * uncaught exceptions have been reported since draining runs callbacks. */ @@ -1328,6 +1335,9 @@ bool GjsContextPrivate::eval_module(const char* identifier, bool ok = JS::ModuleEvaluate(m_cx, obj); + if (ok) + m_main_loop->spin(m_public_context); + /* The promise job queue should be drained even on error, to finish * outstanding async tasks before the context is torn down. Drain after * uncaught exceptions have been reported since draining runs callbacks. |