From a89d708a2cf6028358880087502c487c4087eabf Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 11 Aug 2010 01:27:33 -0700 Subject: Catch bad save dialog sizes on Win32. Fixes bug #285267. Fixed bugs: - https://launchpad.net/bugs/285267 (bzr r9698) --- src/ui/dialog/filedialogimpl-win32.cpp | 38 ++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'src/ui/dialog/filedialogimpl-win32.cpp') diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 0f3672f25..11624af70 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -59,7 +59,11 @@ namespace UI namespace Dialog { -const int PreviewWidening = 150; +const int PREVIEW_WIDENING = 150; +const int WINDOW_WIDTH_MINIMUM = 32; +const int WINDOW_WIDTH_FALLBACK = 450; +const int WINDOW_HEIGHT_MINIMUM = 32; +const int WINDOW_HEIGHT_FALLBACK = 360; const char PreviewWindowClassName[] = "PreviewWnd"; const unsigned long MaxPreviewFileSize = 10240; // kB @@ -91,6 +95,21 @@ ustring utf16_to_ustring(const wchar_t *utf16string, int utf16length = -1) return result; } +namespace { + +int sanitizeWindowSizeParam( int size, int delta, int minimum, int fallback ) +{ + int result = size; + if ( size < lower ) { + g_warning( "Window size %d is less than cutoff.", size ); + result = fallback - delta; + } + result += delta; + return result; +} + +} // namespace + /*######################################################################### ### F I L E D I A L O G B A S E C L A S S #########################################################################*/ @@ -443,9 +462,9 @@ UINT_PTR CALLBACK FileOpenDialogImplWin32::GetOpenFileName_hookproc( RECT rcRect; GetWindowRect(hParentWnd, &rcRect); MoveWindow(hParentWnd, rcRect.left, rcRect.top, - rcRect.right - rcRect.left + PreviewWidening, - rcRect.bottom - rcRect.top, - FALSE); + rcRect.right - rcRect.left + PREVIEW_WIDENING, + rcRect.bottom - rcRect.top, + FALSE); // Set the pointer to the object OPENFILENAMEW *ofn = (OPENFILENAMEW*)lParam; @@ -1686,12 +1705,19 @@ UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc( GetWindowRect(GetDlgItem(hParentWnd, stc2), &rST); GetWindowRect(hdlg, &rROOT); int ydelta = rCB1.top - rEDT1.top; + if ( ydelta < 0 ) { + g_warning("Negative dialog ydelta"); + ydelta = 0; + } // Make the window a bit longer + // Note: we have a width delta of 1 because there is a suspicion that MoveWindow() to the same size causes zero-width results. RECT rcRect; GetWindowRect(hParentWnd, &rcRect); - MoveWindow(hParentWnd, rcRect.left, rcRect.top, rcRect.right - rcRect.left, - rcRect.bottom - rcRect.top + ydelta, FALSE); + MoveWindow(hParentWnd, rcRect.left, rcRect.top, + sanitizeWindowSizeParam( rcRect.right - rcRect.left, 1, WINDOW_WIDTH_MINIMUM, WINDOW_WIDTH_FALLBACK ), + sanitizeWindowSizeParam( rcRect.bottom - rcRect.top, ydelta, WINDOW_HEIGHT_MINIMUM, WINDOW_HEIGHT_FALLBACK ), + FALSE); // It is not necessary to delete stock objects by calling DeleteObject HGDIOBJ dlgFont = GetStockObject(DEFAULT_GUI_FONT); -- cgit v1.2.3 From 8168dfaf605e602e69bd004265c79c94128376ea Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 11 Aug 2010 20:32:13 -0700 Subject: Correct application of older Win32 patch. Fixes bug #616589. Fixed bugs: - https://launchpad.net/bugs/616589 (bzr r9702) --- src/ui/dialog/filedialogimpl-win32.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/dialog/filedialogimpl-win32.cpp') diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 11624af70..c78ce9509 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -100,7 +100,7 @@ namespace { int sanitizeWindowSizeParam( int size, int delta, int minimum, int fallback ) { int result = size; - if ( size < lower ) { + if ( size < minimum ) { g_warning( "Window size %d is less than cutoff.", size ); result = fallback - delta; } -- cgit v1.2.3 From 144819c918dc761641c3cb5a490205fb73194ee3 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 17 Nov 2010 13:12:56 +1100 Subject: Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in all 1074 Vim modelines. The reason for this is that (a) setting the encoding isn't nice, and (b) Vim 7.3 (with modeline enabled) disallows it and pops up an error whenever you open any file with it ("invalid modeline"). Also corrected five deviant modestrings: * src/ui/widget/dock.cpp and src/ui/widget/dock.h: missing colon at the end * src/ui/dialog/tile.cpp: removed gratuitous second colon at the end * src/helper/units-test.h: removed gratuitous space before a colon * share/extensions/export_gimp_palette.py: missing textwidth=99 That's my geekiest commit yet. (bzr r9900) --- src/ui/dialog/filedialogimpl-win32.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/dialog/filedialogimpl-win32.cpp') diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index c78ce9509..e2bf47db9 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -1786,4 +1786,4 @@ UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc( fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3