in reply to Missing base classes when called from Tk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Missing base classes when called from Tk
by perl-diddler (Chaplain) on Sep 27, 2007 at 11:34 UTC | |
When I said "the routines are called like"...I meant my "key handler routine" is called by Tk with a calling sequence that looks like: "$main_win->handle_key($s, Ev('A'), Ev('K'))", where "$s" is the main "self" data structure/pointer." i.e. The bind for my "handle_key" routine is: From the man page on Tk::callbacks, I see: From my call sequence: "$main_win" -> bind('<Any-KeyPress>', \&handle_key, $s, Ev('A'), Ev('K'));" I'd expect "handle_key" to be entered with the following in '@_': my ($main_win, $s, $EvA, $EvK) = @_; I assume "$main_win (handle of win I'm binding to) to be first, and the other 3 args should taken from my bind statement. I pass the key_handler routine addr to Tk via the bind, but it is from the man pages I get that they are calling &handle_key as being called through the "$main_win" handle. I pass my 1 object (at top level is a singleton, I believe the terminology is) -- that contains the "database" I'm sequencing through. The routine that has the bind statement in it, is passed "$s" ($self), which it passes in a param list to &handle_key. I then try to invoke methods on the "$self" object that is passed in via the parameter list. It is some of those "methods" that the "call" should find in Base classes but isn't (doesn't seem to be searching through the base classes at all).
Did that clarify anything or where I might be using it incorrectly? | [reply] [d/l] [select] |
by Anonymous Monk on Sep 27, 2007 at 16:48 UTC | |
| [reply] |
by perl-diddler (Chaplain) on Sep 27, 2007 at 21:25 UTC | |
None of my "("two or one, since timer is currently 'disabled'")" Tk event handler routines rely on searching @ISA. The handler is in the same "class" (package) as the "bind" statement that is 'binding' it to Tk. As for associating the method's invocation with the correct instance, I only allow 1 instance of an "open database" per program. So any methods called by Tk refer to the 1 program-wide instance (any wonder why global variables in the none OO were so useful?... but also, so constraining). The key handler makes an indirect call (or two). The entire code snipplet (which I plan on simplifying, later, once I get it "working" again -- I started from the linear, working 'proof-of-concept' code that was my first "version" of this program, but bound to '<Any_Keypress>', is this routine: Handle_key is what is making some of the "unfound" calls at this point -- the routines in the "jump table"...but it does not seem the jump table is at fault, since "q" (the quit action) properly calls the _quit function: sub _quit() { $_[0]->write_db(); exit 0; } and fails trying to call "write_db" on exit. "write_db" is a method in a parent class. Regardless of call syntax, Perl isn't searching my @ISA info for parent classes. If I am in the debugger before the "$s->write_db()" statement in "_quit()" and use the debugger's "m" command to print out available methods, it finds the parental method, but not when executed.
Perhaps this is a bug? I.e. shouldn't the debugger be using the same search method as that used during regular execution?
| [reply] [d/l] [select] |