"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).
Code:
def updateCardList(self):
for card_ in self.cards:
self.cardList.addItem(card_[0])
It works fine for this function:
Code:
def selectEditionsF(self):
self.cards=[]
for sEdition in self.selectedEditions:
for edition in self.listEditions:
if sEdition == edition[0]:
for card in edition[1].iter('card'):
self.
cards.
append([QListWidgetItem(card.
get('name')), card.
get('graphics'), sEdition
]) self.updateCardList()
self.selectEditionsWindow.close()
but in this case:
Code:
def refine(self, bool):
tempcards = self.cards
self.cards = []
for card in tempcards:
if self.refineColor.isChecked():
if self.colorBlue.isChecked():
if self.getCardColor(card[0]) == "Blue":
self.cards.append(card)
self.updateCardList()
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?
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:)
Code:
def updateCardList(self):
self.cardList.clear()
for card_ in self.cards:
self.cardList.addItem(card_[0])
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.
Re: "underlying C/C++ object has been deleted" PyQt
Quote:
Originally Posted by
janosimas
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 :p
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.