Re: QWebEnginePage.print() raises SIGSEGV

Florian Bruhin <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <[email protected]>
On Mon, Apr 08, 2019 at 01:31:45PM -0300, Julio César Gázquez wrote:
> It results in the following, both in PyQt 5.12.1 from wheel and 5.10.1
> from Ubuntu repos: [...]

The Qt docs for QWebEnginePage::print say:

    It is the users responsibility to ensure the printer remains valid until
    resultCallback has been called.

So you'll need to make sure to keep a reference to the dialog (or the printer)
until the callback is called - for example, by using a nested function:

    def print_page():
    
        def cleanup(_success):
            dialog.deleteLater()
    
        dialog = QtPrintSupport.QPrintDialog(w)
        if dialog.exec_() == QtPrintSupport.QPrintDialog.Accepted:
            page.print(dialog.printer(), cleanup)

Florian

-- 
https://www.qutebrowser.org | [email protected] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEE4E5WAAJAG47w528KkW6wyP1VoHIFAlyrfw4ACgkQkW6wyP1V
oHKFxQ//RIfaXteJDJMiSQT/8LQWLyvg5NTJTHQAJyjcXyEvLbD5tPUTF+Uu8OkO
tf1VrMR6v38+RQR17fYZjPfkYFakJg1ZK6c76Sh8WdDQhnrmibQ4G/WQRKq8ze/q
6QSPhWN54JDJMB+Hi/BqZznUutFs1ADonz0lxWoqIrHYMY0LbxC768FwzrZt3HOO
cCSu1IaMQcPv6Hqwx7yGad0Io5iss6w7f2YZ2nE4F3MBd/vugRKoSeD6oCs8bKEm
wgZnX/EyFgSsfymcbkW01hLTv/YDVYCEF4x77MMBja3crIJWAJZs/3/htOIOy8AW
bnbddVoLkWifw4oJ1V2XQXgrq8lepClcCYnu8bTC7RC9OHUtyaTF78GpToueTjRZ
+yd52WDy5Dg0Q10Cw7cJnftHidvd0ELJWGLMuBA/ZOG0nl1RC/y/ZNuL5iCULSvO
YgDo4KUCAMjtSCxpK0kg+MrAFudfZVUMdZuJbeoPbFZDET0sVgmsYiLjDBlgaeYX
rNlJoflPgR+53ripnhMOr14rvmSY/dg4N1EILT2AZb1zDXE9iDfzAnP/l3hmvBZd
XbAvDw8Mnpbi8iYW4YAObhBbN6oIieF8PkDEYx+04tDKeDj0Bl/14+GaDygQYOeS
jl3kk0Z2UoJtzViHdN1+ZhPtnmbsFFGsDhoC/j/i3BGLMLhjw/M=
=Y7aQ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.