Hi Carlo,

Its very difficult to help you on this situation, because this look
like a bug on PySide memory manager. For some reason PySide object
manager is returning a QWidget where the code wants a QLayout, because
both functions "itemAt" and "ivalidate" are virtual functions and
during the virtual call PySide convert the C++ pointer to Python
object, and for some reason the returned object is not correct.

This normally happens when the C++ object was destroyed and this was
not notified for PySide.

My recommendations to try found the cause of this bug is:

* remote this line: self.__parent = parent  (you can access the parent
widget using the function QWidget.parent())
* make sure to have a extra ref of every python object created
* check the functions called ownership control (return policy and
ownership transfer)

I think this can help you find the reason of the bug.

Good luck :)



On Fri, Jul 29, 2011 at 7:17 AM, Carlo Giesa <[email protected]> wrote:
> Hi there,
>
> I have a problem with PySide that tries to execute a function that does not
> exist on an object.
>
> First, some more explanation:
> I have a special configuration that should be mentioned first. I use PySide
> 1.0.5 that I compiled in 64 bit against Python 2.6 and Qt 4.5.3, both also
> in 64 bit. To have a successful compilation I had to tweak some entries in a
> couple of CMakeFile.txt and typesystem files. Problems came from missing
> elements in Qt 4.5.3 like the QColor::Hsl and QPixmapCache::Key.
> I'm working inside Maya, a 3D software package, that has switched to Qt
> 4.5.3 in its version 2011. Now, there are two ways to build custom user
> interfaces inside it, either with the built-in Python script module which is
> pretty bad or with Python libraries like PyQt and PySide. I'm working on a
> complex project with a couple of user interfaces. Now, with the new
> possibilities of PySide, I would like to replace only some parts of the
> existing interface that has been written with the built-in Python module, so
> I do not need to rewrite everything from scratch.
> I could find a way to convert existing widgets, that have been built in Maya
> into PySide QWidgets (see the bug 902 of PySide buglist). This way I was
> able to just replace parts of my existing user interface with PySide
> QWidgets.
>
> So far, it seemed to work well, but randomly I get following error:
>
> AttributeError: 'PySide.QtGui.QWidget' object has no attribute 'invalidate'
>
> Here's an extract of my code:
>
> class ShotAssetIconBarWidget(QtGui.QWidget):
>     def __init__(self, parent):
>         super(ShotAssetIconBarWidget, self).__init__(parent)
>
>         self.__parent = parent
>
>         self.setGeometry(QtCore.QRect(0, 0, 150, 16))
>         self.setObjectName("ShotAssetIconBarWidget")
>
>         self.horizontalLayout = QtGui.QHBoxLayout(self)
>         self.horizontalLayout.setContentsMargins(0, 0, 0, 0) # Here, the
> error is thrown.
>
> I cannot see any relationship between the setContentsMargins function of the
> QHBoxLayout and the error message. If I remove the line, the error is thrown
> a couple of lines later:
>
>         self.horizontalLayout.setObjectName("HorizontalLayout")
>         self.__assetIcon = QtGui.QLabel(self) # Here, the same error gets
> thrown when I remove the error line above.
>
> So, I investigated a little further and found following things:
>
> When I open a clean Maya and refresh multiple times my user interface,
> everything seems to be stable until we reach a certain amount of
> refreshments (between 400 and 500 times instantiated). So I guess this call
> has to do with some cache or memory cleaning that is called at some point.
> PySide tries to call the invalidate function on the parent QWidget that I
> provide in the constructor. But this parent is a QWidget. So why does PySide
> call the invalidate function on it that is a function of a QLayout? When I
> dynamically add a "invalidate" function that does nothing it works a little
> bit more until PySide wants to call a "itemAt" function on the parent which
> is again a function of QLayout but not of QWidget.
>
> I don't know if anybody has an idea about this.
>
> Thanks for any help!
>
> Greets,
> Carlo
>
>
> _______________________________________________
> PySide mailing list
> [email protected]
> http://lists.pyside.org/listinfo/pyside
>
>



-- 
Renato Araujo Oliveira Filho
Instituto Nokia de Tecnologia - INdT
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to