Skip to content

Commit 448b7ab

Browse files
committed
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.
1 parent b1f2974 commit 448b7ab

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/wx/c_src/wxe_impl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,14 @@ void meta_command(ErlNifEnv *env, int what, wxe_me_ref *mp) {
113113
void send_msg(const char * type, const wxString * msg) {
114114
WxeApp * app = (WxeApp *) wxTheApp;
115115
wxeReturn rt = wxeReturn(app->global_me, init_caller);
116+
ErlNifEnv *env = enif_alloc_env();
117+
rt.env = env;
116118
ERL_NIF_TERM emsg = enif_make_tuple3(rt.env,
117119
rt.make_atom((char *) "wxe_driver"),
118120
rt.make_atom((char *) type),
119121
rt.make(msg));
120122
rt.send(emsg);
123+
enif_free_env(env);
121124
}
122125

123126
void wx_print_term(ErlNifEnv * env, ERL_NIF_TERM t)

0 commit comments

Comments
 (0)