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 868 - Returning color value from styleHint() hangs application
: Returning color value from styleHint() hangs application
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: QtGui
: 1.0.2
: PC Linux
: P2 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2011-05-30 07:22 EEST by Eric P. Mangold
Modified: 2011-06-22 20:14 EEST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric P. Mangold 2011-05-30 07:22:33 EEST
QStyle.styleHint() is called at various times to get values for the given style
hint.

In particular I am trying to change the color of the grid lines of a
QTableWidget. For example:

class MyStyle(QCommonStyle):
    def styleHint(self, hint, option, widget, returnData):
        if hint == QStyle.SH_Table_GridLineColor:
            print "here"
            return QColor("red").rgba()
        return QCommonStyle.styleHint(self, hint, option, widget, returnData)

This crashes in a big way (well, just hangs, actually)... app is unresponsive
and can't be closed via he window manager. Reproducible with PySide 1.0.2 on
Windows 7 and Linux.

This same usage of Qt works perfectly from C++, so it must be something with
the bindings.

I've made full sample programs in C++ (working) and Python (not working) here:

http://teratorn.org/code/pyside-stylehint-bug/

Download the individual files or "darcs get <url>"

Let me know if I can be of further assistance. Would like to get this resolved.
Cheers
Comment 1 Luciano Wolf 2011-05-30 16:30:48 EEST
Thank you for reporting. Marking as P2 (it crashes).
Comment 2 renato filho 2011-06-02 22:32:14 EEST
The main problem here is about c++ and Python conversions.

The return value of QColor.rgb() is a unsigned int.
The return of QCommonStyle.styleHint() is a integer.

For shiboken a unsigned int does not fit in a integer, then shiboken skip the
conversion and return 0 in the styleHint convertion. (this is necessary because
this styleHint is a virtual function).

To fix this problem I recommend you to subtract 2^31 from your value, this will
make the unsigned int fit in the integer return.

Eg:
     return int(QColor("red").rgba() - 2**31)

BTW I commit a new code on generator which will print a warning about that in
virtual functions.

commit 45692a4aca5ce09bc7623cf6483024894b1e7e7d
Author: Renato Filho <renato.filho@openbossa.org>
Date:   Thu Jun 2 13:09:03 2011 -0300
Comment 3 renato filho 2011-06-22 20:14:12 EEST
release 1.0.4