From matthieu.cadet at gmail.com Fri Aug 8 12:06:58 2014 From: matthieu.cadet at gmail.com (Matthieu Cadet) Date: Fri, 8 Aug 2014 12:06:58 +0200 Subject: [PySide] QSortFilterProxyModel and QListView - indexWidget pointer get deleted when filtering In-Reply-To: References: Message-ID: Hi As I didn't get answer yet, I've also post a question on StackOverflow http://stackoverflow.com/questions/24995936/pyside-qsortfilterproxymodel-and-qlistview-indexwidget-pointer-get-deleted-w Someone has test the code on Windows 7 with PySide 1.2.2 and Python 3.3 and says it works for him without RuntimeError message.... I'm still trying to find a solution to this problem :P On Mon, Jul 28, 2014 at 2:26 PM, Matthieu Cadet wrote: > Hi PySide guru's > > I've a problem with a custom QListView I'm trying to make, here the > problem: > > I'm using QListView to show a list of QWidget object by using > QListView.setIndexWidget(), > this works pretty fine, but now I want to filter the item model by > using QSortFilterProxyModel() > with .setFilterWildcard() it is not working very well because the second > time the model is filtered > I got error like this : > > *RuntimeError: Internal C++ object (PySide.QtGui.QLabel) already deleted.* > > Without using filtering and QSortFilterProxyModel everything works fine, > but it seems I'm missing > something with the filtering operation, the indexWidget() is deleted when > using filtering :( > > here a sample code where you can reproduce the bug, when list view is > shown, hit 1,2 or 3 keyboard > key to activate filtering ( Backspace to set filtering empty to show all > items ) > > *https://gist.github.com/66e29df303d1f1825a53.git > * > > > Can someone please help me on this? is this a known bug ? or I'm doing it > completely wrong :P > > Thanks in advance for your help. > > -- > Matthieu Cadet > -- Matthieu Cadet Compositor Artist & TD, nWave Digital matthieu.cadet at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From schampailler at skynet.be Sat Aug 9 23:10:33 2014 From: schampailler at skynet.be (Stefan Champailler) Date: Sat, 9 Aug 2014 23:10:33 +0200 Subject: [PySide] QSortFilterProxyModel and QListView - indexWidget pointer get deleted when filtering In-Reply-To: References: Message-ID: <20140809231033.315c66ba@debian> Hi MAtthieu, I can reproduce your bug Could you try to make a simpler version of your code ? Sometimes, it helps to sort out other causes of error (I had my share of dangling pointer with PySide...) Stefan On Fri, 8 Aug 2014 12:06:58 +0200 Matthieu Cadet wrote: > Hi > > As I didn't get answer yet, I've also post a question on StackOverflow > > http://stackoverflow.com/questions/24995936/pyside-qsortfilterproxymodel-and-qlistview-indexwidget-pointer-get-deleted-w > > Someone has test the code on Windows 7 with PySide 1.2.2 and Python 3.3 and > says it works for him without RuntimeError message.... > > I'm still trying to find a solution to this problem :P > > > > On Mon, Jul 28, 2014 at 2:26 PM, Matthieu Cadet > wrote: > > > Hi PySide guru's > > > > I've a problem with a custom QListView I'm trying to make, here the > > problem: > > > > I'm using QListView to show a list of QWidget object by using > > QListView.setIndexWidget(), > > this works pretty fine, but now I want to filter the item model by > > using QSortFilterProxyModel() > > with .setFilterWildcard() it is not working very well because the second > > time the model is filtered > > I got error like this : > > > > *RuntimeError: Internal C++ object (PySide.QtGui.QLabel) already deleted.* > > > > Without using filtering and QSortFilterProxyModel everything works fine, > > but it seems I'm missing > > something with the filtering operation, the indexWidget() is deleted when > > using filtering :( > > > > here a sample code where you can reproduce the bug, when list view is > > shown, hit 1,2 or 3 keyboard > > key to activate filtering ( Backspace to set filtering empty to show all > > items ) > > > > *https://gist.github.com/66e29df303d1f1825a53.git > > * > > > > > > Can someone please help me on this? is this a known bug ? or I'm doing it > > completely wrong :P > > > > Thanks in advance for your help. > > > > -- > > Matthieu Cadet > > > > > > -- > Matthieu Cadet > Compositor Artist & TD, > nWave Digital > matthieu.cadet at gmail.com -- Timeo Danaos et dona ferentes Twitter : @Arakowa1 From schampailler at skynet.be Sat Aug 9 23:28:59 2014 From: schampailler at skynet.be (Stefan Champailler) Date: Sat, 9 Aug 2014 23:28:59 +0200 Subject: [PySide] QSortFilterProxyModel and QListView - indexWidget pointer get deleted when filtering In-Reply-To: <20140809231033.315c66ba@debian> References: <20140809231033.315c66ba@debian> Message-ID: <20140809232859.0cf2c7ff@debian> I've removed some useless code but the issue still is there... really sounds like a bug... stF On Sat, 9 Aug 2014 23:10:33 +0200 Stefan Champailler wrote: > Hi MAtthieu, > > I can reproduce your bug > > Could you try to make a simpler version of your code ? Sometimes, it helps to sort out other causes of error (I had my share of dangling pointer with PySide...) > > Stefan > > > > On Fri, 8 Aug 2014 12:06:58 +0200 > Matthieu Cadet wrote: > > > Hi > > > > As I didn't get answer yet, I've also post a question on StackOverflow > > > > http://stackoverflow.com/questions/24995936/pyside-qsortfilterproxymodel-and-qlistview-indexwidget-pointer-get-deleted-w > > > > Someone has test the code on Windows 7 with PySide 1.2.2 and Python 3.3 and > > says it works for him without RuntimeError message.... > > > > I'm still trying to find a solution to this problem :P > > > > > > > > On Mon, Jul 28, 2014 at 2:26 PM, Matthieu Cadet > > wrote: > > > > > Hi PySide guru's > > > > > > I've a problem with a custom QListView I'm trying to make, here the > > > problem: > > > > > > I'm using QListView to show a list of QWidget object by using > > > QListView.setIndexWidget(), > > > this works pretty fine, but now I want to filter the item model by > > > using QSortFilterProxyModel() > > > with .setFilterWildcard() it is not working very well because the second > > > time the model is filtered > > > I got error like this : > > > > > > *RuntimeError: Internal C++ object (PySide.QtGui.QLabel) already deleted.* > > > > > > Without using filtering and QSortFilterProxyModel everything works fine, > > > but it seems I'm missing > > > something with the filtering operation, the indexWidget() is deleted when > > > using filtering :( > > > > > > here a sample code where you can reproduce the bug, when list view is > > > shown, hit 1,2 or 3 keyboard > > > key to activate filtering ( Backspace to set filtering empty to show all > > > items ) > > > > > > *https://gist.github.com/66e29df303d1f1825a53.git > > > * > > > > > > > > > Can someone please help me on this? is this a known bug ? or I'm doing it > > > completely wrong :P > > > > > > Thanks in advance for your help. > > > > > > -- > > > Matthieu Cadet > > > > > > > > > > > -- > > Matthieu Cadet > > Compositor Artist & TD, > > nWave Digital > > matthieu.cadet at gmail.com > > > -- > Timeo Danaos et dona ferentes > Twitter : @Arakowa1 > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside -- Timeo Danaos et dona ferentes Twitter : @Arakowa1 From ea7dfh at ea7dfh.com Sun Aug 10 00:26:30 2014 From: ea7dfh at ea7dfh.com (Jesus) Date: Sun, 10 Aug 2014 00:26:30 +0200 Subject: [PySide] QSortFilterProxyModel and QListView - indexWidget pointer get deleted when filtering In-Reply-To: <20140809232859.0cf2c7ff@debian> References: <20140809231033.315c66ba@debian> <20140809232859.0cf2c7ff@debian> Message-ID: <53E6A016.5000105@ea7dfh.com> Hi I'm not an expert programmer in python nor pyside by far, but I've made a test using pyqt4 with your code and the error is the same. This is the kind of bug when an object loss its reference to itself inside a class. So I would check if the label item still has a parent when it is filtered (or deleted?) by the model. I may be wrong, of course, so please be gentle. Regards, Jesus El 09/08/14 23:28, Stefan Champailler escribió: > I've removed some useless code but the issue still is there... > > really sounds like a bug... > > stF > > > On Sat, 9 Aug 2014 23:10:33 +0200 > Stefan Champailler wrote: > >> Hi MAtthieu, >> >> I can reproduce your bug >> >> Could you try to make a simpler version of your code ? Sometimes, it helps to sort out other causes of error (I had my share of dangling pointer with PySide...) >> >> Stefan >> >> >> >> On Fri, 8 Aug 2014 12:06:58 +0200 >> Matthieu Cadet wrote: >> >>> Hi >>> >>> As I didn't get answer yet, I've also post a question on StackOverflow >>> >>> http://stackoverflow.com/questions/24995936/pyside-qsortfilterproxymodel-and-qlistview-indexwidget-pointer-get-deleted-w >>> >>> Someone has test the code on Windows 7 with PySide 1.2.2 and Python 3.3 and >>> says it works for him without RuntimeError message.... >>> >>> I'm still trying to find a solution to this problem :P >>> >>> >>> >>> On Mon, Jul 28, 2014 at 2:26 PM, Matthieu Cadet >>> wrote: >>> >>>> Hi PySide guru's >>>> >>>> I've a problem with a custom QListView I'm trying to make, here the >>>> problem: >>>> >>>> I'm using QListView to show a list of QWidget object by using >>>> QListView.setIndexWidget(), >>>> this works pretty fine, but now I want to filter the item model by >>>> using QSortFilterProxyModel() >>>> with .setFilterWildcard() it is not working very well because the second >>>> time the model is filtered >>>> I got error like this : >>>> >>>> *RuntimeError: Internal C++ object (PySide.QtGui.QLabel) already deleted.* >>>> >>>> Without using filtering and QSortFilterProxyModel everything works fine, >>>> but it seems I'm missing >>>> something with the filtering operation, the indexWidget() is deleted when >>>> using filtering :( >>>> >>>> here a sample code where you can reproduce the bug, when list view is >>>> shown, hit 1,2 or 3 keyboard >>>> key to activate filtering ( Backspace to set filtering empty to show all >>>> items ) >>>> >>>> *https://gist.github.com/66e29df303d1f1825a53.git >>>> * >>>> >>>> >>>> Can someone please help me on this? is this a known bug ? or I'm doing it >>>> completely wrong :P >>>> >>>> Thanks in advance for your help. >>>> >>>> -- >>>> Matthieu Cadet -- Jesus Guardon From schampailler at skynet.be Sun Aug 10 09:15:15 2014 From: schampailler at skynet.be (Stefan Champailler) Date: Sun, 10 Aug 2014 09:15:15 +0200 Subject: [PySide] QSortFilterProxyModel and QListView - indexWidget pointer get deleted when filtering In-Reply-To: <53E6A016.5000105@ea7dfh.com> References: <20140809231033.315c66ba@debian> <20140809232859.0cf2c7ff@debian> <53E6A016.5000105@ea7dfh.com> Message-ID: <20140810091515.46d646ec@debian> Yep, Jesus idea seems right. PySide (an dPyQt4) I guess being C++ bindings, one has to be careful with pointers. This is quite misleading sometimes. Fortunatelemy, with times, one learns the safe design patterns, so it(s not much of a problem. By the way, it's quite surprising to see a reference to a view widget (QLabel) in a model item. I don't say it leads to bug nor that it is plain wrong, but it's just not very MVC (model view ocntroller pattern) stF On Sun, 10 Aug 2014 00:26:30 +0200 Jesus wrote: > Hi > > I'm not an expert programmer in python nor pyside by far, but I've made > a test using pyqt4 with your code and the error is the same. > > This is the kind of bug when an object loss its reference to itself > inside a class. So I would check if the label item still has a parent > when it is filtered (or deleted?) by the model. I may be wrong, of > course, so please be gentle. > > Regards, > > Jesus > > El 09/08/14 23:28, Stefan Champailler escribió: > > I've removed some useless code but the issue still is there... > > > > really sounds like a bug... > > > > stF > > > > > > On Sat, 9 Aug 2014 23:10:33 +0200 > > Stefan Champailler wrote: > > > >> Hi MAtthieu, > >> > >> I can reproduce your bug > >> > >> Could you try to make a simpler version of your code ? Sometimes, it helps to sort out other causes of error (I had my share of dangling pointer with PySide...) > >> > >> Stefan > >> > >> > >> > >> On Fri, 8 Aug 2014 12:06:58 +0200 > >> Matthieu Cadet wrote: > >> > >>> Hi > >>> > >>> As I didn't get answer yet, I've also post a question on StackOverflow > >>> > >>> http://stackoverflow.com/questions/24995936/pyside-qsortfilterproxymodel-and-qlistview-indexwidget-pointer-get-deleted-w > >>> > >>> Someone has test the code on Windows 7 with PySide 1.2.2 and Python 3.3 and > >>> says it works for him without RuntimeError message.... > >>> > >>> I'm still trying to find a solution to this problem :P > >>> > >>> > >>> > >>> On Mon, Jul 28, 2014 at 2:26 PM, Matthieu Cadet > >>> wrote: > >>> > >>>> Hi PySide guru's > >>>> > >>>> I've a problem with a custom QListView I'm trying to make, here the > >>>> problem: > >>>> > >>>> I'm using QListView to show a list of QWidget object by using > >>>> QListView.setIndexWidget(), > >>>> this works pretty fine, but now I want to filter the item model by > >>>> using QSortFilterProxyModel() > >>>> with .setFilterWildcard() it is not working very well because the second > >>>> time the model is filtered > >>>> I got error like this : > >>>> > >>>> *RuntimeError: Internal C++ object (PySide.QtGui.QLabel) already deleted.* > >>>> > >>>> Without using filtering and QSortFilterProxyModel everything works fine, > >>>> but it seems I'm missing > >>>> something with the filtering operation, the indexWidget() is deleted when > >>>> using filtering :( > >>>> > >>>> here a sample code where you can reproduce the bug, when list view is > >>>> shown, hit 1,2 or 3 keyboard > >>>> key to activate filtering ( Backspace to set filtering empty to show all > >>>> items ) > >>>> > >>>> *https://gist.github.com/66e29df303d1f1825a53.git > >>>> * > >>>> > >>>> > >>>> Can someone please help me on this? is this a known bug ? or I'm doing it > >>>> completely wrong :P > >>>> > >>>> Thanks in advance for your help. > >>>> > >>>> -- > >>>> Matthieu Cadet > > > > -- > Jesus Guardon > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside -- Timeo Danaos et dona ferentes Twitter : @Arakowa1 From ochiu at teslamotors.com Tue Aug 12 02:38:45 2014 From: ochiu at teslamotors.com (Otto Chiu) Date: Tue, 12 Aug 2014 00:38:45 +0000 Subject: [PySide] Error compiling shiboken Message-ID: <459D4CF76F76B54697869793F5BEF3592D747C19@SJC04-DAG01-N02.teslamotors.com> Hi, I am trying to compile PySide on Windows by following the instructions on http://qt-project.org/wiki/Building_PySide_on_Windows but I am getting compile errors on Shiboken. I need to compile it instead of using the binaries because of this bug: https://bugreports.qt-project.org/browse/PYSIDE-164. We are seeing our app hang at some_signal.emit() and wanted to see if this patch fixes it. Does anyone have any suggestion on what may be causing the compile error? To be honest, all I really care about is the bugfix - is there an easier way to patch PySide without manually re-compiling? Building CXX object generator/CMakeFiles/shiboken.dir/main.cpp.obj main.cpp Linking CXX executable shiboken.exe [ 96%] Built target shiboken [ 98%] Running generator for 'shiboken'... NMAKE : fatal error U1077: 'C:\PySide-1.2.2\pyside_build\py2.7-qt4.8.5-32bit-release\shiboken\generator\shiboken.EXE' : return code '0xc0000139' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe"' : return code '0x2' Stop. error: Error compiling shiboken Thanks, Otto -------------- next part -------------- An HTML attachment was scrubbed... URL: From backup.rlacko at gmail.com Tue Aug 12 13:00:09 2014 From: backup.rlacko at gmail.com (Roman Lacko) Date: Tue, 12 Aug 2014 13:00:09 +0200 Subject: [PySide] Error compiling shiboken In-Reply-To: <459D4CF76F76B54697869793F5BEF3592D747C19@SJC04-DAG01-N02.teslamotors.com> References: <459D4CF76F76B54697869793F5BEF3592D747C19@SJC04-DAG01-N02.teslamotors.com> Message-ID: Hi, please, can you send here the full build log ? Thanks Roman 2014-08-12 2:38 GMT+02:00 Otto Chiu : > Hi, > > I am trying to compile PySide on Windows by following the instructions on > http://qt-project.org/wiki/Building_PySide_on_Windows but I am getting > compile errors on Shiboken. I need to compile it instead of using the > binaries because of this bug: > https://bugreports.qt-project.org/browse/PYSIDE-164. We are seeing our > app hang at some_signal.emit() and wanted to see if this patch fixes it. > > > > Does anyone have any suggestion on what may be causing the compile error? > To be honest, all I really care about is the bugfix – is there an easier > way to patch PySide without manually re-compiling? > > > > Building CXX object generator/CMakeFiles/shiboken.dir/main.cpp.obj > > main.cpp > > Linking CXX executable shiboken.exe > > [ 96%] Built target shiboken > > [ 98%] Running generator for 'shiboken'... > > NMAKE : fatal error U1077: > 'C:\PySide-1.2.2\pyside_build\py2.7-qt4.8.5-32bit-release\shiboken\generator\shiboken.EXE' > : return code '0xc0000139' > > Stop. > > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual > Studio 9.0\VC\BIN\nmake.exe"' : return code '0x2' > > Stop. > > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual > Studio 9.0\VC\BIN\nmake.exe"' : return code '0x2' > > Stop. > > error: Error compiling shiboken > > > > > > Thanks, > > Otto > > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthieu.cadet at gmail.com Mon Aug 11 11:27:03 2014 From: matthieu.cadet at gmail.com (Matthieu Cadet) Date: Mon, 11 Aug 2014 11:27:03 +0200 Subject: [PySide] QSortFilterProxyModel and QListView - indexWidget pointer get deleted when filtering In-Reply-To: <20140810091515.46d646ec@debian> References: <20140809231033.315c66ba@debian> <20140809232859.0cf2c7ff@debian> <53E6A016.5000105@ea7dfh.com> <20140810091515.46d646ec@debian> Message-ID: Hi Thanks for your help guys... I'm still stuck with this bug... Here is a simplified version of the code: https://gist.github.com/maty974/66e29df303d1f1825a53 Instead of using a QLabel to show text I paint the text value in the painter of the widget. But after made thoses changes, I've discover that each CustomItemWidget() widget get the "QEvent.Type.DeferredDelete" event after filtering with the Proxy model... So now after filtering the model, each indexWidget() get deleted and I don't get any error, and what is visible after filtering is the QtGui.QStandardItem and its DisplayRole... I've also check in the C++ source code of Qt for QAbstractItemView to see how the indexWidget is set: https://qt.gitorious.org/qt/qt/source/bfa0be8a1bf68200f1ba98888deff4a9215ee066:src/gui/itemviews/qabstractitemview.cpp#L3087-3088 and I don't really understand when this part of code happen: if (QWidget *oldWidget = indexWidget(index)) { d->persistent.remove(oldWidget); d->removeEditor(oldWidget); oldWidget->deleteLater(); } Anyway I'll try to investigate more into this :) Thanks for testing this for me ;) Matthieu On Sun, Aug 10, 2014 at 9:15 AM, Stefan Champailler wrote: > Yep, Jesus idea seems right. PySide (an dPyQt4) I guess being C++ > bindings, one has to be careful with pointers. This is quite misleading > sometimes. Fortunatelemy, with times, one learns the safe design patterns, > so it(s not much of a problem. > > By the way, it's quite surprising to see a reference to a view widget > (QLabel) in a model item. I don't say it leads to bug nor that it is plain > wrong, but it's just not very MVC (model view ocntroller pattern) > > stF > > > On Sun, 10 Aug 2014 00:26:30 +0200 > Jesus wrote: > > > Hi > > > > I'm not an expert programmer in python nor pyside by far, but I've made > > a test using pyqt4 with your code and the error is the same. > > > > This is the kind of bug when an object loss its reference to itself > > inside a class. So I would check if the label item still has a parent > > when it is filtered (or deleted?) by the model. I may be wrong, of > > course, so please be gentle. > > > > Regards, > > > > Jesus > > > > El 09/08/14 23:28, Stefan Champailler escribió: > > > I've removed some useless code but the issue still is there... > > > > > > really sounds like a bug... > > > > > > stF > > > > > > > > > On Sat, 9 Aug 2014 23:10:33 +0200 > > > Stefan Champailler wrote: > > > > > >> Hi MAtthieu, > > >> > > >> I can reproduce your bug > > >> > > >> Could you try to make a simpler version of your code ? Sometimes, it > helps to sort out other causes of error (I had my share of dangling pointer > with PySide...) > > >> > > >> Stefan > > >> > > >> > > >> > > >> On Fri, 8 Aug 2014 12:06:58 +0200 > > >> Matthieu Cadet wrote: > > >> > > >>> Hi > > >>> > > >>> As I didn't get answer yet, I've also post a question on > StackOverflow > > >>> > > >>> > http://stackoverflow.com/questions/24995936/pyside-qsortfilterproxymodel-and-qlistview-indexwidget-pointer-get-deleted-w > > >>> > > >>> Someone has test the code on Windows 7 with PySide 1.2.2 and Python > 3.3 and > > >>> says it works for him without RuntimeError message.... > > >>> > > >>> I'm still trying to find a solution to this problem :P > > >>> > > >>> > > >>> > > >>> On Mon, Jul 28, 2014 at 2:26 PM, Matthieu Cadet < > matthieu.cadet at gmail.com> > > >>> wrote: > > >>> > > >>>> Hi PySide guru's > > >>>> > > >>>> I've a problem with a custom QListView I'm trying to make, here the > > >>>> problem: > > >>>> > > >>>> I'm using QListView to show a list of QWidget object by using > > >>>> QListView.setIndexWidget(), > > >>>> this works pretty fine, but now I want to filter the item model by > > >>>> using QSortFilterProxyModel() > > >>>> with .setFilterWildcard() it is not working very well because the > second > > >>>> time the model is filtered > > >>>> I got error like this : > > >>>> > > >>>> *RuntimeError: Internal C++ object (PySide.QtGui.QLabel) already > deleted.* > > >>>> > > >>>> Without using filtering and QSortFilterProxyModel everything works > fine, > > >>>> but it seems I'm missing > > >>>> something with the filtering operation, the indexWidget() is > deleted when > > >>>> using filtering :( > > >>>> > > >>>> here a sample code where you can reproduce the bug, when list view > is > > >>>> shown, hit 1,2 or 3 keyboard > > >>>> key to activate filtering ( Backspace to set filtering empty to > show all > > >>>> items ) > > >>>> > > >>>> *https://gist.github.com/66e29df303d1f1825a53.git > > >>>> * > > >>>> > > >>>> > > >>>> Can someone please help me on this? is this a known bug ? or I'm > doing it > > >>>> completely wrong :P > > >>>> > > >>>> Thanks in advance for your help. > > >>>> > > >>>> -- > > >>>> Matthieu Cadet > > > > > > > > -- > > Jesus Guardon > > _______________________________________________ > > PySide mailing list > > PySide at qt-project.org > > http://lists.qt-project.org/mailman/listinfo/pyside > > > -- > Timeo Danaos et dona ferentes > Twitter : @Arakowa1 > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside > -- Matthieu Cadet Compositor Artist & TD, nWave Digital matthieu.cadet at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tmassimi at gmail.com Wed Aug 13 23:24:33 2014 From: tmassimi at gmail.com (Tommaso Massimi) Date: Wed, 13 Aug 2014 23:24:33 +0200 Subject: [PySide] QSortFilterProxyModel and QListView - indexWidget pointer get deleted when filtering Message-ID: Hi all, I'm sorry to split this thread but I can't answer to the right mail as I was not yet subscribed to this ml when the mail was sent > Hi > > Thanks for your help guys... I'm still stuck with this bug... > > Here is a simplified version of the code:> https://gist.github.com/maty974/66e29df303d1f1825a53 > > Instead of using a QLabel to show text I paint the text value in the > painter of the widget. > > But after made thoses changes, I've discover that each CustomItemWidget() > widget get the "QEvent.Type.DeferredDelete" event after filtering with the > Proxy model... I think that the function setIndexWidget is requiring that deletion, try to modify in this way the function addItem (I'm not sure about what you want to do, so I can't suggest more): def addItem(self, item): self.data_model.appendRow(item) #proxy_index = self.proxy_model.mapFromSource(item.index()) #self.setIndexWidget(proxy_index, item.item_widget) -------------- next part -------------- An HTML attachment was scrubbed... URL: From hlamer at tut.by Mon Aug 25 08:11:13 2014 From: hlamer at tut.by (Andrei Kopats) Date: Mon, 25 Aug 2014 09:11:13 +0300 Subject: [PySide] PyQt. How to shoot yourself in the foot Message-ID: Hi I published an article about memory management in PyQt and PySide. I think it might be interesting for somebody in this list. http://enki-editor.org/2014/08/23/Pyqt_mem_mgmt.html Regards, Andrei Kopats -------------- next part -------------- An HTML attachment was scrubbed... URL: From techtonik at gmail.com Mon Aug 25 10:15:01 2014 From: techtonik at gmail.com (anatoly techtonik) Date: Mon, 25 Aug 2014 11:15:01 +0300 Subject: [PySide] PyQt. How to shoot yourself in the foot In-Reply-To: References: Message-ID: On Mon, Aug 25, 2014 at 9:11 AM, Andrei Kopats wrote: > Hi > > I published an article about memory management in PyQt and PySide. I think > it might be interesting for somebody in this list. > > http://enki-editor.org/2014/08/23/Pyqt_mem_mgmt.html Very interesting stuff actually. You may want to fix indentation in the first snippet. About Python not calling constructor of QObject - are there cases when you don't need to call QObject constructor? If not, it is should be possible to either: a. fix binding b. provide an automatic import through __new__/metaclass mechanizm BTW, it is possible to detect 'disconnected' object without catching exception? "References to all created objects must be saved even if you are not going to use them." - I can't say that this is a bad design. Knowing that PyQt objects have scope and realizing the boundaries of this scope is a good practice for the brain to think about program architecture. I know some serious games where garbage collector is turned off completely. I guess it is very easy to spot memory leaks in such case. > C++ object is deleted by Qt but Python wrapper still exists ... > A slot of the deleted object is called by timer or signal from the external world So, the correct strategy is to disconnect all signals and reset timers when an object is destroyed. I fail to see how C++ -- Python link play major role in this architecture. Even if you implement decoupled system with signals and timers in pure Python, it will still be flaky when referenced objects are destroyed. So how Qt propose to handle this on pure C++ level? > C++ method overridden by Python wrapper Crashes. Looks like a missing part in PySide. If it is fixable, it needs a bug report to keep track of. Few more questions (I don't have CS degree, so they may be lame): > When deleting an object which has Python-slots, disconnect the slots manually How to distinguish object with Python-slots from, well, object with standard PySide slots? > To be notified about an object deletion use the QObject.destroyed signal but not > the __del__ method of a Python wrapper How to be notified with a __del__ method? > Don't use QTimer.singleShot for an object which might be deleted. It is impossible > to stop and disconnect such a timer Not clear why singleShot, being connected to an object method, doesn't keep a reference to this object. > Don't use lambda function as a slot. It is impossible to disconnect it. Also interesting to know the gory details - why? If signals can reach it, then in theory a disconnector could reach it too. P.S. gdb really helps to debug application crashes - I think it works even on Windows, see the cheatsheet https://code.google.com/p/spyderlib/wiki/HowToDebugQtCrash -- anatoly t. From hlamer at tut.by Mon Aug 25 10:35:38 2014 From: hlamer at tut.by (Andrei Kopats) Date: Mon, 25 Aug 2014 11:35:38 +0300 Subject: [PySide] PyQt. How to shoot yourself in the foot In-Reply-To: References: Message-ID: Hi, Anatoly See my comments below > C++ object is deleted by Qt but Python wrapper still exists > ... > > A slot of the deleted object is called by timer or signal from the > external world > > So, the correct strategy is to disconnect all signals and reset timers > when an > object is destroyed. I fail to see how C++ -- Python link play major > role in this architecture. Even if you implement decoupled system with > signals > and timers in pure Python, it will still be flaky when referenced objects > are > destroyed. So how Qt propose to handle this on pure C++ level? > QObject::~QObject documentation: "All signals to and from the object are automatically disconnected, and any pending posted events for the object are removed from the event queue. " > > C++ method overridden by Python wrapper > > Crashes. Looks like a missing part in PySide. If it is fixable, it needs a > bug > report to keep track of. > I don't this it is easily fixable, would has been fixed otherwise. > > Few more questions (I don't have CS degree, so they may be lame): > > When deleting an object which has Python-slots, disconnect the slots > manually > > How to distinguish object with Python-slots from, well, object with > standard > PySide slots? > When I say "Python slots" in this article, I mean any function or method, which is written in Python and connected to signal. Not Python object model __slots__. > > > To be notified about an object deletion use the QObject.destroyed signal > but not > > the __del__ method of a Python wrapper > > How to be notified with a __del__ method? > One may try to disconnect signals in __del__ method. i.e. class Foo: def __del__(self) someObject.someSignal.disconnect(self.mySlot) But this approach doesn't work. > > Don't use QTimer.singleShot for an object which might be deleted. It is > impossible > > to stop and disconnect such a timer > > Not clear why singleShot, being connected to an object method, doesn't > keep a > reference to this object. > > > Don't use lambda function as a slot. It is impossible to disconnect it. > > Also interesting to know the gory details - why? If signals can reach > it, then in theory a disconnector could reach it too. > All this would work fine, if Qt were written in pure Python. But the C++-Python bridge introduces some magic and some pitfalls. Regards, Andrei -------------- next part -------------- An HTML attachment was scrubbed... URL: From schampailler at skynet.be Mon Aug 25 11:03:55 2014 From: schampailler at skynet.be (S. Champailler) Date: Mon, 25 Aug 2014 11:03:55 +0200 (CEST) Subject: [PySide] PyQt. How to shoot yourself in the foot In-Reply-To: References: Message-ID: <300350090.247722.1408957435637.open-xchange@webmail.nmp.skynet.be> Very nice article, a bit scary indeed :-) I'd wish I had it when I started with Pyside 3 years ago, it took me alot of time to realize that all these problems are here "by design" and one has to live with them. Fortunately, when one gets that clear, it really is not a problem anymore (as you said) stF > Le 25 août 2014 à 08:11, Andrei Kopats a écrit : > > > Hi > > I published an article about memory management in PyQt and PySide. I think > it might be interesting for somebody in this list. > > http://enki-editor.org/2014/08/23/Pyqt_mem_mgmt.html > > Regards, > Andrei Kopats > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside From thoromyr at mac.com Mon Aug 25 13:38:44 2014 From: thoromyr at mac.com (Tim Doty) Date: Mon, 25 Aug 2014 06:38:44 -0500 Subject: [PySide] PyQt. How to shoot yourself in the foot In-Reply-To: References: Message-ID: Thanks for the nice article. I really appreciate it when an article points out solutions to issues it has raised, and that is something you. I’m going to stick with new style slots, but that is made easier by PySide disconnecting them. And it is nice to have a warning about potential issue with overriding C++ methods. Thanks. Tim Doty On Aug 25, 2014, at 1:11 AM, Andrei Kopats wrote: > Hi > > I published an article about memory management in PyQt and PySide. I think it might be interesting for somebody in this list. > > http://enki-editor.org/2014/08/23/Pyqt_mem_mgmt.html > > Regards, > Andrei Kopats > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside From Marc.Poinot at onera.fr Mon Aug 25 15:43:31 2014 From: Marc.Poinot at onera.fr (Marc.Poinot at onera.fr) Date: Mon, 25 Aug 2014 15:43:31 +0200 Subject: [PySide] Python vs Cython init Message-ID: <53FB3D83.4040508@onera.fr> Hi all, reading the Andrei Kopats article (http://enki-editor.org/2014/08/23/Pyqt_mem_mgmt.html)regarding the memory init, it reminds me an issue I've had. It's related to an issue I had with the object init, using the same lines with python and then with cython. The cython init is not the same as the python one, at least when you write your own C++ wrapper, but in that case I have no way to modify the actual C++ wrapper. Cython based files do crash with these two calls: # --- crash stack ends with: # Shiboken::String::toCString(_object*, long*) # PySide::Signal::getCallbackSignature(char const*, QObject*, _object*, bool) See the attached file for the test, now my applications are using plain python files to avoid the issue, but I'd rather use cython files. So I wonder if it's an expected behavior, a bad install on my platform or a known issue with PySide. -MP- -- -- ---------------------------------------------------------------------------- -- Marc POINOT [ONERA/DSNA] Tel:+33.1.46.73.42.84 Fax:+33.1.46.73.41.66 -- Avertissement/disclaimer http://www.onera.fr/en/emails-terms -- ---------------------------------------------------------------------------- -- -------------- next part -------------- A non-text attachment was scrubbed... Name: oups.tar.gz Type: application/x-gzip Size: 2342 bytes Desc: not available URL: