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 116 - QHttp doesn't store the reference to a QFile
: QHttp doesn't store the reference to a QFile
Status: CLOSED WONTFIX
Product: PySide
Classification: Unclassified
Component: QtNetwork
: HEAD
: All All
: P5 normal
Assigned To: Lauro Moura
:
: 123
:
  Show dependency treegraph
 
Reported: 2010-01-08 13:52 EET by Tomi Pieviläinen
Modified: 2010-08-13 11:20 EEST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomi Pieviläinen 2010-01-08 13:52:52 EET
Steps to reproduce:
file =  QtCore.QFile(QtCore.QString("foobarbaz"))
self.http.get(url, file)

Expected outcome:
QHttp downloads the url into the file.

Actual outcome:
Segfault.

Workaround:
Use self.file =  QtCore.QFile(QtCore.QString("foobarbaz")) within a class so
that the file is not garbage collected.
Comment 1 Lauro Moura 2010-01-09 15:46:26 EET
Actually not holding a reference is not a bug. As stated in the Qt
documentation for QHttp.get:

"Make sure that the to (The QIoDevice argument) pointer is valid for the
duration of the operation (it is safe to delete it when the requestFinished()
signal is emitted)."

So, you have to make sure it is not garbage collected.

The same problem happens in C++ with pure Qt. QHttp stores the pointer and if
it is deleted elsewhere it'll end up getting a segfault.

I can't see a way to avoid the segfault. Unless there is one, I propose to
resolve as invalid.
Comment 2 Tomi Pieviläinen 2010-01-10 06:20:51 EET
Hm. I understand that the behavior is consistent with plain Qt, but I'd still
say that it surprises programmers with Python background (at least it did
surprise me). In pure Python libraries the file would not be garbage collected,
as the QHttp still holds a reference.

I'm not quite sure what is the main goal of PySide; Pythonized version of Qt or
enabling the C api in Python? Both are valid goals, but I was hoping that
PySide would choose the first target, unlike PyQt (which is mostly unknown to
me too, so I might have misunderstood).
Comment 3 Lauro Moura 2010-01-11 11:09:05 EET
(In reply to comment #2)
> Hm. I understand that the behavior is consistent with plain Qt, but I'd still
> say that it surprises programmers with Python background (at least it did
> surprise me). In pure Python libraries the file would not be garbage collected,
> as the QHttp still holds a reference.
> 
> I'm not quite sure what is the main goal of PySide; Pythonized version of Qt or
> enabling the C api in Python? Both are valid goals, but I was hoping that
> PySide would choose the first target, unlike PyQt (which is mostly unknown to
> me too, so I might have misunderstood).

Makes sense, but we should make sure it would be decref'd when the QHttp is
deleted.

So, one way is to set the QIODevice a child of the QHttp.

Question: Can someone do multiple get() calls? When the request is finished,
shouldn't the reference be released? Or will this reference be held
indifinitely?

Anyway, I'm marking this as assigned.
Comment 4 Lauro Moura 2010-02-04 14:34:25 EET
Adding dependency on 123
Comment 5 Hugo Parente Lima 2010-05-19 18:02:50 EEST
To change the behaviour of QHttp we need a PSEP, because there are a lot of
other classes in Qt with the same pattern, so a PSEP would dictate how to deal
with all those use cases.

Btw, a Igree that on python we need to store a reference to a QFile, but we
can't fix it just on QHttp, we must have a uniform behaviour on all classes
following these pattern. so I'm changing the status of this bug to WONTFIX.