summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gudmundsson <dgud@erlang.org>2023-04-01 10:37:45 +0200
committerDan Gudmundsson <dgud@erlang.org>2023-04-24 09:47:31 +0200
commit448b7ab802bea8fef87c52733c8001572a77ecd8 (patch)
tree5d6473becc78ff5f3457426e6374aef5d4976711
parentb1f297425d7ea4f66f641cd8742dbe5b6f9dd588 (diff)
downloaderlang-448b7ab802bea8fef87c52733c8001572a77ecd8.tar.gz
wx: Use temp env for send_msg
send_msg can be called via (gtk debug msgs) callback when the env is already in use. Noticed with a assert in debug compiled erl. Solve by using a temporary "env" when sending msgs.
-rw-r--r--lib/wx/c_src/wxe_impl.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp
index 48c5bd2f4c..52e9757d2e 100644
--- a/lib/wx/c_src/wxe_impl.cpp
+++ b/lib/wx/c_src/wxe_impl.cpp
@@ -113,11 +113,14 @@ void meta_command(ErlNifEnv *env, int what, wxe_me_ref *mp) {
void send_msg(const char * type, const wxString * msg) {
WxeApp * app = (WxeApp *) wxTheApp;
wxeReturn rt = wxeReturn(app->global_me, init_caller);
+ ErlNifEnv *env = enif_alloc_env();
+ rt.env = env;
ERL_NIF_TERM emsg = enif_make_tuple3(rt.env,
rt.make_atom((char *) "wxe_driver"),
rt.make_atom((char *) type),
rt.make(msg));
rt.send(emsg);
+ enif_free_env(env);
}
void wx_print_term(ErlNifEnv * env, ERL_NIF_TERM t)