PDA

View Full Version : Garbage collector - PyQt



janosimas
11th December 2011, 11:05
Hi guys,
I started using pyqt a few weeks ago, I was not sure about where to but this question but as I'm a newbie here it is.

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).



def updateCardList(self):
for card_ in self.cards:
self.cardList.addItem(card_[0])


It works fine for this function:


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:


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?