Skip to content

Commit e19bfec

Browse files
committed
異常停止不具合を修正
1 parent 061bdc0 commit e19bfec

3 files changed

Lines changed: 13 additions & 18 deletions

File tree

Utils.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -640,23 +640,14 @@ XGStringW XgBinToHex(const void *ptr, size_t size)
640640
// 16進をバイナリにする。
641641
void XgHexToBin(std::vector<BYTE>& data, const XGStringW& str)
642642
{
643-
WCHAR sz[3];
644643
data.clear();
645-
bool flag = false;
646-
sz[2] = 0;
647-
for (auto& ch : str)
644+
WCHAR sz[3] = {};
645+
size_t len = str.size() & ~size_t(1); // 奇数なら最後の1文字を捨てる(既存動作と同じ)
646+
for (size_t i = 0; i < len; i += 2)
648647
{
649-
if (flag)
650-
{
651-
sz[1] = ch;
652-
const auto b = static_cast<BYTE>(wcstol(sz, nullptr, 16));
653-
data.insert(data.end(), b);
654-
}
655-
else
656-
{
657-
sz[0] = ch;
658-
}
659-
flag = !flag;
648+
sz[0] = str[i];
649+
sz[1] = str[i + 1];
650+
data.push_back(static_cast<BYTE>(wcstol(sz, nullptr, 16)));
660651
}
661652
}
662653

XG_SettingsDialog.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,10 @@ BOOL XG_SettingsDialog::DoImportLooks(HWND hwnd, LPCWSTR pszFileName)
398398
std::vector<BYTE> data;
399399
XgHexToBin(data, szText);
400400
XGStringW str;
401-
str.resize(data.size() / sizeof(WCHAR));
402-
memcpy(&str[0], data.data(), data.size());
401+
size_t charCount = data.size() / sizeof(WCHAR);
402+
str.resize(charCount);
403+
if (charCount)
404+
memcpy(&str[0], data.data(), charCount * sizeof(WCHAR)); // バッファ分だけコピー
403405
ComboBox_RealSetText(hCmb2, str.c_str());
404406
}
405407

@@ -913,7 +915,6 @@ XG_SettingsDialog::DialogProcDx(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
913915
case psh3: // マスのフォントリセット
914916
m_lfCellFont = {};
915917
::SetDlgItemTextW(hwnd, edt1, L"");
916-
PropSheet_Changed(GetParent(hwnd), hwnd);
917918
break;
918919

919920
case psh4: // 小さいフォントリセット

XgViewSettings.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ XgViewSettingsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
239239
// 表示を更新。
240240
XgUpdateImage(xg_hMainWnd);
241241
SendMessageW(xg_hMainWnd, WM_SIZE, 0, 0);
242+
243+
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, PSNRET_NOERROR);
244+
return TRUE;
242245
}
243246
break;
244247
}

0 commit comments

Comments
 (0)