Thanks guys, I already tried Stephane and now Camillo's suggestion with debug morph and works like a charm :) . Definetly makes my life a lot easier.
btc self halt inserts a breakpoint to your code, so that execution stops there and debugger pops up. I find all this highly fascinating because its an area of coding that deeply interests me. Even when I don't code I love reading Pharo code, its so nice :) On Fri, Nov 1, 2013 at 7:13 PM, <b...@openinworld.com> wrote: > ** > Camillo Bruni wrote: > > On 2013-11-01, at 16:44, b...@openinworld.com wrote: > > > > kilon alios wrote: > > > About the problem to recreate it all it takes is a demo := AthensDemoMorph > new openInWorld . It opens the morph with the Athens grey box, I save the > image , close pharo, open pharo which reloads the image automagically and > BOOM Red Box of Doom :) My other tries also are based on AthensDemoMorph > since I cant find documentation to do things differently. > > So lets get to the questions > > 6) Also why there is a Red Box of Doom in the first place ? > > > > See #drawErrorOn: call from... > > Morph>>fullDrawOn: > self visible ifFalse: [^ self]. > (aCanvas isVisible: self fullBounds) ifFalse:[^self]. (self hasProperty: > #errorOnDraw) ifTrue:[^self drawErrorOn: aCanvas]. [ > "calls to each Morph's drawing stuff" > ] on: Error do: > [:err | > "Smalltalk at: #morphDebugOnce ifPresent: [ Smalltalk remove: > #morphDebugOnce. self halt ]. > self setProperty: #errorOnDraw toValue: true. > self setProperty: #drawError toValue: err freeze. > ^ self drawErrorOn: aCanvas ] > --------------- > In the past I have successfully debugged a morph by adding something like the > commented line. Although I can't quite remember if 'self halt' is correct. > Perhaps it should be 'err raise'. Perhaps others with more experience of > the debugger internals can comment. > From a workspace just evaluate 'Smalltalk at: #morphDebugOnce put: #anything' > before opening the morph. Or if the morph is already open and you have a > reference theMorph, then you can try 'theMorph setProperty: #errorOnDraw > toValue: false' to cause the bad morph code to run again. You can get a > reference to an existing morph by enabling 'Create textual references to > dropped morphs' from the window menu of a Workspace - then from the window > menu select 'inspect variables' > > Now what would be really interesting is if in place of my commented line, the > debugging context of the error was serialized using Fuel to a variable and > then clicking on the red-square-of-death brought up a debugger on that. > Something like this... > > Morph>>fullDrawOn: > self visible ifFalse: [^ self]. > (aCanvas isVisible: self fullBounds) ifFalse:[^self]. (self hasProperty: > #errorOnDraw) ifTrue:[^self drawErrorOn: aCanvas debugOn: (self property: > #drawError) ]. [ > "calls to each Morph's drawing stuff" > ] on: Error do: > [:err | > self setProperty: #errorOnDraw toValue: true. > self setProperty: #drawError toValue: (Fuel > serializedDebuggingContextOf: err. "***". > ^ self drawErrorOn: aCanvas ] > "*** Disclaimer: I haven't used Fuel yet, so I don't have the faintest idea > what the proper method here should be." > > > You have in the halo menu an entry "debug drawing error" which does what you > want. As you can see there is already the line: > > > self setProperty: #drawError toValue: err freeze. > > > which serializes the whole error (no need to use fuel as long as you stay in > the image...). > > > Thats brilliant! I think thats new since last time I had to debug a > morph. I did see 'err freeze' in passing just earlier and wonder. > However the functionality is a bit hidden. To make it more obvious, > perhaps #drawErrorOn: could be modified as follows... > > self valueOfProperty: #drawError ifPresentDo: [ :error| | trace > stringBounds | > trace := String streamContents: [ :s| error signalerContext > shortDebugStackOn: s]. > trace := 'Use Halos>Debug>debug drawing error' , String cr , trace. > -------------------- > > btw kilon, you can experiment with that by adding a '1/0' to > EllipseMorph>>drawOn: > and evaluating (EllipseMorph new extent: 300@300) openInWorld. > > cheers -ben > > >