Skip to content

Commit

Permalink
Merge pull request pharo-graphics#632 from pharo-graphics/CleanupEven…
Browse files Browse the repository at this point in the history
…tDispatching

Clean ups in events, space and universe
  • Loading branch information
tinchodias authored Oct 24, 2024
2 parents 7862e66 + f491f6e commit 0d23168
Show file tree
Hide file tree
Showing 38 changed files with 212 additions and 1,127 deletions.
6 changes: 3 additions & 3 deletions src/Bloc-DevTool/BlBenchmarkConsole.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ BlBenchmarkConsole >> listenSpace: aSpace [
lastTime := aSpace time now.
frames := 0.
framesLimit := 120.
aSpace eventDispatcher addEventHandler:
aSpace addEventHandler:
(BlEventHandler on: BlSpaceRenderEndEvent do: [ :evt |
frames := frames + 1.
frames % framesLimit = 0
Expand All @@ -86,11 +86,11 @@ BlBenchmarkConsole >> listenSpace: aSpace [
lastTime := evt end.
frames := 0 ].
self renderTime: (evt end - evt start) ]).
aSpace eventDispatcher addEventHandler:
aSpace addEventHandler:
(BlEventHandler on: BlSpaceEventsProcessedEvent do: [ :evt |
self eventProcessingTime: (evt end - evt start).
]).
aSpace eventDispatcher addEventHandler:
aSpace addEventHandler:
(BlEventHandler on: BlSpaceLayoutEndEvent do: [ :evt |
self layoutTime: (evt end - evt start).
])
Expand Down
2 changes: 1 addition & 1 deletion src/Bloc-Tests/BlHostPulseLoopTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ BlHostPulseLoopTest >> testOpeningAnSpaceDeferingAnErrorKeepsLoopRunning [
aSpace show.

logger := MemoryLogger new.
logger runFor: BlParallelUniverseErrorDuringPulse during: [
logger runFor: BlParallelUniverseErrorDuringPulseSignal during: [
aSpace universe defer: [ 1 error: 'I am the debugger to kill' ].
[aSpace universe hasDeferredActions] whileTrue: [
100 milliSeconds wait
Expand Down
23 changes: 0 additions & 23 deletions src/Bloc-Tests/BlSpaceEventTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,6 @@ BlSpaceEventTest >> testSpaceClosed [
self assert: count equals: 1
]

{ #category : #tests }
BlSpaceEventTest >> testSpaceDestroyed [

| events |
events := OrderedCollection new.

space
addEventHandlerOn: BlSpaceClosedEvent
do: [ events add: #closed ].
space
addEventHandlerOn: BlSpaceDestroyedEvent
do: [ events add: #destroyed ].

space show.
self waitPulses.
self assert: events size equals: 0.

space close.
self waitPulses.
self assert: events size equals: 2.
self assert: events asArray equals: #( closed destroyed )
]

{ #category : #tests }
BlSpaceEventTest >> testSpaceShown [

Expand Down
17 changes: 8 additions & 9 deletions src/Bloc/BlElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3933,16 +3933,15 @@ BlElement >> whenLayoutedDo: aBlock [

{ #category : #'geometry hooks' }
BlElement >> whenLayoutedDoOnce: aBlock [
"As an example of use, imagine you need to get the actual size of an element.
"Evaluate block passed as argument after the layout applied.
As an example of use, imagine you need to get the actual size of an element.
The size is computed by the layout.
Thus, if one need to get the size of an element one have to be sure that its layout applied.
This is the purpose of #whenLayoutedDoOne: (when layout applied do once) which intention is to run
the block passed as argument only one time just after the layout applied.
** notice ** that my use is not encouraged except for debugging or for particular purposes
ouside usual Bloc coding
"
self when: BlElementLayoutComputedEvent doOnce: [ :event | aBlock cull: event ].
Thus, if one need to get the size of an element one have to be sure that its layout applied."

^ self
addEventHandlerOn: BlElementLayoutComputedEvent
doOnce: aBlock
]

{ #category : #'api - bounds' }
Expand Down
6 changes: 6 additions & 0 deletions src/Bloc/BlHeadlessHostSpace.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ BlHeadlessHostSpace >> isResizable [
^ true
]

{ #category : #testing }
BlHeadlessHostSpace >> isValid [

^ true
]

{ #category : #'host space - testing' }
BlHeadlessHostSpace >> isVisible [
"Return true if underlying window is shown, false otherwise.
Expand Down
6 changes: 6 additions & 0 deletions src/Bloc/BlHost.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Class {
#category : #'Bloc-Universe - Host'
}

{ #category : #testing }
BlHost class >> hasUniverse [

^ BlParallelUniverse existsForHost: self
]

{ #category : #'api - lifecycle' }
BlHost class >> isRunning [
^ self subclassResponsibility
Expand Down
4 changes: 2 additions & 2 deletions src/Bloc/BlHostPulseLoop.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ BlHostPulseLoop >> loopIteration [

[
pulseStartMS := Time millisecondClockValue.
universe := BlParallelUniverse forHost: hostClass.
universe := hostClass universe.
universe pulse.
pulseDurationMS := Time millisecondClockValue - pulseStartMS.
self waitUntilNextPulse. ]
on: Exception
do: [ :e |
self forceStartNewUIProcess.
self forceStartNewUIProcess.
e pass ].

"Returns true to continue looping"
Expand Down
Loading

0 comments on commit 0d23168

Please sign in to comment.