Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi there,

I am having trouble in closing a output file. I have opened my output file as the following code and initialized :

pMe->m_pWriteOutFile =NULL;
......

//create an FILEMGR interface
ISHELL_CreateInstance( pMe->a.m_pIShell,AEECLSID_FILEMGR,(void**)&pMe->m_pIFileMgr);

......

//opening the result output file
if(!pMe->m_pWriteOutFile)
pMe->m_pWriteOutFile = IFILEMGR_OpenFile(pMe->m_pIFileMgr,OUTPUT_FILE_NAME, _OFM_CREATE);

Then after I have done with it I closed my file as the following code:

static void Destroy_textviewerApp(textViewer* pMe)
{
//close the output text file
IFILE_Release(pMe->m_pWriteOutFile);

if (pMe->m_pIFileMgr!= NULL )
{
IFILEMGR_Release(pMe->m_pIFileMgr); // release the interface
pMe->m_pIFileMgr = NULL; // set to NULL so no problems trying to free later
}

}

Now, after I execute the program, there is an error showing for "access violation" and the cursor is pointing to "IFILE_Release(pMe->m_pWriteOutFile);".

Can anybody tell me why is this happening and how can I debug that? :(

Thanks.

Is it possible that you released the IFileMgr twice?

Is it possible that you released the IFileMgr twice?

mohlendo wrote:Is it possible that you released the IFileMgr twice?
Hi,
Actually not.. I have rechecked it. ifilemngr is released once and the ifile is released once to close the file. I also tried getting rid of "IFILE_Relesae()" code and in the emulator screen; i had a message saying "Modulator failed to free all memory". So I did put it back:).
But still I am getting the same error message. Plesae help .
Thanks.

mohlendo wrote:Is it possible that you released the IFileMgr twice?
Hi,
Actually not.. I have rechecked it. ifilemngr is released once and the ifile is released once to close the file. I also tried getting rid of "IFILE_Relesae()" code and in the emulator screen; i had a message saying "Modulator failed to free all memory". So I did put it back:).
But still I am getting the same error message. Plesae help .
Thanks.

mohlendo wrote:Is it possible that you released the IFileMgr twice?
Hello Max,
I found an intersting thing.... I was running the program in BREW 2.0.1 emulator and getting that "Access violation" error after closing the IFILE interface. Then I chnaged my project in BREW3.1.4 and executed it. Now it is working fine. :D
I wonder , probably this is a BREW thing...not my coding problem, is it?
:rolleyes: ;)

mohlendo wrote:Is it possible that you released the IFileMgr twice?
Hello Max,
I found an intersting thing.... I was running the program in BREW 2.0.1 emulator and getting that "Access violation" error after closing the IFILE interface. Then I chnaged my project in BREW3.1.4 and executed it. Now it is working fine. :D
I wonder , probably this is a BREW thing...not my coding problem, is it?
:rolleyes: ;)

Were you compiling in BREW 3.1.4 and then running in the 2.0 Emulator? That;s kind of a bad idea. ;)

Were you compiling in BREW 3.1.4 and then running in the 2.0 Emulator? That;s kind of a bad idea. ;)