[PyQt] QWebEngineUrlRequestInterceptor doesn't work
redstone-cold
redstone-cold at 163.com
Tue Jul 12 18:15:46 BST 2016
So if Qt does not has ownership of the interceptor , and the interceptor isn't referenced by Python , then it is garbage collected, Right ?
BTW, if we assign a parent to the interceptor(e.g. WebEngineUrlRequestInterceptor(profile)), then it is owned by Qt, therefore won't be garbage collected. I tested it!
在2016年07月11 14时53分, "Florian Bruhin"<me at the-compiler.org>写道:
* 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 --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160713/909caa7b/attachment.html>
More information about the PyQt
mailing list