diff options
author | Dan Gudmundsson <[email protected]> | 2011-11-16 15:03:31 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2011-11-16 15:03:31 +0100 |
commit | f44805dc16feb213f65a65c9a74f1e3125976c2f (patch) | |
tree | 98b3ca5e51e534a1a0c95d2db819c68b4a794dad /lib/wx/test | |
parent | 88d995112219ca3339be12776757ef564cb04f8d (diff) | |
download | otp-f44805dc16feb213f65a65c9a74f1e3125976c2f.tar.gz otp-f44805dc16feb213f65a65c9a74f1e3125976c2f.tar.bz2 otp-f44805dc16feb213f65a65c9a74f1e3125976c2f.zip |
[wx] Fix deadlock in callback handling
New testcase showcase the deadlock
Diffstat (limited to 'lib/wx/test')
-rw-r--r-- | lib/wx/test/wx_event_SUITE.erl | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/wx/test/wx_event_SUITE.erl b/lib/wx/test/wx_event_SUITE.erl index 0d8dd4852e..8f364049b4 100644 --- a/lib/wx/test/wx_event_SUITE.erl +++ b/lib/wx/test/wx_event_SUITE.erl @@ -47,7 +47,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> [connect, disconnect, connect_msg_20, connect_cb_20, - mouse_on_grid, spin_event, connect_in_callback]. + mouse_on_grid, spin_event, connect_in_callback, recursive]. groups() -> []. @@ -331,3 +331,35 @@ connect_in_callback(Config) -> wx_test_lib:flush(), wx_test_lib:wx_destroy(Frame, Config). + +%% Test that event callback which triggers another callback works +%% i.e. the callback invoker in driver will recurse +recursive(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo); +recursive(Config) -> + Wx = wx:new(), + Frame = wxFrame:new(Wx, ?wxID_ANY, "Connect in callback"), + Panel = wxPanel:new(Frame, []), + Sz = wxBoxSizer:new(?wxVERTICAL), + ListBox = wxListBox:new(Panel, ?wxID_ANY, [{choices, ["foo", "bar", "baz"]}]), + wxSizer:add(Sz, ListBox, [{proportion, 1},{flag, ?wxEXPAND}]), + wxWindow:setSizer(Panel, Sz), + wxListBox:connect(ListBox, command_listbox_selected, + [{callback, + fun(#wx{event=#wxCommand{commandInt=Id}}, _) -> + io:format("Selected ~p~n",[Id]) + end}]), + wxListBox:setSelection(ListBox, 0), + wxListBox:connect(ListBox, size, + [{callback, + fun(#wx{event=#wxSize{}}, _) -> + io:format("Size init ~n",[]), + case wxListBox:getCount(ListBox) > 0 of + true -> wxListBox:delete(ListBox, 0); + false -> ok + end, + io:format("Size done ~n",[]) + end}]), + wxFrame:show(Frame), + wx_test_lib:flush(), + + wx_test_lib:wx_destroy(Frame, Config). |