Removing a specific event filter.

19 views
Skip to first unread message

Mark Cox

unread,
Sep 8, 2012, 10:16:38 PM9/8/12
to eql-...@googlegroups.com
G'day,

I would like to implement a function WAIT-UNTIL-CLOSED that blocks until the window is closed. My implementation of it is as follows

(defun wait-until-closed (window)
(qlet ((event-loop (qnew "QEventLoop")))
(qadd-event-filter window |QEvent.Close| (lambda (obj ev)
(qfun event-loop "quit")
nil))
(qfun event-loop "exec")
(qclear-event-filters))
window)

This works, however, it uses the function QCLEAR-EVENT-FILTERS. All that is required is to remove the temporary event filter. Is it possible to add a function QREMOVE-EVENT-FILTER?

I am unsure on how this would work. I think these are the options:

Option 1: Break backwards compatibility by changing QADD-EVENT-FILTER to return an event filter handle instead of the event identifier.

(let ((event-filter (qadd-event-filter ...)))
(unwind-protect
(progn)
(qremove-event-filter event-filter)))

As far as I can tell, EQL and the examples are not impacted by this change. Users of EQL would be if knowing the event-id is important.

Option 2: QADD-EVENT-FILTER returns more than one value.

(multiple-value-bind (event-id event-filter) (qadd-event-filter ...)
(unwind-protect
(progn)
(qremove-event-filter event-filter)))

Again, I don't know how useful the event-id is to people.

Option 3: Remove the exclusion on overriding eventFilter in instances of QObject.

I am not sure on the history of why eventFilter is excluded in the first place.

Thanks
Mark

Polos Ruetz

unread,
Sep 10, 2012, 5:01:10 AM9/10/12
to eql-...@googlegroups.com
2012/9/9, Mark Cox <mark...@gmail.com>:
> Option 3: Remove the exclusion on overriding eventFilter in instances of
> QObject.
>
> I am not sure on the history of why eventFilter is excluded in the first
> place.

I don't remember why I excluded overriding of "eventFilter" initially,
so I just removed the exclusion in "helper/generate.lisp", and it
works fine now.

So, repeating for all:
You can now use QOVERRIDE for QObject::eventFilter(QObject*, QEvent*)
together with QObject::installEventFilter(QObject*).

(The function QADD-EVENT-FILTER is simply more convenient for e.g.
application wide event filters.)

Paul

Mark Cox

unread,
Sep 10, 2012, 7:26:03 AM9/10/12
to eql-...@googlegroups.com
Hi Paul,

On 10/09/2012, at 7:01 PM, Polos Ruetz wrote:

> 2012/9/9, Mark Cox <mark...@gmail.com>:
>> Option 3: Remove the exclusion on overriding eventFilter in instances of
>> QObject.
>>
>> I am not sure on the history of why eventFilter is excluded in the first
>> place.
>
> I don't remember why I excluded overriding of "eventFilter" initially,
> so I just removed the exclusion in "helper/generate.lisp", and it
> works fine now.

Thank you.

Mark

Polos Ruetz

unread,
Sep 15, 2012, 6:37:49 PM9/15/12
to eql-...@googlegroups.com
2012/9/9, Mark Cox <mark...@gmail.com>:
> Option 1: Break backwards compatibility by changing QADD-EVENT-FILTER to
> return an event filter handle instead of the event identifier.

QREMOVE-EVENT-FILTER is now added for consistency (as you suggested).

Paul
Reply all
Reply to author
Forward
0 new messages