|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Jean-Yves Tremblay
|
Jan 15, 2007 - 12:24 PM
|
Hi !
I get a memory leak when I try to load a bitmap file with an invalid path. I think it’s because of no CException (CFileException) are caught, and then, deleted
I supposed that’s the same case for CExtBitmap::SaveBMP_File
David
|
|
Courtney Smith
|
Mar 9, 2007 - 11:12 AM
|
I’m getting weird behaviors from FromBitmap(hbitmap). Is there similar code in this function?
|
|
Technical Support
|
Mar 9, 2007 - 11:45 AM
|
In v.2.64 we fixed a memory leak in the code that loads bitmaps when the CExtBitmap::LoadBMP_File() method is invoked with an invalid file path. You can either switch to version 2.64 or simply tell us and we will send you the latest ../Prof-UIS/Include/ExtCmdIcon.h and ../Prof-UIS/Src/ExtCmdIcon.cpp files from v.2.64.
|
|
Jean-Yves Tremblay
|
Jan 15, 2007 - 2:03 PM
|
Here’s my output :
[...]
* * * TERMINATING DYNAMIC LIBRARY: ProfUIS version 2.62 * * *
Detected memory leaks!
Dumping objects ->
f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {30675} normal block at 0x0251D1E8, 33 bytes long.
Data: < >x > EC 97 3E 78 10 00 00 00 10 00 00 00 01 00 00 00
{30674} client block at 0x025649A0, subtype c0, 24 bytes long.
a CFileException object at $025649A0, 24 bytes long
Object dump complete.
The thread ’__tmainCRTStartup’ (0x8d0) has exited with code 0 (0x0).
The thread ’Win32 Thread’ (0x8f0) has exited with code 0 (0x0).
The program ’[3472] TestProfuis.exe: Native’ has exited with code 0 (0x0).
[...]
And the code I use :
bData.extBmp.LoadBMP_File(strTemp.c_str(), false, false);
|
|
Technical Support
|
Jan 16, 2007 - 12:27 PM
|
Please update the source code for the CExtBitmap::LoadBMP_Buffer() , CExtBitmap::LoadBMP_File() and CExtBitmap::SaveBMP_File() methods in the ../Prof-UIS/Src/ExtCmdIcon.cpp file: bool CExtBitmap::LoadBMP_Buffer(
LPCVOID pBuffer,
UINT nByteCount,
bool bMake32, //= false
bool bEnableThrowException, // = false
bool bResourceFormat // = false
)
{
ASSERT( pBuffer != NULL );
try
{
Empty();
CMemFile _file(
(LPBYTE)pBuffer,
nByteCount
);
if( ! LoadBMP_File(
_file,
bMake32,
bEnableThrowException,
bResourceFormat
)
)
return false;
return true;
}
catch( CException * pException )
{
if( bEnableThrowException )
throw;
pException->Delete();
}
catch( ... )
{
if( bEnableThrowException )
throw;
}
return false;
}
bool CExtBitmap::LoadBMP_File(
__EXT_MFC_SAFE_LPCTSTR strFilePath,
bool bMake32, //= false
bool bEnableThrowException, // = false
bool bResourceFormat // = false
)
{
try
{
CFile _file(
strFilePath,
CFile::modeRead
| CFile::typeBinary
);
return
LoadBMP_File(
_file,
bMake32,
bEnableThrowException,
bResourceFormat
);
}
catch( CException * pException )
{
if( bEnableThrowException )
throw;
pException->Delete();
}
catch( ... )
{
if( bEnableThrowException )
throw;
}
return false;
}
bool CExtBitmap::SaveBMP_File(
__EXT_MFC_SAFE_LPCTSTR strFilePath,
bool bMake32, //= false
bool bEnableThrowException, // = false
bool bUseIndexedRLE // = true
)
{
try
{
CFile _file(
strFilePath,
CFile::modeCreate
| CFile::modeWrite
| CFile::typeBinary
);
return
SaveBMP_File(
_file,
bMake32,
bEnableThrowException,
bUseIndexedRLE
);
}
catch( CException * pException )
{
if( bEnableThrowException )
throw;
pException->Delete();
}
catch( ... )
{
if( bEnableThrowException )
throw;
}
return false;
}
|
|
Technical Support
|
Jan 15, 2007 - 1:13 PM
|
Could you let us look at the content of the Visual Studio’s Output window displaying the information about the memory leak?
|
|