Use std::string instead of strange conversion.

It just makes life easier.
This commit is contained in:
Arthur Moore 2015-03-12 06:59:45 -04:00
parent 4aa526d623
commit e8b8ee7bc2
3 changed files with 12 additions and 18 deletions

View File

@ -1925,16 +1925,6 @@ public:
} throttle_ctrl;
/////////////////////////////
///Helper functions to convert WX's crazy string types to std::string
std::string ToString(wxCharBuffer aString)
{
return std::string(aString);
}
std::string ToString(const wxChar* aString)
{
return std::string(wxString(aString).mb_str(wxConvUTF8));
}
///Check if a pointer from the XRC file is valid. If it's not, throw an error telling the user.
template <typename T>

View File

@ -1232,16 +1232,11 @@ void DrawingPanel::DrawArea(u8 **data)
10, 20, panel->osdstat.utf8_str(), gopts.osd_transparent);
if(!gopts.no_osd_status && !panel->osdtext.empty()) {
if(systemGetClock() - panel->osdtime < OSD_TIME) {
std::string message = ToString(panel->osdtext);
int linelen = (width * scale - 20) / 8;
// auto-conversion of wxCharBuffer to const char * seems broken
// so save underlying wxCharBuffer (or create one of none is used)
wxCharBuffer msg_mb = panel->osdtext.mb_str();
int msglen = strlen(msg_mb.data());
char msg[msglen + 1];
memcpy(msg, msg_mb.data(), msglen + 1);
int nlines = (msglen + linelen - 1) / linelen;
int nlines = (message.length() + linelen - 1) / linelen;
int cury = height - 14 - nlines * 10;
char *ptr = msg;
char *ptr = const_cast<char *>(message.c_str());
while(nlines > 1) {
char lchar = ptr[linelen];
ptr[linelen] = 0;

View File

@ -41,7 +41,16 @@ void CheckPointer(T pointer)
throw std::runtime_error(errormessage);
}
}
///Helper functions to convert WX's crazy string types to std::string
inline std::string ToString(wxCharBuffer aString)
{
return std::string(aString);
}
inline std::string ToString(const wxChar* aString)
{
return std::string(wxString(aString).mb_str(wxConvUTF8));
}
class MainFrame;