ini: fixed insufficient utf8->16 alloc
This commit is contained in:
parent
adca5111f6
commit
a900cbb798
2 changed files with 13 additions and 9 deletions
|
|
@ -941,11 +941,15 @@ HeaderWidget::HeaderWidget(QWidget *parent) : QWidget(parent) {
|
|||
}
|
||||
connect(channels, &QCheckBox::stateChanged, [this, parent](){
|
||||
set->setValue("show_channels", channels->isChecked(), sizeof("show_channels"));
|
||||
if(!OverseerHandler::settingsPath.empty())
|
||||
if(!OverseerHandler::settingsPath.empty()){
|
||||
set->save(OverseerHandler::settingsPath.c_str());
|
||||
if(parent)
|
||||
QCoreApplication::instance()->postEvent
|
||||
(parent, new QEvent((QEvent::Type)CustomQEvent::RecomposeMainWindow));
|
||||
}
|
||||
if(parent) {
|
||||
QEvent explosion = QEvent((QEvent::Type)CustomQEvent::RecomposeMainWindow);
|
||||
QCoreApplication::instance()->sendEvent
|
||||
(parent, &explosion);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
namespace ini {
|
||||
|
||||
wchar_t* utf8toUtf16(const char* str, uint64_t* size = nullptr) {
|
||||
wchar_t* Utf8toUtf16(const char* str, uint64_t* size = nullptr) {
|
||||
if(!str || str[0] == '\0') return nullptr;
|
||||
int sizeNeeded = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
|
||||
if(size) *size = sizeNeeded;
|
||||
wchar_t* utf16 = (wchar_t*)calloc(sizeNeeded, 1);
|
||||
wchar_t* utf16 = (wchar_t*)calloc(sizeNeeded, sizeof(wchar_t));
|
||||
MultiByteToWideChar(CP_UTF8, 0, str, -1, utf16, sizeNeeded);
|
||||
return utf16;
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ namespace ini {
|
|||
|
||||
if(!path) return false;
|
||||
uint64_t convertedPathSize = 0;
|
||||
wchar_t* convertedPath = utf8toUtf16(path, &convertedPathSize);
|
||||
wchar_t* convertedPath = Utf8toUtf16(path, &convertedPathSize);
|
||||
if(!convertedPath) return false;
|
||||
wchar_t* utf16Path = (wchar_t*)calloc(maxPathBypassLen + convertedPathSize, sizeof(wchar_t));
|
||||
memcpy(utf16Path, maxPathBypass, sizeof(wchar_t) * maxPathBypassLen);
|
||||
|
|
@ -164,7 +164,7 @@ namespace ini {
|
|||
releaseBeforeReturn();
|
||||
if (writeSuccess == TRUE) return true;
|
||||
else return false;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ namespace ini {
|
|||
|
||||
UserSettings* UserSettings::createSettings(const char* path, bool create) {
|
||||
if(!path) return nullptr;
|
||||
wchar_t* utf16Path = utf8toUtf16(path);
|
||||
wchar_t* utf16Path = Utf8toUtf16(path);
|
||||
if(!utf16Path) return nullptr;
|
||||
|
||||
#define releaseBeforeReturn() do { \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue