About Store Forum Documentation Contact
Donations:
140$/mo



Post Reply 
Gui controls array
Author Message
Ogniok Offline
Member

Post: #1
Gui controls array
Hi!

I have a problem in my game. I have array:

Code:
Button answerButton[2];

I'm creating all 3 buttons, but when i'm creating last i got error:

Code:
Unhandled exception at 0x006363e5 in cRPG.exe: 0xC0000005: Access violation reading location 0x00000000.

and green arrow shows me this line:

Code:
Button& create(Rect   &rect,Str text=CNULL){create(text).setRect(rect); return T;} // create and set rectangle

in Button.h.
But, when i have an array with 4 members:

Code:
Button answerButton[3];

and I'm creating only 3 everything works OK.

One more:

When i"m exiting my game i got this error:

Code:
Unhandled exception at 0x005d2b4d in cRPG.exe: 0xC0000005: Access violation writing location 0x0000000b.

And it can show code because this code in unavailable.
When I'm choose to show disassembly i got this:

Code:
EE::Str16::clear:
005D2B40  mov         eax,ecx
005D2B42  mov         ecx,dword ptr [eax]
005D2B44  xor         edx,edx
005D2B46  cmp         ecx,edx
005D2B48  je          EE::Str16::clear+11h (5D2B51h)
005D2B4A  push        esi  
005D2B4B  xor         esi,esi
005D2B4D  mov         word ptr [ecx],si               <----- ARROW HERE
005D2B50  pop         esi  
005D2B51  mov         dword ptr [eax+4],edx
005D2B54  ret              
005D2B55  int         3    
005D2B56  int         3    
005D2B57  int         3    
005D2B58  int         3    
005D2B59  int         3    
005D2B5A  int         3    
005D2B5B  int         3    
005D2B5C  int         3    
005D2B5D  int         3    
005D2B5E  int         3    
005D2B5F  int         3
(This post was last modified: 04-11-2010 01:16 PM by Ogniok.)
04-11-2010 01:15 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Gui controls array
Quote:I have array:
Button answerButton[2];
I'm creating all 3 buttons, but when i'm creating last i got error:
you have 2 so why you're creating 3?
Quote:But, when i have an array with 4 members:
Button answerButton[3];
I see 3 elements, not 4
04-11-2010 01:36 PM
Find all posts by this user Quote this message in a reply
Ogniok Offline
Member

Post: #3
RE: Gui controls array
My fault. I've forget that in C++ when you declaring array with 3 elements the indexes are 0, 1, 2.
(This post was last modified: 04-11-2010 03:07 PM by Ogniok.)
04-11-2010 01:43 PM
Find all posts by this user Quote this message in a reply
Post Reply