PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 467 - QtGui.QApplication.allWidgets () returns subclassed widgets as QWidgets
: QtGui.QApplication.allWidgets () returns subclassed widgets as QWidgets
Status: CLOSED WORKSFORME
Product: PySide
Classification: Unclassified
Component: QtCore
: 0.4.2
: PC MS Windows XP/Vista/7
: P3 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2010-11-12 04:30 EET by Alberto Soto
Modified: 2010-12-20 11:26 EET (History)
8 users (show)

See Also:


Attachments
unit test (399 bytes, text/x-python)
2010-11-19 19:34 EET, renato filho
Details
Example script that tries to get widgets from running application (154 bytes, text/plain)
2010-11-22 11:09 EET, Alberto Soto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alberto Soto 2010-11-12 04:30:25 EET
Working with python (2.5) and PySide (0.4.2)

When scripting for a Qt run application, using the
QtGui.QApplication.allWidgets () returns all application widgets. But
customized widgets (e.g. MainWindow that inherits from QMainWindow) objects are
identified as QWidget objects by the interpreter, and so acces to subclass
implemented methods is blocked (even by using static class methods because
instance name is checked).



Original thread with longer description at:
http://lists.openbossa.org/pipermail/pyside/2010-November/001387.html
Comment 1 renato filho 2010-11-19 19:34:17 EET
I created a simple unit test to try reproduce this error, but my test works.
Can you check this and verify if you are doing some different?

Thanks
Comment 2 renato filho 2010-11-19 19:34:38 EET
Created attachment 143 [details]
unit test
Comment 3 renato filho 2010-11-19 19:35:58 EET
I will mark as worksforme but feel free to reopen the bug if you find a way to
reproduce the error e a new test case.
Comment 4 Alberto Soto 2010-11-22 07:31:31 EET
We have also tried to come up with a unitary test that reproduces the bug
but have not had much luck. My first test was similar to yours and seems
to work fine. The newt test used the SuperHybrid example from 
http://lynxline.com/superhybrids-part-2-now-qt-pyside/
using the console to launch a 2nd script that tried to recuperate all
widgets, but not bug.

I think the problem is that in my actual application:
1.- A big C++ program (.exe) is launched and it is this program that 
launches an embedded Python interpreter. 
2.- It is trough this interpreter that I try and recuperate widgets from the
C++ application. 

But we can't come up with a simple unitary version to test this (specially
the embedded Python part).

Do any ideas come to mind to test this?
If not, I just though you should know abut this behavior...
Comment 5 renato filho 2010-11-22 10:39:14 EET
This problem normally happens when the PyObject was destroyed before
the c++ class. This can be a bug on PySide.

Check for these errors:

* Try check if in some point you remove the last ref from PyObject
related to MainWindow object.
* Make sure you keep a reference to PyObject live.
* Check before leave a scope where the PyObject live, if this have a
extra reference to keep the object alive.
Comment 6 Alberto Soto 2010-11-22 11:09:46 EET
Created attachment 150 [details]
Example script that tries to get widgets from running application

We actually have no "original" reference to the application or any of their
widgets. As I said before, the python script is launched from an embedded
interpreter. I am attaching the example script that uses
QtGui.QApplication.allWidgets () to get access to all application widgets. 
The C++ application is a static .exe from C++ source code.

After running the script, part of the print is something like:
...
<PySide.QtGui.QWidget object at 0x0DAF5F00> AME
<PySide.QtGui.QWidget object at 0x0DAF5F20> 
<PySide.QtGui.QWidget object at 0x0DAF5F40> Image order popup menu
<PySide.QtGui.QRubberBand object at 0x0DAF5F60> qt_rubberband
<PySide.QtGui.QToolButton object at 0x0DAF5F80> 
<PySide.QtGui.QToolButton object at 0x0DAF5FA0> 
<PySide.QtGui.QToolButton object at 0x0DAF5FC0> 
<PySide.QtGui.QStatusBar object at 0x0DAF5FE0> 
<PySide.QtGui.QWidget object at 0x0DAFD020> cross result view
<PySide.QtGui.QWidget object at 0x0DAFD040> qt_dockwidget_floatbutton
<PySide.QtGui.QDockWidget object at 0x0DAFD060> External Variables
...
...

Where we know that the QMainWindow corresponds to the widget named 'AME',
though here it is identified as a QWidget.


Hope this makes it clearer. Maybe it is not a bug but simply a 'lack of
information' to the interpreter? so that it does not 'recognize' the objects
and defaults to a QWidget.
Comment 7 Hugo Parente Lima 2010-12-20 11:26:07 EET
Closign bugs after release of 1.0.0 beta2.