Bloc icon indicating copy to clipboard operation
Bloc copied to clipboard

Execute inUIProcessDo: when even there is no process

Open labordep opened this issue 4 months ago • 7 comments

The method BlElement>>inUIProcessDo: aBlock cannot value block when there is no uiProcess (nil). This is the case when I'm writing basic unit tests. I think it should be great to value block in all cases. This can be use to build from the same way a BlElement inside or outside the graphic tree.

A fix can be:

inUIProcessDo: aBlock
	"Run the supplied block in the UI process.
	If the active process is already the UI process, evaluate immediately. 
	Otherwise, queue up for the next frame."

	| uiProcess |
	self isAttachedToSceneGraph ifTrue: [ 
		self space host uiProcessDo: [ :uiProc | uiProcess := uiProc ] ].

	(uiProcess  isNil or:[ uiProcess = Processor activeProcess ])
		ifTrue: [ aBlock value ]
		ifFalse: [ 
			self enqueueTask: (BlTaskAction new
					 action: aBlock;
					 yourself) ]

labordep avatar Oct 24 '24 09:10 labordep