Open GoogleCodeExporter opened 8 years ago
[deleted comment]
There is a way to call the base class implementation of a method in standard
ECMA
Script. Consider this class 'MyWidget', derived from 'QWidget':
// Constructor of MyWidget, calls constructor of QWidget
function MyWidget(parent) {
QWidget.call(this, parent);
}
// MyWidget is derived from QWidget
MyWidget.prototype = new QWidget();
// MyWidget re-implements the event method and calls
// the event method from QWidget
MyWidget.prototype.event = function(e) {
...
QWidget.prototype.event.call(this, e);
...
}
The problem with this attempt is that the call of the base class implementation
results in an endless recursion. As far as I understand, the event method of the
'QWidget' wrapper class is called, which then checks if there is an 'event'
method
available in class 'MyWidget' and since this is the case, calls it.
A workaround is to 'hide' the 'event' method of MyWidget before calling the
base class implementation:
MyWidget.prototype.event = function(e) {
...
var eventMethod = MyWidget.prototype.event;
MyWidget.prototype.event = undefined;
QWidget.prototype.event.call(this, e);
MyWidget.prototype.event = eventMethod;
...
}
IMHO, the wrappers should be fixed to also work without this workaround.
Original comment by ribbons...@gmail.com
on 8 Apr 2010 at 9:08
Original issue reported on code.google.com by
kentm...@gmail.com
on 18 Nov 2009 at 12:18