diff options
author | Dan Gudmundsson <[email protected]> | 2016-01-08 10:43:47 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2016-02-23 14:18:55 +0100 |
commit | a5d1c7b8fc58a8dff36d8f72df22e2c372610799 (patch) | |
tree | 89d8f3a5c656167fca008f717be0286399c81bd1 /lib | |
parent | bd5c928e1c47f05d0d7b18f4e28e42d276cfc038 (diff) | |
download | otp-a5d1c7b8fc58a8dff36d8f72df22e2c372610799.tar.gz otp-a5d1c7b8fc58a8dff36d8f72df22e2c372610799.tar.bz2 otp-a5d1c7b8fc58a8dff36d8f72df22e2c372610799.zip |
wx: Fix a crash with sending two binaries to command queue
Introduced when I optimized the binary handling.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/wx/c_src/wxe_driver.c | 2 | ||||
-rw-r--r-- | lib/wx/test/wx_basic_SUITE.erl | 14 | ||||
-rw-r--r-- | lib/wx/test/wx_event_SUITE.erl | 30 |
3 files changed, 41 insertions, 5 deletions
diff --git a/lib/wx/c_src/wxe_driver.c b/lib/wx/c_src/wxe_driver.c index eb7d7dcaeb..6f027ea25b 100644 --- a/lib/wx/c_src/wxe_driver.c +++ b/lib/wx/c_src/wxe_driver.c @@ -241,12 +241,10 @@ standard_outputv(ErlDrvData drv_data, ErlIOVec* ev) bin = ev->binv[1]; driver_binary_inc_refc(bin); /* Otherwise it could get deallocated */ binref->bin = bin; - sd->bin = binref; } else { /* Empty binary (becomes NULL) */ binref->base = NULL; binref->size = 0; binref->from = driver_caller(sd->port_handle); binref->bin = NULL; - sd->bin = binref; } } diff --git a/lib/wx/test/wx_basic_SUITE.erl b/lib/wx/test/wx_basic_SUITE.erl index 2c746158e5..0b919f6254 100644 --- a/lib/wx/test/wx_basic_SUITE.erl +++ b/lib/wx/test/wx_basic_SUITE.erl @@ -338,6 +338,20 @@ data_types(_Config) -> ?m(true, is_boolean(wxCalendarCtrl:setDate(Cal,DateTime))), ?m({Date,_}, wxCalendarCtrl:getDate(Cal)), + %% Images, test sending and reading binaries + Colors = << <<200:8, 199:8, 198:8 >> || _ <- lists:seq(1, 128*64) >>, + Alpha = << <<255:8>> || _ <- lists:seq(1, 128*64) >>, + ImgRGB = ?mt(wxImage, wxImage:new(128, 64, Colors)), + ?m(true, wxImage:ok(ImgRGB)), + ?m(false, wxImage:hasAlpha(ImgRGB)), + ?m(Colors, wxImage:getData(ImgRGB)), + + ImgRGBA = ?mt(wxImage, wxImage:new(128, 64, Colors, Alpha)), + ?m(true, wxImage:ok(ImgRGBA)), + ?m(true, wxImage:hasAlpha(ImgRGBA)), + ?m(Colors, wxImage:getData(ImgRGBA)), + ?m(Alpha, wxImage:getAlpha(ImgRGBA)), + wxClientDC:destroy(CDC), %%wx_test_lib:wx_destroy(Frame,Config). wx:destroy(). diff --git a/lib/wx/test/wx_event_SUITE.erl b/lib/wx/test/wx_event_SUITE.erl index 7e71d6ca69..516133e3e2 100644 --- a/lib/wx/test/wx_event_SUITE.erl +++ b/lib/wx/test/wx_event_SUITE.erl @@ -46,8 +46,8 @@ end_per_testcase(Func,Config) -> %% SUITE specification suite() -> [{ct_hooks,[ts_install_cth]}]. -all() -> - [connect, disconnect, connect_msg_20, connect_cb_20, +all() -> + [connect, disconnect, disconnect_cb, connect_msg_20, connect_cb_20, mouse_on_grid, spin_event, connect_in_callback, recursive, dialog, char_events, callback_clean ]. @@ -162,9 +162,33 @@ disconnect(Config) -> ?m([], wx_test_lib:flush()), wx_test_lib:wx_destroy(Frame, Config). - + +disconnect_cb(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo); +disconnect_cb(Config) -> + ?mr(wx_ref, wx:new()), + Frame = ?mt(wxFrame, wxFrame:new(wx:null(), 1, "Event Testing")), + Panel = ?mt(wxPanel, wxPanel:new(Frame)), + + Tester = self(), + CB = fun(#wx{event=#wxSize{},userData=UserD}, SizeEvent) -> + ?mt(wxSizeEvent, SizeEvent), + wxEvtHandler:disconnect(Frame, close_window), + Tester ! {got_size, UserD} + end, + ?m(ok, wxFrame:connect(Frame, close_window)), + ?m(ok, wxFrame:connect(Frame, size)), + ?m(ok, wxEvtHandler:connect(Panel, size, [{callback,CB},{userData, panel}])), + + ?m(true, wxFrame:show(Frame)), + + wxWindow:setSize(Panel, {200,100}), + get_size_messages(Frame, [frame, panel_cb]), + wx_test_lib:flush(), + + wx_test_lib:wx_destroy(Frame, Config). + %% Test that the msg events are forwarded as supposed to connect_msg_20(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo); |