|
Question : A serious bug in the MFC exception handling on Windows CE
|
|
I found that the following code causes memory leak on Windows CE if the file does not exist.
TRY { CFile file(lpszFilename, CFile::modeRead); } CATCH(CFileException, pEx) { } END_CATCH
Further investigation shows that the destructor is not called. Try the following code on Windows CE and you won't see the "Destructor" message box and the CString is not released.
class CLeak { public: CLeak() { ::AfxMessageBox(_T("Constructor")); }
~CLeak() { ::AfxMessageBox(_T("Destructor")); } };
TRY { CString str(_T('a'), 10240);
CLeak leak;
AfxThrowFileException(2, 2, _T("c:\\a.a")); } CATCH(CFileException, pEx) { } END_CATCH
It is due to the MFC exception handling for Windows CE using setjmp and longjmp, which do not support C++ object semantics. Unfortunately, the C++ exception handling is not supported for Window CE.
I think the only perfect solution is to make the C++ exception handling supported for Windows CE.
|
|
Answer : A serious bug in the MFC exception handling on Windows CE
|
|
PAQed - no points refunded (of 0)
Computer101 E-E Admin
|
|
|
|