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 944 - Segfault on QIcon(None).pixmap()
: Segfault on QIcon(None).pixmap()
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: QtGui
: 1.0.4
: PC Linux
: P3 normal
Assigned To: Hugo Parente Lima
:
:
:
  Show dependency treegraph
 
Reported: 2011-07-23 09:57 EEST by seblin
Modified: 2011-10-20 22:53 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 seblin 2011-07-23 09:57:06 EEST
Trying to get a pixmap, when QIcon was initialized with None, fails with
segfault:

import sys
from PySide import QtGui

ICON = None
#ICON = '/usr/share/pixmaps/firefox.png'

def test_segfault():
    app = QtGui.QApplication(sys.argv)
    icon = QtGui.QIcon(ICON)
    label = QtGui.QLabel()
    print 'Before icon.pixmap()'
    pixmap = icon.pixmap(48, 48)
    print 'After icon.pixmap()'
    label.setPixmap(pixmap)
    label.show()
    return app.exec_()

if __name__ == '__main__':
    sys.exit(test_segfault())


Running the program:

$ python segfault.py
Before icon.pixmap()
Segmentation fault
Comment 1 Marcelo Lira 2011-08-08 22:23:00 EEST
Fixed in commits Shiboken/6b658625 and PySide/1650d802.
Comment 2 renato filho 2011-08-23 00:35:38 EEST
Released on PySide 1.0.6
Comment 3 seblin 2011-08-28 19:13:26 EEST
Hm, I now had the time to test it. The new behaviour seems just to ignore a
given `None`, which seems not to be documented anywhere. A actually thought of
a `TypeError` instead of different behaviour compared to the original (C++)
one. I personally would suggest to change that to an exception, unless there
are good reasons against it.
Comment 4 Hugo Parente Lima 2011-08-29 16:06:05 EEST
(In reply to comment #3)
> Hm, I now had the time to test it. The new behaviour seems just to ignore a
> given `None`, which seems not to be documented anywhere. A actually thought of
> a `TypeError` instead of different behaviour compared to the original (C++)
> one. I personally would suggest to change that to an exception, unless there
> are good reasons against it.

I agree, I TypeError is more feasible since the function doesn't accept null
pointers.
Comment 5 Hugo Parente Lima 2011-10-18 21:57:09 EEST
The fix Marcelo dis already throw a TypeError, the problem with "QIcon(None)"
is that None is convertible to QString, to if you do:

QIcon(None)

is the same as (in C++):

QIcon(QString())

In other words, this bug was fixed in the first time.
Comment 6 Hugo Parente Lima 2011-10-20 22:53:51 EEST
Released on 1.0.8.