Results 1 to 6 of 6

Thread: ListModel.remove() crashes program

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2008
    Posts
    16
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: ListModel.remove() crashes program

    Quote Originally Posted by Lykurg View Post
    What should index be? Try .remove(currentIndex)!
    index is whatever the index of the item is that has been interacted with or interacted with one of its children. For my current project, which isn't entirely reflected in the reproducable code, in order to remove the item from the list you have to interact with a child element of the item. This means currentIndex is not practical for my current project, since interacting with the child element does not necessarily make the item parent the current item. Nevertheless, if you were to replace index with ListView.currentIndex (or whatever gives you the current index) in the reproducable code, the program would still crash.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: ListModel.remove() crashes program

    Removing the current item inside any routine that handles that item is not safe. Mark the item for deletion and delete it after the control returns to the event loop. You might need to interface with C++ for that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2008
    Posts
    16
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: ListModel.remove() crashes program

    Quote Originally Posted by wysota View Post
    Removing the current item inside any routine that handles that item is not safe. Mark the item for deletion and delete it after the control returns to the event loop. You might need to interface with C++ for that.
    Researching what you said, i found this example in the documentation which also calls model_id.remove(index) from the delegate: http://doc.qt.nokia.com/4.7-snapshot...clist-qml.html Skimming through the example, i don't really see any fundamental difference between my code (or the crash reproducable code) and the example.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: ListModel.remove() crashes program

    The fundamental difference is in ListView.delayRemove=true and everything around it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    truefusion (6th February 2012)

Similar Threads

  1. Program crashes on OS X Lion
    By fyodor in forum Newbie
    Replies: 1
    Last Post: 31st October 2011, 06:18
  2. Program crashes
    By Fallen_ in forum Qt Programming
    Replies: 49
    Last Post: 20th September 2010, 01:41
  3. Program crashes while trying to do a check in constructor
    By hakermania in forum Qt Programming
    Replies: 5
    Last Post: 1st September 2010, 10:15
  4. program crashes (QtTestRunner)
    By fmariusd in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2008, 09:27
  5. Program crashes (SIGSEGV)
    By Voldemort in forum Qt Programming
    Replies: 47
    Last Post: 21st May 2007, 20:09

Tags for this Thread

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.