×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    38

    Question exception caused by two dimension array* destruction...

    Hello,

    I've a Class with a two dimension array pointer. It works fine, but when I'm trying to exit from the application the emulator returns with an error "unknown software exception...".
    I know this caused by the wrong destruction... (when i'm commenting out my iTable variable it works fine...)
    How can i destruct a two dimension array pointer?
    Why isn't enough "delete iTable;"?



    my header file: ctable.h

    Code:
    #ifndef CTABLE_H
    #define CTABLE_H
    #include <e32base.h>
    class CTable
    {
    public:
    	static CTable* NewL(TInt aW, TInt aH);
    	static CTable* NewLC(TInt aW, TInt aH);
    
    	~CTable();
    private:
    	void ConstructL(TInt aW, TInt aH);
    	CTable();
    private:
    	TInt8 **iTable;
    };
    #endif // CTABLE_H

    my cpp file:
    Code:
    #include "ctable.h"
    #include "Cascade.pan"
    #include <e32math.h>
    
    CTable* CTable::NewL(TInt aW, TInt aH){
    	CTable* self = NewLC(aW,aH);
    	CleanupStack::Pop();
    	return self;
    }
    CTable* CTable::NewLC(TInt aW, TInt aH){
    	CTable* self = new (ELeave)CTable();
    	CleanupStack::PushL(self);
    	self->ConstructL(aW,aH);
    	return self;
    }
    void CTable::ConstructL(TInt aW, TInt aH)
    {
    iTable = (TInt8**) new (ELeave)(TInt8[aW]);
    int i;
    for(i=0;i<aW+1;i++){
    iTable[i]=new (ELeave)TInt8[aH];
    			}
    }
    CTable::CTable()
    {
    	//non-Leave construction
    }
    CTable::~CTable(){
    	if(iTable){
    		delete iTable;
    		iTable = NULL;
    	}
    }
    code updated.

  2. #2
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: exception caused by two dimension array* destruction...

    Try this:
    delete[] iTable;

    hope this works... Also if u still get the error, then try getting the panic codes. How to get panic codes- u ll find enough discussions on that on this forum...
    Amit Kankani
    Nokia Developer Champion

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    38

    Re: exception caused by two dimension array* destruction...

    Quote Originally Posted by amitkankani
    Try this:
    delete[] iTable;

    hope this works... Also if u still get the error, then try getting the panic codes. How to get panic codes- u ll find enough discussions on that on this forum...
    It's still not working...
    I've tryed to enable extended errors (Emulator S60 2.0) but nothing happened.

    but here is epocwind file:

    Error: Icon size (25,20) in listbox different from expected size (42,29).
    Error: Icon size (42,22) in listbox different from expected size (42,29).
    Error: Icon size (42,22) in listbox different from expected size (42,29).
    Error: Icon size (42,22) in listbox different from expected size (42,29).
    Error: Icon size (25,20) in listbox different from expected size (42,29).
    Error: Icon size (42,22) in listbox different from expected size (42,29).
    Error: Icon size (25,20) in listbox different from expected size (42,29).
    Error: Icon size (25,20) in listbox different from expected size (42,29).
    FeatMgr: InitializeLibL()
    SharedData: Assign to 0x10005a2b by CASCADESharedData: total allocated memory: 7864
    FeatMgr: TLS increase, clients now(1)
    SharedData: Assign to 0x100058ec by EikAppUiServerSharedData: total allocated memory: 7944
    SharedData: Get request with key "ColPal" by EikAppUiServerSharedData: Assign to 0x100056c6 by CASCADESharedData: total allocated memory: 8184
    SharedData: Get request with key "Layout" by CASCADEAknLayoutUtils: Rect width -4 > 0AknLayoutUtils: Calculated rect -4 different from one from LAF 104
    SharedData: Assign to 0x100058ec by CASCADESharedData: total allocated memory: 7944
    SharedData: Get request with key "ColPal" by CASCADESharedData: Assign to 0x100058ec by CASCADESharedData: total allocated memory: 7944
    SharedData: Get request with key "InputLang" by CASCADEError: Icon size (25,20) in listbox different from expected size (42,29).

  4. #4
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: exception caused by two dimension array* destruction...

    Quote Originally Posted by kienzan
    It's still not working...
    I've tryed to enable extended errors (Emulator S60 2.0) but nothing happened.

    but here is epocwind file:

    Error: Icon size (25,20) in listbox different from expected size (42,29).
    Error: Icon size (42,22) in listbox different from expected size (42,29).
    Error: Icon size (42,22) in listbox different from expected size (42,29).
    Error: Icon size (42,22) in listbox different from expected size (42,29).
    Error: Icon size (25,20) in listbox different from expected size (42,29).
    Error: Icon size (42,22) in listbox different from expected size (42,29).
    Error: Icon size (25,20) in listbox different from expected size (42,29).
    Error: Icon size (25,20) in listbox different from expected size (42,29).
    FeatMgr: InitializeLibL()
    SharedData: Assign to 0x10005a2b by CASCADESharedData: total allocated memory: 7864
    FeatMgr: TLS increase, clients now(1)
    SharedData: Assign to 0x100058ec by EikAppUiServerSharedData: total allocated memory: 7944
    SharedData: Get request with key "ColPal" by EikAppUiServerSharedData: Assign to 0x100056c6 by CASCADESharedData: total allocated memory: 8184
    SharedData: Get request with key "Layout" by CASCADEAknLayoutUtils: Rect width -4 > 0AknLayoutUtils: Calculated rect -4 different from one from LAF 104
    SharedData: Assign to 0x100058ec by CASCADESharedData: total allocated memory: 7944
    SharedData: Get request with key "ColPal" by CASCADESharedData: Assign to 0x100058ec by CASCADESharedData: total allocated memory: 7944
    SharedData: Get request with key "InputLang" by CASCADEError: Icon size (25,20) in listbox different from expected size (42,29).

    if u see the errors seem to be because of something else and not memory leaks or deletion in 2-dimensional array.... is there any listbox u trying to load and some icons, may be the icon sizes have to be 42x29 only !!!

    debug and get to the line after which u get the crash... that will be more helpful...
    Amit Kankani
    Nokia Developer Champion

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    38

    Re: exception caused by two dimension array* destruction...

    Quote Originally Posted by amitkankani
    if u see the errors seem to be because of something else and not memory leaks or deletion in 2-dimensional array.... is there any listbox u trying to load and some icons, may be the icon sizes have to be 42x29 only !!!

    debug and get to the line after which u get the crash... that will be more helpful...
    i have no listbox or icons in my application...

  6. #6
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: exception caused by two dimension array* destruction...

    this is your code:

    #include "ctable.h"
    #include "Cascade.pan"
    #include <e32math.h>

    CTable* CTable::NewL(TInt aW, TInt aH){
    CTable* self = NewLC(aW,aH);
    CleanupStack::Pop();
    return self;
    }
    CTable* CTable::NewLC(TInt aW, TInt aH){
    CTable* self = new (ELeave)CTable();
    CleanupStack::PushL(self);
    self->ConstructL(aW,aH);
    return self;
    }
    void CTable::ConstructL(TInt aW, TInt aH)
    {
    iTable = (TInt8**) new (ELeave)(TInt8[aW]);
    int i;
    //for(i=0;i<aW+1;i++){
    for(i=0;i<aW;i++){
    iTable[i]=new (ELeave)TInt8[aH];
    }
    }
    CTable::CTable()
    {
    //non-Leave construction
    }
    CTable::~CTable(){
    if(iTable){
    //delete iTable;
    delete[] iTable;
    iTable = NULL;
    }
    }




    Now first change as per the red lines highlighted above.
    Also make your class CTable derive from CBase.
    Hope it helps and let me know
    Amit Kankani
    Nokia Developer Champion

  7. #7
    Registered User
    Join Date
    Mar 2006
    Posts
    38

    Re: exception caused by two dimension array* destruction...

    Quote Originally Posted by amitkankani
    this is your code:

    Now first change as per the red lines highlighted above.
    Also make your class CTable derive from CBase.
    Hope it helps and let me know

    I've changed the code, but still not working...

  8. #8
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: exception caused by two dimension array* destruction...

    well then you got to debug and tell which line gives u the error.
    Also make sure u derive ur class CTable from CBase ...
    Amit Kankani
    Nokia Developer Champion

  9. #9
    Registered User
    Join Date
    Mar 2006
    Posts
    38

    Re: exception caused by two dimension array* destruction...

    Quote Originally Posted by amitkankani
    well then you got to debug and tell which line gives u the error.
    Also make sure u derive ur class CTable from CBase ...

    how can i debug? i have no any IDE... i'm using only command line tools.

    class CTable : public CBase
    {
    public:
    .
    .
    .

  10. #10
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: exception caused by two dimension array* destruction...

    Quote Originally Posted by kienzan
    how can i debug? i have no any IDE... i'm using only command line tools.

    class CTable : public CBase
    {
    public:
    .
    .
    .
    well then use carbide (free ide) or some ide.... it will help you debug better.
    If u cant use an ide, then use logging (RFileLogger) and see which part of the code is crashing. How to use RFileLogger ? there are enough discussions and examples... hunt them
    Amit Kankani
    Nokia Developer Champion

  11. #11
    Registered User
    Join Date
    Mar 2006
    Posts
    38

    Re: exception caused by two dimension array* destruction...

    HERE IS THE SOLUTION:

    The problem caused by a bad declaration and a bad destruction...
    One of my friends helpd me (he is a cpp expert)... Thank you

    And thank you too, amitkankani!

    Code:
    void CTable::ConstructL(TInt aW, TInt aH)
    {
    ...
    /*iTable = (TInt8**) new (ELeave)(TInt8[aW]);*/
    iTable =new (ELeave)TInt8*[aW];
    int i;
    for(i=0;i<aW;i++){
    	iTable[i]=new (ELeave)TInt8[aH];
    }
    ...
    }
    
    
    CTable::~CTable(){
    		int i;
    		for(i=0;i<iWidth;i++){
    //			delete iTable[i];
    			delete[] iTable[i];
    		}
    		delete[] iTable;
    ...
    }
    code updated...
    Last edited by kienzan; 2007-03-15 at 17:07.

Similar Threads

  1. VS.Net 2003 Carbide 2.01 and epoc32.exe
    By ValentinK in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2007-01-12, 12:31
  2. First-chance exception in emulator S60 3rd ed.
    By darioses in forum Symbian Tools & SDKs
    Replies: 6
    Last Post: 2006-04-25, 18:24
  3. Catching an exception
    By btnokdev in forum Mobile Java General
    Replies: 2
    Last Post: 2003-10-11, 14:45
  4. J2ME cannot report exception line number???
    By dying in forum Mobile Java General
    Replies: 2
    Last Post: 2003-09-02, 09:08
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •