qoverride question

8 views
Skip to first unread message

dherring

unread,
Mar 14, 2011, 2:47:52 AM3/14/11
to eql-user
I started playing with EQL for real, and qoverride is being
difficult. Details first, question at the end.


Here's the documentation for qoverride in ecl_fun.cpp.

cl_object qoverride(cl_object l_obj, cl_object l_name, cl_object
l_fun) {
/// args: (object name function)
/// Sets a Lisp function to be called on a virtual Qt method. If
the Lisp function returns <code>NIL</code>, the default Qt method will
be called afterwards.<br><br>To remove a function, pass <code>NIL</
code> instead of the function argument.
/// (qoverride edit "keyPressEvent(QKeyEvent*)" (lambda (ev)
(print (qfun ev "key")) nil))


Here's the implementation of the override I tried using (from src/gen/
_main_q_classes.h). From the documentation above, I thought that
(lambda (...) nil) would result in the default createEditor() being
called. Looking at the code, that's not possible.

QWidget* createEditor(QWidget* x1, const QStyleOptionViewItem& x2,
const QModelIndex& x3) const {
void* fun = LObjects::overrideFun(unique, 45);
if(fun) {
const void* args[] = { &x1, &x2, &x3 };
return (QWidget*)qVariantValue<void*>(callOverrideFun(fun, 45,
args));
}
return QAbstractItemDelegate::createEditor(x1, x2, x3);
}


So how does one call "AbstractItemDelegate::createEditor" when that
function has been overridden? Returning nil doesn't do the trick.
Invoking the method inside the override causes infinite recursion.

Have I missed something?

Thanks,
Daniel

Polos Ruetz

unread,
Mar 14, 2011, 4:51:49 AM3/14/11
to eql-...@googlegroups.com
2011/3/14, dherring <dnun...@gmail.com>:

> So how does one call "AbstractItemDelegate::createEditor" when that
> function has been overridden? Returning nil doesn't do the trick.
> Invoking the method inside the override causes infinite recursion.

Thanks for reporting, that's obviously a bug.
I will fix it today.

(Seems that I need to do some real-world project myself, in order to
discover stupid bugs like this one...).

Paul

Polos Ruetz

unread,
Mar 14, 2011, 5:36:55 PM3/14/11
to eql-...@googlegroups.com
2011/3/14, dherring <dnun...@gmail.com>:

> I started playing with EQL for real, and qoverride is being
> difficult.

OK, this is fixed now (in version 11.3.6)
I needed to change the behavior of qoverride, adding a new function:

qcall-default

So, to call the base implementation of a virtual Qt method, simply do
(qcall-default)
inside your overridden function.

All examples and the docu is updated accordingly.

Paul

Polos Ruetz

unread,
Mar 14, 2011, 6:05:08 PM3/14/11
to eql-...@googlegroups.com
2011/3/14, dherring <dnun...@gmail.com>:
> qoverride

Oops, I had to fix a small bug...

Please use version 11.3.7 (not 11.3.6).

Paul

Daniel Herring

unread,
Mar 14, 2011, 8:45:17 PM3/14/11
to eql-...@googlegroups.com

Thanks for the fixes.  Everything seems to work now.  Used commit 160e8c4.

- Daniel
Reply all
Reply to author
Forward
0 new messages