[squeak-dev] ToolBuilder and corrupt key windows (Was: FATAL PROJECT ERROR: Project was 'HomeProject')

Lauren Pullen drurowin at gmail.com
Thu Jan 27 22:52:37 UTC 2022


Hi Marcel,

On 1/22/22 09:23, Marcel Taeumel wrote:
> ...
> PasteUpMorph>>privateOuterDisplayWorld
> PasteUpMorph>>displayWorld
> [] in MorphicDebugger class>>openOn:context:label:contents:fullView:
> -- and more not shown --
> 
> So we were already trying to open a debugger but failed in layouting an instance of PluggableTextMorphPlus, which has a submorph that was "nil" instead of a morph, which in turn does not understand #ownerChanged.
> 
> Yes, that is a recursive error. Debuggers need to rely on scrollable list and text fields to work. But why is that instance of PluggableTextMorphPlus broken in the first place? Hmm....
I had a chance to do some debugging in the broken image.

The broken morph is from SquotWorkingCopyTest>>testTrackingWorkspaceMorph

I can't say how it became broken, but I did figure out why we got a
recursive error!

When ToolBuilder opens the debugger window it calls
SystemWindow>>beKeyWindow, which sent #lookUnfocused to the defective
Workspace.

I made a little hack to ToolBuilder so a recursive error is less likely
when entering the debugger.  I supplied an initial case where the key
window is corrupt and cannot be visually unkeyed.  This won't affect
normal operations.

How does this look?
-------------- next part --------------
'From Squeak6.0alpha of 20 January 2022 [latest update: #21062] on 27 January 2022 at 3:43:19 pm'!
MorphicModel subclass: #SystemWindow
	instanceVariableNames: 'labelString stripes label closeBox collapseBox paneMorphs paneRects collapsedFrame fullFrame isCollapsed isActive isLookingFocused menuBox mustNotClose labelWidgetAllowance updatablePanes allowReframeHandles labelArea expandBox openingSafely '
	classVariableNames: 'ClickOnLabelToEdit CloseBoxFrame CloseBoxImageFlat CloseBoxImageGradient CollapseBoxImageFlat CollapseBoxImageGradient DoubleClickOnLabelToExpand DragToEdges ExpandBoxFrame ExpandBoxImageFlat ExpandBoxImageGradient FocusFollowsMouse GradientWindow HideExpandButton MenuBoxFrame MenuBoxImageFlat MenuBoxImageGradient ResizeAlongEdges ReuseWindows RoundedWindowCorners TopWindow WindowTitleActiveOnFirstClick WindowsRaiseOnClick '
	poolDictionaries: ''
	category: 'Morphic-Windows'!
Object subclass: #ToolBuilder
	instanceVariableNames: 'parent safely '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'ToolBuilder-Kernel'!

!MorphicDebugger methodsFor: 'initialize' stamp: 'lrnp 1/27/2022 14:46'!
openNotifierNoSuspendContents: msgString label: label

	| builder spec |
	super openNotifierNoSuspendContents: msgString label: label.
	
	builder := ToolBuilder default.
	spec := self buildNotifierWith: builder label: label message: msgString.

	^ ToolBuilder default openSafely: spec! !


!SystemWindow methodsFor: 'initialization' stamp: 'lrnp 1/27/2022 15:05'!
initialize
	"Initialize a system window. Add label, stripes, etc., if desired"

	super initialize.

	self layoutPolicy: ProportionalLayout new.

	self wantsPaneSplitters: true.
	self layoutInset: ProportionalSplitterMorph gripThickness.
	self cellGap: ProportionalSplitterMorph gripThickness.

	self initializeLabelArea.				
	self addCornerGrips.
	self setDefaultParameters.

	allowReframeHandles := true.
	isCollapsed := false.
	paneMorphs := Array new.
	mustNotClose := false.
	updatablePanes := Array new.
	openingSafely := false.

	self initializeKeyboardShortcuts.! !

!SystemWindow methodsFor: 'top window' stamp: 'lrnp 1/27/2022 15:43'!
beKeyWindow
	"Let me be the most important window on the screen. I am at the top and I can have a shadow to get more attention by the user. I am the window that is responsible for window keyboard shortcuts. Also see #isKeyWindow, #activate, and #lookFocused."

	| oldKeyWindow |
	self isKeyWindow ifTrue: [^ self].

	oldKeyWindow := TopWindow.
	TopWindow := self.

	self
		unlockWindowDecorations; "here, because all windows might be active anyway"
		activate; "if not already active, activate now"
		comeToFront. "key windows are on top"

	"Change appearance to get noticed."
	self hasDropShadow: Preferences menuAppearance3d.
	(self valueOfProperty: #borderWidthWhenActive)
		ifNotNil: [:bw | self acquireBorderWidth: bw].

	oldKeyWindow ifNotNil: [:wnd |
		[wnd passivateIfNeeded]
			on: Error
			do: [:e | self openingSafely ifFalse: [e pass]].
		
		"Change appearance to not look prettier than the new key window."
		wnd hasDropShadow: false.
		(wnd valueOfProperty: #borderWidthWhenInactive)
			ifNotNil: [:bw | wnd acquireBorderWidth: bw]].
	
	self currentEvent isKeyboard ifTrue: [
		self currentHand newKeyboardFocus: self defaultFocusMorph].
	
	"Synchronize focus look with position of current hand because any call could have made this window the new key window."
	self updateFocusLookAtHand.! !

!SystemWindow methodsFor: '*ToolBuilder-Morphic-opening' stamp: 'lrnp 1/27/2022 15:19'!
openAsToolSafely
	"Open this window as a tool, that is, honor the preferences such as #reuseWindows and #openToolsAttachedToMouseCursor.

	Try to be careful that opening this window doesn't cause the debugger to open."
	
	openingSafely := true.
	^ self openAsTool! !

!SystemWindow methodsFor: '*ToolBuilder-Morphic-opening' stamp: 'lrnp 1/27/2022 15:42'!
openingSafely

	^ openingSafely ifNil: [false] ifNotNil: [openingSafely]! !


!ToolBuilder methodsFor: 'opening' stamp: 'lrnp 1/27/2022 15:18'!
openSafely: anObject
	"Build and open the object. Answer the widget opened. Try to avoid causing an error while opening. Override me to add support."
	^ self open: anObject! !


!MorphicToolBuilder methodsFor: 'opening' stamp: 'lrnp 1/27/2022 15:20'!
openSafely: anObject
	"Build and open the object. Answer the widget opened. Try to avoid causing an error by building or opening the widget."
	
	^ (self build: anObject) openAsToolSafely! !

Object subclass: #ToolBuilder
	instanceVariableNames: 'parent safely'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'ToolBuilder-Kernel'!
MorphicModel subclass: #SystemWindow
	instanceVariableNames: 'labelString stripes label closeBox collapseBox paneMorphs paneRects collapsedFrame fullFrame isCollapsed isActive isLookingFocused menuBox mustNotClose labelWidgetAllowance updatablePanes allowReframeHandles labelArea expandBox openingSafely'
	classVariableNames: 'ClickOnLabelToEdit CloseBoxFrame CloseBoxImageFlat CloseBoxImageGradient CollapseBoxImageFlat CollapseBoxImageGradient DoubleClickOnLabelToExpand DragToEdges ExpandBoxFrame ExpandBoxImageFlat ExpandBoxImageGradient FocusFollowsMouse GradientWindow HideExpandButton MenuBoxFrame MenuBoxImageFlat MenuBoxImageGradient ResizeAlongEdges ReuseWindows RoundedWindowCorners TopWindow WindowTitleActiveOnFirstClick WindowsRaiseOnClick'
	poolDictionaries: ''
	category: 'Morphic-Windows'!


More information about the Squeak-dev mailing list