[Wxsqueak] Putting halts in event handlers

Rob Gayvert rtg at rochester.rr.com
Tue Dec 19 16:11:41 UTC 2006


Hi Daniel,

It turns out that this is the worst-case scenario for callbacks. In this 
demo, this method comes from a callback that is triggered by an event 
callback, so there are two return points on the C stack. When the halt 
is encountered, WxEvtHandler class>>checkCallbackException is run, but 
it restores the wrong point on the C stack, crashing the VM.

There are a couple of difficulties here. The exception check could be 
improved to avoid the crash (it should check for the generic case 
first), but then you wind up with a big pile of debugger windows, since 
after restoring the C stack, the calling routine in the wx library 
continues doing its comparisons.

I'm currently working on unifying the two different kinds of callbacks 
in order to avoid this kind of problem. Even then, though, if you put a 
halt inside a Squeak callback method, you're going to get some odd 
behavior, because the callback must be completed back to the wx library. 
Your best bet in this case is to use some old-fashioned logging (e.g., 
Wx logMessage:). Not very Smalltalk-like, but it's safe.

.. Rob


dan wrote:
> Hi Rob
> 
> If I put a halt in the method WxDemoTreeCtrl>>#onCompareItems:item2:, 
> doing something that triggers that handler causes the VM to crash. Is 
> that something you expect at this stage?
> 
> Cheers
> 
> Daniel
> 



More information about the Wxsqueak mailing list