Proper fix for random crashes

This commit is contained in:
Kovid Goyal 2018-12-15 13:16:53 +05:30
parent 46c646e49d
commit e4e313f1d6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -127,6 +127,8 @@ class UrlSchemeHandler(QWebEngineUrlSchemeHandler):
def send_reply(self, rq, mime_type, data):
if sip.isdeleted(rq):
return
# make the buf a child of rq so that it is automatically deleted when
# rq is deleted
buf = QBuffer(parent=rq)
buf.open(QBuffer.WriteOnly)
# we have to copy data into buf as it will be garbage
@ -134,9 +136,7 @@ class UrlSchemeHandler(QWebEngineUrlSchemeHandler):
buf.write(data)
buf.seek(0)
buf.close()
buf.aboutToClose.connect(buf.deleteLater)
rq.reply(mime_type.encode('ascii'), buf)
# }}}