diff options
author | Dan Gudmundsson <[email protected]> | 2013-12-20 09:20:22 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2014-01-14 13:26:53 +0100 |
commit | 74f6d6d74f7a3be5aece37a0b419e40d96e036d4 (patch) | |
tree | 73ffc54f3b8b9b827f6f2a9aedd46b566dce7ffa /lib/wx/test/wx_event_SUITE.erl | |
parent | 3f9b80b1e635f3b5f39bd7380b3bd777ebd98338 (diff) | |
download | otp-74f6d6d74f7a3be5aece37a0b419e40d96e036d4.tar.gz otp-74f6d6d74f7a3be5aece37a0b419e40d96e036d4.tar.bz2 otp-74f6d6d74f7a3be5aece37a0b419e40d96e036d4.zip |
wx: Fix crash when garbage collect event handlers (debugger caused seg fault)
wxStyledTextCtrl had no wrapper class so, because it was not detected
that it had virtual destructors, thus references to it was not cleaned
up on destruction. When a process dies and wx cleans up the event handlers
access was made to the deleted object and caused a seg fault.
Added a testcase which I thought could provoke the bug but didn't.
Diffstat (limited to 'lib/wx/test/wx_event_SUITE.erl')
-rw-r--r-- | lib/wx/test/wx_event_SUITE.erl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/wx/test/wx_event_SUITE.erl b/lib/wx/test/wx_event_SUITE.erl index 6a9f19ad51..bbb5294d08 100644 --- a/lib/wx/test/wx_event_SUITE.erl +++ b/lib/wx/test/wx_event_SUITE.erl @@ -484,6 +484,7 @@ callback_clean(Config) -> %% timer:sleep(infinity), %% ok. + white_box_check_event_handlers() -> {_,_,Server,_} = wx:get_env(), {status, _, _, [Env, _, _, _, Data]} = sys:get_status(Server), @@ -495,3 +496,35 @@ white_box_check_event_handlers() -> gb_trees:to_list(CBs), [Funs || Funs = {Id, {Fun,_}} <- Env, is_integer(Id), is_function(Fun)] }. + +handler_clean(TestInfo) when is_atom(TestInfo) -> + wx_test_lib:tc_info(TestInfo); +handler_clean(_Config) -> + wx:new(), + Init = fun() -> create_window() end, + Frame1 = wx_obj_test:start([{init, Init}]), + ?mt(wxFrame, Frame1), + wxWindow:show(Frame1), + ?m([_|_], lists:sort(wx_test_lib:flush())), + ?m({stop,_}, wx_obj_test:stop(Frame1, fun(_) -> normal end)), + ?m([{terminate,normal}], lists:sort(wx_test_lib:flush())), + + Frame2 = wx_obj_test:start([{init, Init}]), + wxWindow:show(Frame2), + ?m([_|_], lists:sort(wx_test_lib:flush())), + ?m({stop,_}, wx_obj_test:stop(Frame2, fun(_) -> wxWindow:destroy(Frame2), normal end)), + ?m([{terminate,normal}], lists:sort(wx_test_lib:flush())), + timer:sleep(104), + ?m({[],[],[]}, white_box_check_event_handlers()), + ?m(ok, wx:destroy()), + ok. + +create_window() -> + Frame = wxFrame:new(wx:null(), ?wxID_ANY, "Test wx_object", [{size, {500, 400}}]), + Sz = wxBoxSizer:new(?wxHORIZONTAL), + Panel = wxPanel:new(Frame), + wxSizer:add(Sz, Panel, [{flag, ?wxEXPAND}, {proportion, 1}]), + wxWindow:connect(Frame, show), + %% wxPanel:connect(Panel, paint, [callback, {userData, foobar}]), + wxWindow:connect(Panel, size, [callback]), + {Frame, {Frame, Panel}}. |