From d7805acb99f2b7ccd97541d189f6494966564d98 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Fri, 25 Jan 2019 08:38:33 +0100 Subject: Fix showModal crash on Mojave Invoking wxDialog:showModal could cause a seg-fault on Mojave if invoked from inside event callback. Which could happen when wx dispatch commands inside send_event. Wx dispatches commands inside send_event because some events will not return to idle mode (on Windows) until mouse is released. These events are (at least) wxSize and wxMove according to previous commits. Solved by only dispatching commands for those events. Another solution might be to ifdef the code to only do it on windows or not do it on the Mac. --- lib/wx/api_gen/wx_gen_cpp.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/wx/api_gen') diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl index a29172032b..c6f2534380 100644 --- a/lib/wx/api_gen/wx_gen_cpp.erl +++ b/lib/wx/api_gen/wx_gen_cpp.erl @@ -1332,8 +1332,10 @@ encode_events(Evs) -> w(" } else {~n"), w(" send_res = rt.send();~n"), w(" if(cb->skip) event->Skip();~n"), - #class{id=MouseId} = lists:keyfind("wxMouseEvent", #class.name, Evs), - w(" if(app->recurse_level < 1 && Etype->cID != ~p) {~n", [MouseId]), + #class{id=SizeId} = lists:keyfind("wxSizeEvent", #class.name, Evs), + #class{id=MoveId} = lists:keyfind("wxMoveEvent", #class.name, Evs), + w(" if(app->recurse_level < 1 && (Etype->cID == ~w || Etype->cID == ~w)) {~n", + [SizeId, MoveId]), w(" app->recurse_level++;~n"), w(" app->dispatch_cmds();~n"), w(" app->recurse_level--;~n"), -- cgit v1.2.3