Results 1 to 3 of 3

Thread: "underlying C/C++ object has been deleted" PyQt

  1. #1
    Join Date
    Dec 2011
    Posts
    4
    Qt products
    Platforms
    Unix/X11

    Default "underlying C/C++ object has been deleted" PyQt

    I've already asked this question in 'newbie' but with no answer, I'm trying here then.

    I have list, self.cards, that is [QListWidgetItem, string, QString]
    in this function I just iter the elements of this list and populate my QListView (self.cardList).

    Qt Code:
    1. def updateCardList(self):
    2. for card_ in self.cards:
    3. self.cardList.addItem(card_[0])
    To copy to clipboard, switch view to plain text mode 

    It works fine for this function:
    Qt Code:
    1. def selectEditionsF(self):
    2. self.cards=[]
    3. for sEdition in self.selectedEditions:
    4. for edition in self.listEditions:
    5. if sEdition == edition[0]:
    6. for card in edition[1].iter('card'):
    7. self.cards.append([QListWidgetItem(card.get('name')), card.get('graphics'), sEdition])
    8. self.updateCardList()
    9. self.selectEditionsWindow.close()
    To copy to clipboard, switch view to plain text mode 

    but in this case:
    Qt Code:
    1. def refine(self, bool):
    2. tempcards = self.cards
    3. self.cards = []
    4. for card in tempcards:
    5. if self.refineColor.isChecked():
    6. if self.colorBlue.isChecked():
    7. if self.getCardColor(card[0]) == "Blue":
    8. self.cards.append(card)
    9. self.updateCardList()
    To copy to clipboard, switch view to plain text mode 

    When it enters the loop in updateCardList I receive this message: "underlying C/C++ object has been deleted"
    Debug I found that inside the function everything is Ok, the error appears just inside the loop.

    Any Ideas?

  2. #2
    Join Date
    Dec 2011
    Posts
    4
    Qt products
    Platforms
    Unix/X11

    Default Re: "underlying C/C++ object has been deleted" PyQt

    I found the cause but not the reason

    (in the function I posted was missing a line

    Qt Code:
    1. def updateCardList(self):
    2. self.cardList.clear()
    3. for card_ in self.cards:
    4. self.cardList.addItem(card_[0])
    To copy to clipboard, switch view to plain text mode 

    when I cleared my self.cardList it deleted all items regardless if I had pointers for them or not.
    I could solve it repopulating my self.cardList with new items identical but not the sames.

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: "underlying C/C++ object has been deleted" PyQt

    Quote Originally Posted by janosimas View Post
    I found the cause but not the reason

    (in the function I posted was missing a line
    And this is why I wrote my sig

    I guess you did soemthing wrong with pyqt ref count rules or something. Think about it - if you lost your only pointers to the c++ object, pyqt should clean up in c++, otherwise it is memory leak.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. QGraphicsView: Ladder editor - move object in a "grid"
    By PeterMacGonagan in forum Newbie
    Replies: 0
    Last Post: 7th July 2011, 07:48
  2. Replies: 4
    Last Post: 8th April 2011, 06:47
  3. Replies: 0
    Last Post: 15th November 2009, 09:40
  4. PyQt and i18n, only "half of it" is translated
    By NebuK in forum Qt Programming
    Replies: 21
    Last Post: 25th January 2008, 10:37
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.