PDA

View Full Version : Program Error


AliNaqvi
07-15-2002, 01:49 AM
Hi,
I'm new to Brew but before get used to develop using MIDP.

I'm getting very strange behavior of BREW SDK 1.1 and the behavior is like this.
I've defined a structure with only two variables (except the mandatory one of type AEEApplet) of type IImage. and in MyApp_initAppData i'm initializing those variables to NULL and every thing works fine. But whenever i define the third variable of type IImage in that structure and try to initialize that variable to initAppData function to NULL i got the following error message. Surprisingly error message for windows versions are different. in chinese version i got the following message:

---------------------------
LGE CX-300L.qsc - BREW Emulator: BREW_Emulator.exe - 应用程序错误
---------------------------
"0x00000000" 指令引用的 "0x00000000" 内存。该内存不能为 "read"。


要终止程序,请单击“确定”。
要调试程序,请单击“取消”。
---------------------------
确定 取消
---------------------------

stating that statment referenced at memory address 0x00000000 can not read memory at address 0x00000000.

But in english version (windows 2000 for both versions)
i got the following error message.

BREW_Emulator.e.exe has generated errors and will be closed by Windows. You will need to restart the program.

An error log is being created.
---------
OK
---------


But i can't find any log file generated.

Can anybody tell me what is wrong above.

Note:
I've tested the program with setting the device Heap option to "Use windows heap" but still the same problem.

Any help or suggestion will be appreciated as this thing is really driving me crazy.

I've seen the example provided with the SDK that the structure they have defined are very big and those examples works very fine.

Regards,
Ali Naqvi

arunbangari
07-15-2002, 07:36 AM
Hi,
Can you paste your piece of code for AEEClsCreateInstance and Intialization function in your next post?If possible let me have a look at your app data structure too.

Regards
Bangs

AliNaqvi
07-15-2002, 06:55 PM
Hi Bangs,
Thanks for reply. Below are code fragments.


typedef struct _CImage
{
AEEApplet a;
IImage *pImgBack;
IImage *pImgMenu;
//IImage *pImgCaret;
}CImage;


int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)
{
*ppObj = NULL;

if(ClsId == AEECLSID_MYAPPID){
if(AEEApplet_New(sizeof(AEEApplet), ClsId, pIShell,po,(IApplet**)ppObj,
(AEEHANDLER)MyApp_HandleEvent,
(PFNFREEAPPDATA)MyApp_FreeAppData) == TRUE)
{
if (MyApp_InitAppData((IApplet*)*ppObj) == TRUE)
return (AEE_SUCCESS);
}
}
return (EFAILED);
}

static boolean MyApp_InitAppData(IApplet* pMe)
{
CImage* pi = (CImage*)pMe;
pi->pImgBack = NULL;
pi->pImgMenu = NULL;
//pi->pImgCaret = NULL;
return TRUE;
}

Actually i have tried the structure by declaring the array of images but again run time exception is being thrown.

I've commented the third variable which causes exception if uncommented.

Thanks for your kind help.

Regards,
Ali Naqvi

arunbangari
07-15-2002, 09:42 PM
Hi ali,
I found out the problem..:D

The problem lies in this piece of code...

if(AEEApplet_New(sizeof(AEEApplet), ClsId, pIShell,po,(IApplet**)ppObj,
(AEEHANDLER)MyApp_HandleEvent,
(PFNFREEAPPDATA)MyApp_FreeAppData) == TRUE)

It should be

if(AEEApplet_New(sizeof(CImage), ClsId, pIShell,po,(IApplet**)ppObj,
(AEEHANDLER)MyApp_HandleEvent,
(PFNFREEAPPDATA)MyApp_FreeAppData) == TRUE)

When you use size of(AEEAplet), the memory allocated will be only for AEEAplet, instead u need to allocate for your application data structure which is nothing but CImage in your case. Note that you have included AEEAplet in your app data structure. I hope it should work now. If you have any problem lemme know.

Regards
Arun Bangari

AliNaqvi
07-15-2002, 11:34 PM
Thanks alot Arun

It really solved my problem. You are right actually i should pass the size of my application data structure.

Thanks again for your nice help.

Regards,

Ali Naqvi

arunbangari
07-15-2002, 11:40 PM
You are welcome.Good luck

Regards
Arun Bangari