[PyQt] QWebEngineUrlRequestInterceptor doesn't work

Florian Bruhin me at the-compiler.org
Mon Jul 11 07:53:20 BST 2016


* redstone-cold <redstone-cold at 163.com> [2016-07-11 13:50:46 +0800]:
> I think ,normally ,once the profile has been set, then the profile should work on subsequent requests, and if you follow this post to change your code
> http://stackoverflow.com/questions/37658772/pyqt5-6-interceptrequest-doesnt-work
> It works as expected.
> 
> 
> I still cannot figure out why the strange behavior happened if we don't assign WebEngineUrlRequestInterceptor() to a variable

Because Qt does not know anything about Python references. It only has
the concept of ownership. The profile doesn't take ownership of the
interceptor (probably so you can use the same interceptor with
multiple profiles?), and Python doesn't know if Qt still needs the
interceptor - so you need to keep a reference it for it not to be
garbage collected.

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160711/d692cffc/attachment.sig>


More information about the PyQt mailing list