Skip to content

Commit

Permalink
#105: Ensure guile mode active when calling callbacks/functions
Browse files Browse the repository at this point in the history
Since some GLib primitives can spawn new threads, we
need to ensure that Guile is active whenever
scheme callbacks and functions are called.

* src/gig_callback.c (callback_binding): init guile
* src/gig_function.c (function_binding): init guile
  • Loading branch information
spk121 committed Jan 26, 2021
1 parent f9ce477 commit 43c03ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/gig_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ callback_binding(ffi_cif *cif, gpointer ret, gpointer *ffi_args, gpointer user_d
SCM s_args = SCM_EOL;
SCM s_ret;

// When using GLib thread functions, this could be the entrypoint
// into Guile for this thread.
scm_init_guile();

g_assert(cif != NULL);
g_assert(ret != NULL);
g_assert(ffi_args != NULL);
Expand Down
6 changes: 5 additions & 1 deletion src/gig_function.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2018, 2019, 2020 Michael L. Gran
// Copyright (C) 2018, 2019, 2020, 2021 Michael L. Gran

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -626,6 +626,10 @@ function_binding(ffi_cif *cif, gpointer ret, gpointer *ffi_args, gpointer user_d
GObject *self = NULL;
SCM s_args = SCM_UNDEFINED;

// When using GLib thread functions, could this be the entrypoint
// into Guile for this thread?
scm_init_guile();

g_assert(cif != NULL);
g_assert(ret != NULL);
g_assert(ffi_args != NULL);
Expand Down

0 comments on commit 43c03ec

Please sign in to comment.