Results 1 to 7 of 7

Thread: app core dumps!!

  1. #1
    Join Date
    Feb 2006
    Posts
    42
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question app core dumps!!

    Hi I have written a small sample, but while its exiting it core dumps. I am using Qt 4.0.1 on Linux. Am I doing anything wrong here? Some body please help, I have attached the source files.

    Thanks in advance,
    Seem Rao
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: app core dumps!!

    Problem in your destructor...try first delete list widgets items and then delete list widget..
    If it doesnt help try comment delete items.
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: app core dumps!!

    Quote Originally Posted by Seema Rao
    delete layers;
    Object that the layers variable points to is owned by the Qt, and Qt will delete it:
    void QLayout::addItem ( QLayoutItem * item ) [pure virtual]
    Implemented in subclasses to add an item. How it is added is specific to each subclass.
    The ownership of item is transferred to the layout, and it's the layout's responsibility to delete it.
    Quote Originally Posted by Seema Rao
    delete [] layers_item;
    You didn't allocate that array using new[], so you can't delete it.

  4. #4
    Join Date
    Feb 2006
    Posts
    42
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: app core dumps!!

    Then Why is that even if I remove the delete statements sample still cores??

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: app core dumps!!

    Because you add each item to the list twice:
    Qt Code:
    1. ...
    2. layers_item[19]= new QListWidgetItem("Bookshops",layers); // <-- here
    3.  
    4. for (int i=0;i<=NumItems; i++){
    5. layers_item[i]->setCheckState(Qt::Unchecked);
    6. layers->addItem(layers_item[i]); // <-- and here
    7. }
    To copy to clipboard, switch view to plain text mode 
    Remove the second line from that for loop and everything should be OK.

  6. The following user says thank you to jacek for this useful post:

    Seema Rao (2nd May 2006)

  7. #6
    Join Date
    Feb 2006
    Posts
    42
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: app core dumps!!

    I have further problems inserting the same QListWidget to a grid Layout.
    My sample core dumps before showing the dialog. Can some body please help I have attached the source files. If I comment QListWidgetItem initialization part app does come up. Am I doing anything wrong here ?

    Thanks in advance,
    Seema
    Attached Files Attached Files

  8. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: app core dumps!!

    The item array has a size of 19 and you are inserting/indexing 20 items.

    Qt Code:
    1. NumItems = 20 // tour.h (36)
    2. for (int i=0; i < NumItems; i++) // tour.cpp (104)
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. openGL in Qtopia core
    By sar_van81 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 18th July 2008, 11:26
  2. Qt designer differences in qt-x11 and qtopia core
    By hungr in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 20th August 2007, 03:06
  3. Qtopia Core & OpenGL ES?
    By zelko in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 28th May 2007, 07:21
  4. OpenGL ES, Qt/11 - Qtopia Core?
    By zelko in forum Qt Programming
    Replies: 0
    Last Post: 3rd May 2007, 10:56
  5. Problem of Core Dropped!
    By Stephano in forum General Programming
    Replies: 1
    Last Post: 10th May 2006, 15:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.