Bug in QWebEngineProfile::setNotificationPresenter
Florian Bruhin <[email protected]> Thu, 21 May 2020 11:42:06 +0200
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Message-ID | <[email protected]> |
Hi, When running the attached example and clicking "authorize", then "show" 2-3 times, either a segfault or an exception like this will happen: TypeError: 'QWebEngineNotification' object is not callable As a workaround, show_notification_2 can be used instead, which re-registers the callback and makes things work fine. Looking at the implementation of setNotificationPresenter in qwebengineprofile.sip, it does "Py_DECREF(a0);", inside its wrapper, with a0 being the passed function. That seems to be wrong, as the function gets called multiple times with multiple notifications. Compare that to e.g. setCookieFilter in qwebenginecookiestore.sip where the callback isn't DECREF'd. Florian -- [email protected] (Mail/XMPP) | https://www.qutebrowser.org https://bruhin.software/ | https://github.com/sponsors/The-Compiler/ GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc I love long mails! | https://email.is-not-s.ms/
notifications.py
(text/plain, 929 B)
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, QWebEngineProfile
app = QApplication(sys.argv)
view = QWebEngineView()
def handle_feature_permission(origin, feature):
view.page().setFeaturePermission(origin, feature, QWebEnginePage.PermissionGrantedByUser)
view.page().featurePermissionRequested.connect(handle_feature_permission)
def show_notification(notification):
print(notification.message())
def show_notification_2(notification):
QWebEngineProfile.defaultProfile().setNotificationPresenter(show_notification_2)
print(notification.message())
QWebEngineProfile.defaultProfile().setNotificationPresenter(show_notification)
# QWebEngineProfile.defaultProfile().setNotificationPresenter(show_notification_2)
view.load(QUrl("https://www.bennish.net/web-notifications.html"))
view.show()
app.exec_()
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE4E5WAAJAG47w528KkW6wyP1VoHIFAl7GTOsACgkQkW6wyP1V oHLiUhAAiEd7qb1Gr8eJlZuVgaXHl1S30KK7FQQzaX0j/NfyVZnhLjmOeGbAWPRI 4+IVdsykFtfYtDb40gf2Kl6m+e3kyQ8g8WadgkI/Fg7i8EjpkYQI6psFQZgGW7Cm iIKCNfUqkIEsVCuOB7h3xkS5p68QGtr1pr/Ij3B7KfgY1dmfK920Fti4SgDD/uZD wliKZbHT/YAIGC/8/Fwy7PK0cPz7ZptHX+l3U2osU8fGkvB24sAUB+BHfJs7NJxL GYnbP/bdcIUuJmp2gVF91lYZwgXUCUlqsRJwAoCYB4LfPgrshwwzQ/EWtLNs7Dse V2ky8aljUNms+HQACFuxPzvxgX9Uscj1Z45IweOMYNc/C/M96R4yDeroYLL9CdOB PJ1vIniOhRiiGTRdHAQkRVw06EG1i+M2adATS++sRjrVLzS3Lsy9TtLcg661p8hI F+qWb8GYWxf12EKrcc8oMN1FSHrUxV10quGRqZi/a/d2ClRHrK7JPpC3h57ahT1M SLJJHwsCOe7z9Ju/Yz3iihaRQsGWzA//pnM/Xt2BDRI9ZbekHSC1rt7z3czKk0he 4OQf7L7s6h+EFd2nlquF+lVFUWpkrA3DOceX2lFeDau6i9QKjEdeluXNIFnsi1l8 /U8UNp3aAS65/8YRIuil18R/YYhlcAqx9MeUhB8TksrdqR/mUOg= =jLqZ -----END PGP SIGNATURE-----