diff options
author | nijtmans <nijtmans> | 2010-05-17 08:43:58 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2010-05-17 08:43:58 (GMT) |
commit | c8ab85ecfd0e2802bb98ab00e67b9acaa01a5577 (patch) | |
tree | f00ab26a5c6edc02a389c79fd585beb4b8df33a1 /win | |
parent | ede9fc2f74a2e9aa5084e18c93d903e81f0f3303 (diff) | |
download | tk-c8ab85ecfd0e2802bb98ab00e67b9acaa01a5577.zip tk-c8ab85ecfd0e2802bb98ab00e67b9acaa01a5577.tar.gz tk-c8ab85ecfd0e2802bb98ab00e67b9acaa01a5577.tar.bz2 |
[Patch #2999920]: Optimize Internal Virtual event string operations
[Bug #2987995]: Tk_getOpenFile returns garbage under described circumstances
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinDialog.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 041aea8..8ac95bf 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinDialog.c,v 1.73 2010/04/20 19:57:46 nijtmans Exp $ + * RCS: @(#) $Id: tkWinDialog.c,v 1.74 2010/05/17 08:44:00 nijtmans Exp $ * */ @@ -996,7 +996,17 @@ OFNHookProcW( } else if (uMsg == WM_NOTIFY) { OFNOTIFYW *notifyPtr = (OFNOTIFYW *) lParam; - if (notifyPtr->hdr.code == CDN_FILEOK) { + /* + * This is weird... or not. The CDN_FILEOK is NOT sent when the selection + * exceeds declared buffer size (the nMaxFile member of the OPENFILENAMEW + * struct passed to GetOpenFileNameW function). So, we have to rely on + * the most recent CDN_SELCHANGE then. Unfortunately this means, that + * gathering the selected filenames happens twice when they fit into the + * declared buffer. Luckily, it's not frequent operation so it should + * not incur any noticeable delay. See [tktoolkit-Bugs-2987995] + */ + if (notifyPtr->hdr.code == CDN_FILEOK || + notifyPtr->hdr.code == CDN_SELCHANGE) { int dirsize, selsize; WCHAR *buffer; int buffersize; @@ -1531,7 +1541,17 @@ OFNHookProcA( } else if (uMsg == WM_NOTIFY) { OFNOTIFY *notifyPtr = (OFNOTIFY *) lParam; - if (notifyPtr->hdr.code == CDN_FILEOK) { + /* + * This is weird... or not. The CDN_FILEOK is NOT sent when the selection + * exceeds declared buffer size (the nMaxFile member of the OPENFILENAMEW + * struct passed to GetOpenFileNameW function). So, we have to rely on + * the most recent CDN_SELCHANGE then. Unfortunately this means, that + * gathering the selected filenames happens twice when they fit into the + * declared buffer. Luckily, it's not frequent operation so it should + * not incur any noticeable delay. See [tktoolkit-Bugs-2987995] + */ + if (notifyPtr->hdr.code == CDN_FILEOK || + notifyPtr->hdr.code == CDN_SELCHANGE) { int dirsize, selsize; char *buffer; int buffersize; |