Skip to content

Commit 9c7ab0d

Browse files
committed
GUIの自動開始設定の挙動が正しくなかったのを修正
1 parent 6494205 commit 9c7ab0d

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

waifu2x-caffe-gui/Source.cpp

+30-25
Original file line numberDiff line numberDiff line change
@@ -1997,36 +1997,40 @@ class DialogEvent
19971997

19981998
// ドロップされたファイル数を取得
19991999
UINT FileNum = DragQueryFile((HDROP)wParam, 0xFFFFFFFF, szTmp, _countof(szTmp));
2000-
if (FileNum == 1)
2000+
if (FileNum > 0)
20012001
{
2002-
DragQueryFile((HDROP)wParam, 0, szTmp, _countof(szTmp));
2003-
szTmp[_countof(szTmp) - 1] = TEXT('\0');
2004-
2005-
OnSetInputFilePath(szTmp);
2006-
}
2007-
else if (FileNum > 1)
2008-
{
2009-
input_str_multi.clear();
2002+
if (FileNum == 1)
2003+
{
2004+
DragQueryFile((HDROP)wParam, 0, szTmp, _countof(szTmp));
2005+
szTmp[_countof(szTmp) - 1] = TEXT('\0');
20102006

2011-
for (UINT i = 0; i < FileNum; i++)
2007+
OnSetInputFilePath(szTmp);
2008+
}
2009+
else if (FileNum > 1)
20122010
{
2013-
TCHAR szTmp[AR_PATH_MAX];
2011+
input_str.clear();
2012+
input_str_multi.clear();
20142013

2015-
if (DragQueryFile((HDROP)wParam, i, szTmp, _countof(szTmp)) < _countof(szTmp))
2014+
for (UINT i = 0; i < FileNum; i++)
20162015
{
2017-
szTmp[_countof(szTmp) - 1] = TEXT('\0');
2016+
TCHAR szTmp[AR_PATH_MAX];
2017+
2018+
if (DragQueryFile((HDROP)wParam, i, szTmp, _countof(szTmp)) < _countof(szTmp))
2019+
{
2020+
szTmp[_countof(szTmp) - 1] = TEXT('\0');
20182021

2019-
input_str_multi.push_back(szTmp);
2022+
input_str_multi.push_back(szTmp);
2023+
}
20202024
}
2021-
}
20222025

2023-
OnSetInputFilePath();
2024-
}
2026+
OnSetInputFilePath();
2027+
}
20252028

2026-
if (SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_ONE), BM_GETCHECK, 0, 0) ||
2027-
(SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_MULTI), BM_GETCHECK, 0, 0) && input_str_multi.size() > 0))
2028-
{
2029-
::PostMessage(GetDlgItem(dh, IDC_BUTTON_EXEC), BM_CLICK, 0, 0);
2029+
if (SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_ONE), BM_GETCHECK, 0, 0) ||
2030+
(SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_MULTI), BM_GETCHECK, 0, 0) && (input_str_multi.size() > 0 || boost::filesystem::is_directory(szTmp))))
2031+
{
2032+
::PostMessage(GetDlgItem(dh, IDC_BUTTON_EXEC), BM_CLICK, 0, 0);
2033+
}
20302034
}
20312035

20322036
return 0L;
@@ -2130,13 +2134,14 @@ class DialogEvent
21302134
{
21312135
szFile[szFile.size() - 1] = TEXT('\0');
21322136

2133-
input_str_multi.clear();
2134-
21352137
const TCHAR * ptr = szFile.data();
21362138

21372139
const auto firstLen = _tcslen(ptr);
21382140
if (firstLen > 0)
21392141
{
2142+
input_str.clear();
2143+
input_str_multi.clear();
2144+
21402145
if(firstLen + 2 >= szFile.size() || ptr[firstLen + 1] == '\0')
21412146
OnSetInputFilePath(ptr);
21422147
else
@@ -2167,8 +2172,8 @@ class DialogEvent
21672172
OnSetInputFilePath();
21682173
}
21692174

2170-
if (SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_ONE), BM_GETCHECK, 0, 0) ||
2171-
(SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_MULTI), BM_GETCHECK, 0, 0) && input_str_multi.size() > 0))
2175+
if ( SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_ONE), BM_GETCHECK, 0, 0) ||
2176+
(SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_MULTI), BM_GETCHECK, 0, 0) && (input_str_multi.size() > 0 || boost::filesystem::is_directory(szFile.data()))))
21722177
{
21732178
::PostMessage(GetDlgItem(dh, IDC_BUTTON_EXEC), BM_CLICK, 0, 0);
21742179
}

0 commit comments

Comments
 (0)