Results 1 to 4 of 4

Thread: QT crashed during running

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QT crashed during running

    Quote Originally Posted by d_stranz View Post
    What do you think happens when your code hits line 45? All you have done in line 41 is to allocate a -pointer-. You haven't given the QList that pointer points to any size. So if you have a zero-sized QList, and you try to assign something to the i-th member of it, what happens?
    Thanks for helping, I've tried to allocate the size of
    Qt Code:
    1. listVector
    To copy to clipboard, switch view to plain text mode 
    using the value from
    Qt Code:
    1. numberItems
    To copy to clipboard, switch view to plain text mode 
    at line 41, then initiate each nested list with pointers(line 44) that has many items(say 1000), however, the program still crashed.....

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,349
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: QT crashed during running

    If you make listVector a QList (not QList *) member variable of your SNP_Plotter class, then you can use QList::push_back() to add new elements onto the the end of the list.

    Your logical error is in thinking that when you allocate a pointer, that also allocates a size for whatever list that is. It doesn't. All it does is allocate a pointer to a list. There is no list, just a pointer to a list. If you want to put things on the list, then you have to use list->push_back() or a similar method. And if what you have allocated is a pointer to a list of pointers to lists, then you have to make sure that what you are pushing onto the main list is pointers to lists that have been allocated with new() and not pointers to things you have created on the stack (e.g. list->push_back( &stackList); ). That will cause a crash too, because those stack things will be deleted as soon as the method that creates them exits and your stack will contain a bunch of pointers to deleted objects.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. qt crashed!
    By erfan in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2012, 17:27
  2. QFileDialog is crashed?
    By Gokulnathvc in forum Newbie
    Replies: 3
    Last Post: 19th December 2011, 07:16
  3. winId() crashed
    By nedivi in forum Qt Programming
    Replies: 1
    Last Post: 6th March 2011, 23:03
  4. QT Creator crashed on startup
    By eloos in forum Qt Tools
    Replies: 13
    Last Post: 20th November 2009, 08:50
  5. Crashed project
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 26th January 2008, 00:25

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
  •  
Qt is a trademark of The Qt Company.