minor OSD code cleanup
Use strdup instead of a stack variable + strncpy to convert the osd wxString message to a C string, hopefully fixes an MSVC incompatiblity.
This commit is contained in:
parent
0dc3e06c99
commit
947cd10e2f
|
@ -1,3 +1,4 @@
|
||||||
|
#include <cstdlib>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <wx/dcbuffer.h>
|
#include <wx/dcbuffer.h>
|
||||||
|
@ -1792,10 +1793,8 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
|
||||||
int linelen = std::ceil(width * scale - 20) / 8;
|
int linelen = std::ceil(width * scale - 20) / 8;
|
||||||
int nlines = (message.size() + linelen - 1) / linelen;
|
int nlines = (message.size() + linelen - 1) / linelen;
|
||||||
int cury = height - 14 - nlines * 10;
|
int cury = height - 14 - nlines * 10;
|
||||||
const char* msg_data = message.mb_str();
|
char* buf = strdup(message.mb_str());
|
||||||
char buf[message.size() + 1];
|
char* ptr = buf;
|
||||||
char* ptr = &buf[0];
|
|
||||||
std::strncpy(ptr, msg_data, message.size() + 1);
|
|
||||||
|
|
||||||
while (nlines > 1) {
|
while (nlines > 1) {
|
||||||
char lchar = ptr[linelen];
|
char lchar = ptr[linelen];
|
||||||
|
@ -1812,6 +1811,8 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
|
||||||
drawText(todraw + outstride * (systemColorDepth != 24),
|
drawText(todraw + outstride * (systemColorDepth != 24),
|
||||||
outstride, 10, cury, ptr,
|
outstride, 10, cury, ptr,
|
||||||
showSpeedTransparent);
|
showSpeedTransparent);
|
||||||
|
|
||||||
|
free(buf);
|
||||||
} else
|
} else
|
||||||
panel->osdtext.clear();
|
panel->osdtext.clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue