From 33776e5154bbee22f54edd958bcbfdc9331091e8 Mon Sep 17 00:00:00 2001 From: lltcggie Date: Sat, 9 Jul 2016 14:51:05 +0900 Subject: [PATCH] =?UTF-8?q?GUI=E7=89=88=E3=81=AE=E5=85=A5=E5=8A=9B?= =?UTF-8?q?=E5=8F=82=E7=85=A7=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=81=A7=E5=A4=A7=E9=87=8F=E3=81=AE=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=82=92=E9=81=B8=E6=8A=9E=E3=81=97=E3=81=9F=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=80=81=E5=BC=B7=E5=88=B6=E7=B5=82=E4=BA=86=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=83=90=E3=82=B0=E3=82=92=E4=BF=AE=E6=AD=A3=20#36?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- waifu2x-caffe-gui/MainDialog.cpp | 35 ++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/waifu2x-caffe-gui/MainDialog.cpp b/waifu2x-caffe-gui/MainDialog.cpp index 747ec19..028d16b 100644 --- a/waifu2x-caffe-gui/MainDialog.cpp +++ b/waifu2x-caffe-gui/MainDialog.cpp @@ -1080,7 +1080,6 @@ UINT_PTR DialogEvent::OFNHookProcIn(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM { case CDN_SELCHANGE: { - TCHAR szPath[AR_PATH_MAX] = TEXT(""); HWND hParent = GetParent(hdlg); stFindParam param; @@ -1102,16 +1101,40 @@ UINT_PTR DialogEvent::OFNHookProcIn(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM if (results.size() > 1) { - TCHAR str[10000] = TEXT(""); + const size_t addSize = 5000; + std::vector str(10000); + str[0] = TEXT('\0'); + + size_t nlen = 0; + const auto funcC = [&nlen, &str, addSize](const TCHAR c) + { + while (str.size() <= nlen + 1 + 1) + str.resize(str.size() + addSize); + + str.data()[nlen] = c; + nlen += 1; + }; + + const auto funcStr = [&nlen, &str, addSize](const tstring &s) + { + while (str.size() <= nlen + s.length() + 1) + str.resize(str.size() + addSize); + + memcpy(str.data() + nlen, s.c_str(), sizeof(TCHAR) * s.length()); + nlen += s.length(); + }; for (const auto &p : results) { - _tcscat_s(str, TEXT("\"")); - _tcscat_s(str, p.c_str()); - _tcscat_s(str, TEXT("\" ")); + funcC(TEXT('\"')); + funcStr(p); + funcC(TEXT('\"')); + funcC(TEXT(' ')); } - CommDlg_OpenSave_SetControlText(hParent, edt1, str); + str[nlen] = TEXT('\0'); + + CommDlg_OpenSave_SetControlText(hParent, edt1, str.data()); } else if(results.size() == 1) CommDlg_OpenSave_SetControlText(hParent, edt1, results[0].c_str());