From 741dd542f2132e2e13bf54a006079505840c1c5e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 24 Aug 2017 14:17:33 +0200 Subject: [PATCH] Fix assert in the text sample when logging char events Passing long argument to "%c" printf format specifier was correctly flagged as invalid in 64 bit Unix builds where long != int. Fix this by just making the "keycode" variable int in the first place, there doesn't seem to be any reason whatsoever for it to be long and this allows us to get rid of a couple of existing casts instead of adding yet another one. --- samples/text/text.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/text/text.cpp b/samples/text/text.cpp index 79d141c043..97e995f877 100644 --- a/samples/text/text.cpp +++ b/samples/text/text.cpp @@ -588,7 +588,7 @@ bool MyTextCtrl::ms_logClip = false; void MyTextCtrl::LogKeyEvent(const wxChar *name, wxKeyEvent& event) const { wxString key; - long keycode = event.GetKeyCode(); + const int keycode = event.GetKeyCode(); { switch ( keycode ) { @@ -710,12 +710,12 @@ void MyTextCtrl::LogKeyEvent(const wxChar *name, wxKeyEvent& event) const default: { - if ( wxIsprint((int)keycode) ) - key.Printf(wxT("'%c'"), (char)keycode); + if ( wxIsprint(keycode) ) + key.Printf(wxT("'%c'"), keycode); else if ( keycode > 0 && keycode < 27 ) key.Printf(_("Ctrl-%c"), wxT('A') + keycode - 1); else - key.Printf(wxT("unknown (%ld)"), keycode); + key.Printf(wxT("unknown (%d)"), keycode); } } }