From: Robert R. <rob...@gm...> - 2014-01-14 13:05:36
|
I apologize for not copying the list on this message. Please review the patch below and let me know if you need another maintainer <grin>. I've been developing Windows apps since before there was a Windows kernel <my age is showing>. Best regards, Robert ---------- Forwarded message ---------- From: Robert Randall <rob...@gm...> Date: Mon, Jan 13, 2014 at 7:04 PM Subject: Re: [Iometer-devel] a couple fixes, are the maintainers interested? To: "lefferts, john" <joh...@em...> Patch is below. There are still a few issues I should clean up with regard to cleanly including the MFC headers. I need to investigate one more internal bug report; loading .icf file with multiple managers results in the first manager being created other are not created. Index: src/GalileoApp.cpp =================================================================== --- src/GalileoApp.cpp (revision 141) +++ src/GalileoApp.cpp (working copy) @@ -122,6 +122,14 @@ delete login_port; } +void CGalileoApp::CloseAllDocuments(BOOL bEndSession) +{ + if (bEndSession) + { + m_wndStatusBar.DestroyWindow(); + m_wndToolBar.DestroyWindow(); + } +} ///////////////////////////////////////////////////////////////////////////// // The one and only CGalileoApp object @@ -311,6 +319,8 @@ /////////////////////////////////////////////////////////////////////////////// int CGalileoApp::ExitInstance() { + manager_list.RemoveAllManagers(); + delete[]m_pVersionString; delete[]m_pVersionStringWithDebug; Index: src/GalileoApp.h =================================================================== --- src/GalileoApp.h (revision 141) +++ src/GalileoApp.h (working copy) @@ -130,6 +130,7 @@ virtual int ExitInstance(); virtual BOOL OnIdle(LONG lCount); virtual CDocument *OpenDocumentFile(LPCTSTR lpszFileName); + virtual void CloseAllDocuments(BOOL bEndSession); //}}AFX_VIRTUAL // Implementation Index: src/GalileoView.cpp =================================================================== --- src/GalileoView.cpp (revision 141) +++ src/GalileoView.cpp (working copy) @@ -1180,6 +1180,7 @@ void CGalileoView::OnFileOpen() { BOOL flags[NumICFFlags]; + CICFOpenDialog file_open_box; // open config file dialog box // Show the custom file open dialog. if (file_open_box.DoModal() == IDCANCEL) @@ -1202,6 +1203,7 @@ void CGalileoView::OnFileSave() { BOOL flags[NumICFFlags]; + CICFSaveDialog file_save_box; // save config file dialog box // Show the custom file save dialog. if (file_save_box.DoModal() == IDCANCEL) Index: src/GalileoView.h =================================================================== --- src/GalileoView.h (revision 141) +++ src/GalileoView.h (working copy) @@ -182,8 +182,6 @@ CPropertySheet *m_pPropSheet; protected: - CICFOpenDialog file_open_box; // open config file dialog box - CICFSaveDialog file_save_box; // save config file dialog box // tracks whether parent frame has already been sized. BOOL m_bSizedBefore; Index: src/ICFOpenDialog.cpp =================================================================== --- src/ICFOpenDialog.cpp (revision 141) +++ src/ICFOpenDialog.cpp (working copy) @@ -87,9 +87,10 @@ ///////////////////////////////////////////////////////////////////////////// // CICFOpenDialog dialog - CICFOpenDialog::CICFOpenDialog() -: CFileDialog(TRUE, "icf", "", NULL, - "Iometer Configuration Files (*.icf)|*.icf|" "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||") + CICFOpenDialog::CICFOpenDialog() +: CFileDialog(TRUE, "icf", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + "Iometer Configuration Files (*.icf)|*.icf|" "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||", + NULL, 0UL, FALSE) { CString title; char *buf; @@ -104,9 +105,6 @@ m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FILEOPEN_OPTS); - // This is key to getting the templates working properly and secondary opens to work at all?! - m_bVistaStyle = FALSE; - //{{AFX_DATA_INIT(CICFOpenDialog) isCkTestSetup = TRUE; isCkResultsDisplay = TRUE; Index: src/ICFSaveDialog.cpp =================================================================== --- src/ICFSaveDialog.cpp (revision 141) +++ src/ICFSaveDialog.cpp (working copy) @@ -88,8 +88,9 @@ ///////////////////////////////////////////////////////////////////////////// // CICFSaveDialog dialog CICFSaveDialog::CICFSaveDialog() -: CFileDialog(FALSE, "icf", "iometer", NULL, - "Iometer Configuration Files (*.icf)|*.icf|" "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||") +: CFileDialog(FALSE, "icf", "iometer", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + "Iometer Configuration Files (*.icf)|*.icf|" "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||", + NULL, 0UL, FALSE) { CString title; char *buf; @@ -104,9 +105,6 @@ m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FILESAVE_OPTS); - // This is key to getting the templates working properly and secondary opens to work at all?! - m_bVistaStyle = FALSE; - //{{AFX_DATA_INIT(CICFSaveDialog) isCkTestSetup = TRUE; isCkResultsDisplay = TRUE; Index: src/IOCommon.h =================================================================== --- src/IOCommon.h (revision 141) +++ src/IOCommon.h (working copy) @@ -204,17 +204,21 @@ #if defined(IOMTR_OSFAMILY_WINDOWS) // Only first, because it is needed here! //#define VC_EXTRALEAN //#pragma warning (disable: 4242) +#include "StdAfx.h" +//#define WIN32_LEAN_AND_MEAN 1 +//#include <Windows.h> +//#include <windef.h> #include <process.h> #include <io.h> #include <direct.h> - #include <afxwin.h> - #include <afxext.h> - #include <afxcmn.h> - #include <winioctl.h> +// #include <afxwin.h> +// #include <afxext.h> +// #include <afxcmn.h> #include <iomanip> #include <winperf.h> #include <winreg.h> - #include <afxmt.h> + #include <winioctl.h> +// #include <afxmt.h> #include <malloc.h> #endif // ---------------------------------------------------------------------------- @@ -868,7 +872,7 @@ struct IOCQ { CQ_Element *element_list; struct aiocb64 **aiocb_list; -#ifdef IOMTR_SETTING_LINUX_LIBAIO +#ifdef IOMTR_SETTING_LINUX_LIBAIO struct iocb **iocb_list; io_context_t io_ctx_id; struct io_event *events; Index: src/IOPort.cpp =================================================================== --- src/IOPort.cpp (revision 141) +++ src/IOPort.cpp (working copy) @@ -81,6 +81,7 @@ /* ######################################################################### */ #if defined(IOMTR_OS_WIN32) || defined(IOMTR_OS_WIN64) +#include "StdAfx.h" #include "GalileoApp.h" #endif #include "IOPort.h" Index: src/IOPortTCP.cpp =================================================================== --- src/IOPortTCP.cpp (revision 141) +++ src/IOPortTCP.cpp (working copy) @@ -89,7 +89,7 @@ /* ######################################################################### */ #if defined(IOMTR_OS_WIN32) || defined(IOMTR_OS_WIN64) -#include <afx.h> +#include "StdAfx.h" #endif #include "IOPortTCP.h" Index: src/IOTarget.cpp =================================================================== --- src/IOTarget.cpp (revision 141) +++ src/IOTarget.cpp (working copy) @@ -109,6 +109,9 @@ #if defined(IOMTR_OSFAMILY_UNIX) && defined(WORKAROUND_MOD_BUG) return ((DWORDLONG)fmodl(spec.random = A * spec.random + B, limit)); #else +#ifdef _DEBUG + assert(limit > 0); +#endif return (spec.random = A * spec.random + B) % limit; #endif } Index: src/IOTargetDisk.cpp =================================================================== --- src/IOTargetDisk.cpp (revision 141) +++ src/IOTargetDisk.cpp (working copy) @@ -1329,10 +1329,14 @@ // Loop through the I/O queue looking for idle slots. for (i = 0; i < PREPARE_QDEPTH; i++) { // Check to see if we've reached the end of the disk - if (spec.disk_info.maximum_size && + // Windows debuggers lie when decoding spec.disk_info pushing + // values into local vars + int dd_sector_size = spec.disk_info.sector_size; + ULONGLONG dd_maximum_size = spec.disk_info.maximum_size; + ULONGLONG dd_starting_sector = spec.disk_info.starting_sector; + if (dd_maximum_size && ((*prepare_offset + bytes) > - ((spec.disk_info.starting_sector + - (DWORDLONG) spec.disk_info.maximum_size) * spec.disk_info.sector_size))) { + ((dd_starting_sector + dd_maximum_size) * dd_sector_size))) { // A maximum disk size was specified by the user, and the next write // would go past the specified maximum size. #ifdef _DEBUG Index: src/IOTime.cpp =================================================================== --- src/IOTime.cpp (revision 141) +++ src/IOTime.cpp (working copy) @@ -92,6 +92,9 @@ /* ## ## */ /* ######################################################################### */ +#if defined(IOMTR_OS_WIN32) || defined(IOMTR_OS_WIN64) +#include "StdAfx.h" +#endif #include "IOCommon.h" #if defined(IOMTR_OS_LINUX) Index: src/StdAfx.h =================================================================== --- src/StdAfx.h (revision 141) +++ src/StdAfx.h (working copy) @@ -58,11 +58,61 @@ /* ## ## */ /* ######################################################################### */ -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +//#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#include <afxwin.h> // MFC core and standard components +//#include <afxwin.h> // MFC core and standard components //#include <afxext.h> // MFC extensions +//#ifndef _AFX_NO_AFXCMN_SUPPORT +//#include <afxcmn.h> // MFC support for Windows Common Controls +//#endif // _AFX_NO_AFXCMN_SUPPORT +//#include <afxtempl.h> + +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#endif + +#include "targetver.h" + +//#define _AFX_NO_OLE_SUPPORT 1 +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit + +// turns off MFC's hiding of some common and often safely ignored warning messages +#define _AFX_ALL_WARNINGS + +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions + +#ifndef _AFX_NO_OLE_SUPPORT +#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls +#endif #ifndef _AFX_NO_AFXCMN_SUPPORT -#include <afxcmn.h> // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT -//#include <afxtempl.h> +#include <afxcmn.h> // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include <afxcontrolbars.h> // MFC support for ribbons and control bars + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + On Mon, Jan 13, 2014 at 3:10 PM, lefferts, john <joh...@em...>wrote: > I appreciate you valuable efforts. > > I think the developers would be better able to evaluate the technical > merit of your changes if you take the extra time to construct a patch. > > Even a simple diff stream would be useful for a review. > > > > I have co-workers who complain about “crashes” when shutting-down a > performance run—I wonder if you have addressed their issues. > > > > The SLN file under src/msvc9 says it was created with VS2008 (version 10) > and I am using that. > > It has the same constructor. > > > > The developers have a comment that seems to indicate open-exclusive issues > on reopen without prompt destruction of heap objects: > > > > // This is key to getting the templates working properly and > secondary opens to work at all?! > > m_bVistaStyle = FALSE; > > > > I am interested in seeing your changes. > > > > > > *From:* Robert Randall [mailto:rob...@gm...] > *Sent:* Monday, January 13, 2014 3:44 PM > *To:* iom...@li... > *Subject:* Re: [Iometer-devel] a couple fixes, are the maintainers > interested? > > > > I also fixed a problem when running in batch mode. The destruction > sequence of Windows causes an exception. The cheap fix is implementing a > function in CGalileoApp. > > > > Regards, > > Robert > > > > On Mon, Jan 13, 2014 at 2:17 PM, Robert Randall < > rob...@gm...> wrote: > > > > Hello, > > > > I've spent some time fixing a few simple problems with the latest version > of MFC using the current trunk. The CFileDialog constructors were being > called incorrectly causing reference counting problems with COM. The COM > classes should not have been initialized in the first place. Because the > code was messing with m_bVistaStyle directly (not a good idea) it was > causing the COM classes to be created but not destroyed which results in > exceptions when running in the debugger and leaks resource when running a > release build. > > > > I made these changes using VS 2012 and I don't have the tools to know if > the CFileDialog constructor is compatible with previous releases of MFC. > I'm not sure how old a tool set is supported by the project when compiling > on Windows. Which versions of the compiler and MFC are supported? > > > > The constructor in the version of MFC I'm using is: > > > > CFileDialog( > > BOOL bOpenFileDialog, > > LPCTSTR lpszDefExt = NULL, > > LPCTSTR lpszFileName = NULL, > > DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, > > LPCTSTR lpszFilter = NULL, > > CWnd* pParentWnd = NULL, > > DWORD dwSize = 0, > > BOOL bVistaStyle = TRUE > > ); > > > > I found one other minor problem. When using a file on disk for testing > the minimum Maximum Disk Size in sectors MUST be 128 or larger because of > the code that IOTargetDisk::Prepare assumes that at least 64Kb will be > written to the file. A smaller value results in a divide by zero > exception. I'm not sure if Prepare should be fixed to handle smaller files > or a minimum size should be enforced by the GUI. Happy to make the fix > either way. > > > > > > Let me know if you would like a patch for these changes. > > > > Best regards, > > Robert > > > > -- > Robert Randall | rob...@gm... > > > > > > -- > Robert Randall | rob...@gm... > -- Robert Randall | rob...@gm... -- Robert Randall | rob...@gm... |