Bloc
Bloc copied to clipboard
Execute inUIProcessDo: when even there is no process
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) ]