[PyQt] a CustomEvent in KTMLPart crashes eventFilter
Jim Bublitz
jbublitz at nwinternet.com
Fri Sep 7 20:45:20 BST 2007
On Friday 07 September 2007 08:00, Jean-Michel Vourgère wrote:
> Hi.
>
> I've been digging into a bug for a few days, now. After upgrading from
> Debian Sarge to Etch, our python application crashes (SEGV) if we install
> an event filter. Attached is a minimal example of the problem.
>
> The application doesn't crash when commenting out the installEventFilter,
> despite the fact it does nothing.
>
> Does any one has a cue?
> I suspect a problem in KHTML sending a signal to a deleted object.
> It could also be that the "void *data" of the QCustomEvent causes problems
> in sip that can't possibly convert its type... Or maybe I'm just doing
> something wrong that will look obvious to an expert ^^
I have no idea what's going on in KHTMLPart that causes the crash - it's not
an easy object to troubleshoot, and does some peculiar things in my
experience with it.
However, it looks like what you want to do is press a key and grab a screen
shot (via some other code, I assume).
The attached should let you do that, and has the added benefit of not
crashing. It actually catches the event twice - probably once from
self.htmlpart.view (), which is a KHTMLView and QScrollView subclass. You can
filter that, or else try attaching an event filter to KHTMLView, but I think
this is easier and more likely to work.
self.htmlpart.view () gives you access to the actual view that paints on the
screen. KParts.BrowserExtension provides other stuff - cut, paste, and link
clicking support (self.htmlpart.browserExtension () returns the part's
extension in the example). It may also be necessary to call
self.htmlpart.partManager () - it has the side effect of creating a part
manager if none exists. If you create actions, do it before instantiating
KHTMLPart (but don't ask me why).
Let me know if this does what you need, or what further problems it causes.
Jim
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testKHTML2.py
Type: application/x-python
Size: 1025 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20070907/e8c3e28e/testKHTML2-0001.bin
More information about the PyQt
mailing list