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 436 - Using a custom QValidator generates a segfault
: Using a custom QValidator generates a segfault
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: QtGui
: HEAD
: All All
: P3 critical
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2010-10-26 17:16 EEST by Mickaël
Modified: 2010-11-25 17:48 EET (History)
9 users (show)

See Also:


Attachments
Testcase (455 bytes, application/octet-stream)
2010-10-26 17:16 EEST, Mickaël
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mickaël 2010-10-26 17:16:08 EEST
Created attachment 127 [details]
Testcase

I joined a testcase, it works with PyQt4.

Here is a backtrace :
 #0  0xb7f57f6c in ?? () from /usr/lib/libpython2.7.so.1.0
 #1  0xb7fd3629 in Shiboken::BindingManager::resolveType(void*,
Shiboken::SbkBaseWrapperType*) () from /usr/lib/libshiboken.so.0.5
 #2  0xb7fcf22d in Shiboken::SbkBaseWrapper_New(Shiboken::SbkBaseWrapperType*,
void*, bool, bool, char const*) () from /usr/lib/libshiboken.so.0.5
 #3  0xb6c5dcb4 in ?? () from /usr/lib/python2.7/site-packages/PySide/QtGui.so
 #4  0xb5eca357 in QLineControl::finishChange(int, bool, bool) () from
/usr/lib/libQtGui.so.4
 #5  0xb5ecbc13 in QLineControl::insert(QString const&) () from
/usr/lib/libQtGui.so.4
 #6  0xb5ecc979 in QLineControl::processKeyEvent(QKeyEvent*) () from
/usr/lib/libQtGui.so.4
 #7  0xb5ec0635 in QLineEdit::keyPressEvent(QKeyEvent*) () from
/usr/lib/libQtGui.so.4
Comment 1 Mickaël 2010-10-26 17:27:19 EEST
A little note about how PyQt4 handles this (at least, this is what I observed)
:

The doc (
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qvalidator.html#fixup-2
) says :
 * validate should return either (State, QString, int) or (State, int)
 * fixup should return either QString or None

What I experencied is :
 * PyQt4 only accepts (State, int) for validate()
 * PyQt4 only accepts None for fixup()

IMHO, it should simply accept every variant, and PySide should do the same too.
Comment 2 Chris Morgan 2010-11-09 01:56:52 EET
I just ran into this porting a PyQt4 app I've written to PySide; unfortunately
this total inability to use validators is a blocker for me, though I'd like to
switch to PySide. My test case I wrote before looking to see if it had been
reported (as I find it has been) is much the same as Mickaël's. Before properly
realising it was segfaulting before calling the function, I tried returning
State, (State, pos) and (State, input, pos); the second is valid for PyQt4 API
1 and the third for API 2; invalid ones (with PyQt4) write to the console
"TypeError: invalid result type from MyValidator.validate()". In PySide though
I get a crash, validate() never being called.

I'm using Python 2.6 on Ubuntu 10.04, 64-bit, with the PySide PPA 0.4.2
(0.4.2-0pyside1). Unless you want, I won't add a backtrace because it's more or
less the same as Mickaël's one.
Comment 3 Matti Airas 2010-11-09 06:04:26 EET
I agree that validators are a pretty elementary functionality that must work.
Luckily, this bug has already been selected for this sprint and should be taken
care of within the next few days. Stay tuned. :-)
Comment 4 Hugo Parente Lima 2010-11-11 18:34:51 EET
Fixed in commits:

pyside/655219636b1500e82d543914045f4cc7ba7db95f
shiboken/157c00f271b7a7cb963900e7b967070ac0e09c41

PySide now supports the following variants:

State
(State,)
(State, unicode)
(State, unicode, int)

Not having (State,unicode) but having (State,int) and (State,unicode,int) seens
that the optimal element in the middle, just weird and a bit confusing.

Supporting (State, unicode) and (State,int) seens not only confusing but much
more error prone to me, if you miss a cast from str to int you will not be able
notice the error.

PyQt you can return (State,int) only in API1 because it have QStrings and you
can modify them, on API2 they don't have QString, so it must have the (State,
unicode, int) for sure. So when using PyQt use the API2 and the full tuple to
get 100% compatibility with PySide.
Comment 5 renato filho 2010-11-25 17:48:17 EET
released on 1.0.0~beta1