string conversion issues

4 views
Skip to first unread message

Tim Hutton

unread,
Dec 3, 2019, 5:42:42 PM12/3/19
to reaction-...@googlegroups.com
So I've just pushed a fix for issue #38 in Ready. Turns out that it was caused by us doing this:

wxString filename;
// ...
const char* filename_cstr = filename.mb_str();

This is wrong and should never be done, according to:
https://wiki.wxwidgets.org/WxString#Converting_a_wxString_to_a_Normal_String
And indeed changing it has made the bug disappear.

We have quite a lot of bits in the code where we do this, e.g.:

const char* filename_cstr = filename.mb_str();
if (strlen(filename_cstr) == 0)
{
    wxMessageBox(_("Unsupported characters in path"), _("Error"), wxOK | wxCENTER | wxICON_ERROR);
    return;
}

I'll change these as I see them but I know that we've struggled with string conversion in the past and I'm wary of breaking things.

Tim
Reply all
Reply to author
Forward
0 new messages