From 4246d988b53947c7a7f0ce4943a83af38d129435 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Tue, 30 Jun 2015 12:53:02 +0200 Subject: wx: Send wxWdigets assert to error logger Instead of popping up an annoying msgbox --- lib/wx/c_src/wxe_impl.cpp | 19 +++++++++++++++++++ lib/wx/c_src/wxe_impl.h | 5 +++++ lib/wx/test/wx_class_SUITE.erl | 6 +++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp index 6236fb708e..e6ed236962 100644 --- a/lib/wx/c_src/wxe_impl.cpp +++ b/lib/wx/c_src/wxe_impl.cpp @@ -181,6 +181,25 @@ void WxeApp::dummy_close(wxEvent& Ev) { // windows open, and this will kill the erlang, override default handling } +void WxeApp::OnAssertFailure(const wxChar *file, int line, const wxChar *cfunc, + const wxChar *cond, const wxChar *cmsgUser) { + wxString msg; + wxString func(cfunc); + wxString msgUser(cmsgUser); + + msg.Printf(wxT("wxWidgets Assert failure: %s(%d): \"%s\""), + file, line, cond); + if ( !func.empty() ) { + msg << wxT(" in ") << func << wxT("()"); + } + // and the message itself + if ( !msgUser.empty() ) { + msg << wxT(" : ") << msgUser; + } + + send_msg("error", &msg); +} + // Called by wx thread void WxeApp::idle(wxIdleEvent& event) { event.Skip(true); diff --git a/lib/wx/c_src/wxe_impl.h b/lib/wx/c_src/wxe_impl.h index d8241d11a4..d6d3095a0f 100644 --- a/lib/wx/c_src/wxe_impl.h +++ b/lib/wx/c_src/wxe_impl.h @@ -57,9 +57,14 @@ class WxeApp : public wxApp { public: virtual bool OnInit(); + + virtual void OnAssertFailure(const wxChar *file, int line, const wxChar *func, + const wxChar *cond, const wxChar *msg); + #ifdef _MACOSX virtual void MacOpenFile(const wxString &filename); #endif + void shutdown(wxeMetaCommand& event); int dispatch(wxeFifo *, int, int); diff --git a/lib/wx/test/wx_class_SUITE.erl b/lib/wx/test/wx_class_SUITE.erl index fd6023a820..ebae32aeb8 100644 --- a/lib/wx/test/wx_class_SUITE.erl +++ b/lib/wx/test/wx_class_SUITE.erl @@ -386,13 +386,17 @@ listCtrlSort(Config) -> io:format("Sorted ~p ~n",[Time]), Item = wxListItem:new(), + + %% Force an assert on (and debug compiled) which 3.0 is by default + wxListItem:setId(Item, 200), + io:format("Got ~p ~n", [wxListCtrl:getItem(LC, Item)]), + wxListItem:setMask(Item, ?wxLIST_MASK_TEXT), _List = wx:map(fun(Int) -> wxListItem:setId(Item, Int), ?m(true, wxListCtrl:getItem(LC, Item)), io:format("~p: ~s~n",[Int, wxListItem:getText(Item)]) end, lists:seq(0,10)), - wxListItem:destroy(Item), wx_test_lib:wx_destroy(Frame,Config). -- cgit v1.2.3