NewTools icon indicating copy to clipboard operation
NewTools copied to clipboard

Raw inspectiond does not play well with proxies

Open pavel-krivanek opened this issue 3 years ago • 0 comments

Working with Glorp, the new Spec based inspector does not handle proxy objects the same way as the old inspector did.

Method StRawInspection>>#step should not use #= for Array which leads to #= on Proxy level and thus instantiation.

Instead:

step
	| rootNodes allAreEqual |

	rootNodes := self model allInspectorNodes.
	mementoNodes ifNil: [ 
		mementoNodes := rootNodes collect: #mementoValue.
		^ self ].
	allAreEqual := true.
	rootNodes size = mementoNodes size ifTrue: [
		(rootNodes collect: #value) with: mementoNodes do: [ :rn :mn |
			((self isUninstantiatedProxy: rn) and: [self isUninstantiatedProxy: mn])
				ifFalse: [allAreEqual := allAreEqual & (rn = mn)].
		].
	].
	allAreEqual ifTrue: [^self].
	mementoNodes := rootNodes collect: #mementoValue.
	attributeTable updateRootsKeepingSelection: rootNodes

Testing utility in StRawInspection:

isUninstantiatedProxy: anObject

	(anObject class inheritsFrom: AbstractProxy)
		ifFalse: [^false].
	^anObject isInstantiated not

(here, AbstractProxy is a Glorp class, Pharo unfortunatelly does not have a standard message to detect proxy (and it should have one!)

StObjectPrinter class>>#asTruncatedTextFrom: anObject
	
	should call #stDisplayString instead of #displayString

pavel-krivanek avatar May 17 '21 12:05 pavel-krivanek