-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
618-Bloc-Main-Thread-should-be-stopped-and-restarted-in-shutdownstartup #619
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,92 +7,3 @@ Class { | |
], | ||
#category : #'Bloc-Tests-Space' | ||
} | ||
|
||
{ #category : #initialization } | ||
BlSpaceTest >> dirtyAreas [ | ||
^ space dirtyAreas asArray collect: #asRectangle | ||
] | ||
|
||
{ #category : #initialization } | ||
BlSpaceTest >> setUp [ | ||
super setUp. | ||
|
||
space := BlSpace new. | ||
host := BlMockedHost new. | ||
|
||
space host: host. | ||
host createHostSpaceFor: space. | ||
] | ||
|
||
{ #category : #initialization } | ||
BlSpaceTest >> tearDown [ | ||
super tearDown. | ||
|
||
host destroyHostSpaceFor: space. | ||
space host: nil. | ||
host := nil. | ||
space := nil | ||
] | ||
|
||
{ #category : #tests } | ||
BlSpaceTest >> testEnqueueEvent [ | ||
|
||
self skip. | ||
space pulse. | ||
self assert: space pulseRequested not. | ||
|
||
space hostSpace enqueueEvent: | ||
(BlMouseMoveEvent new | ||
position: 20 @ 20; | ||
yourself). | ||
self assert: space pulseRequested. | ||
|
||
space pulse. | ||
self assert: space pulseRequested not | ||
] | ||
|
||
{ #category : #tests } | ||
BlSpaceTest >> testInitialization [ | ||
self skip. | ||
"Host space must not be nil" | ||
self assert: space hostSpace isNotNil. | ||
|
||
"Space must request pulse when just created" | ||
self assert: space pulseRequested. | ||
|
||
"Space must have its whole area being dirty" | ||
self assert: self dirtyAreas equals: { 0@0 extent: space extent } | ||
] | ||
|
||
{ #category : #tests } | ||
BlSpaceTest >> testRender [ | ||
self skip. | ||
self assert: self dirtyAreas equals: { 0@0 extent: space extent }. | ||
self assert: space hostSpace renderCount equals: 0. | ||
self assert: space pulseRequested. | ||
|
||
space pulse. | ||
self assert: self dirtyAreas equals: {}. | ||
self assert: space hostSpace renderCount equals: 1. | ||
self assert: space pulseRequested not. | ||
|
||
space pulse. | ||
self assert: self dirtyAreas equals: {}. | ||
self assert: space hostSpace renderCount equals: 1. | ||
self assert: space pulseRequested not. | ||
|
||
space requestNextPulse. | ||
self assert: space pulseRequested. | ||
space pulse. | ||
self assert: self dirtyAreas equals: {}. | ||
self assert: space hostSpace renderCount equals: 1. | ||
self assert: space pulseRequested not. | ||
|
||
space invalidRect: (BlBounds origin: [email protected] extent: [email protected]) from: space root. | ||
self assert: space pulseRequested. | ||
self assert: self dirtyAreas equals: { 50@70 extent: 300@200 }. | ||
space pulse. | ||
self assert: self dirtyAreas equals: {}. | ||
self assert: space hostSpace renderCount equals: 2. | ||
self assert: space pulseRequested not. | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Class { | ||
#name : #BlSpaceVisibilityTest, | ||
#superclass : #BlParameterizedHostTest, | ||
#category : #'Bloc-Tests-Space' | ||
} | ||
|
||
{ #category : #tests } | ||
BlSpaceVisibilityTest >> testHidingAnOpenSpaceHidesTheWindow [ | ||
|
||
| aSpace | | ||
|
||
Smalltalk vm operatingSystemName = 'unix' ifTrue: [ ^ self skip ]. | ||
|
||
aSpace := self newTestingSpace. | ||
|
||
aSpace show. | ||
self waitTestingOpenedSpaces. | ||
|
||
self assert: aSpace hostSpace isVisible. | ||
|
||
aSpace hide. | ||
|
||
self deny: aSpace hostSpace isVisible. | ||
|
||
] | ||
|
||
{ #category : #tests } | ||
BlSpaceVisibilityTest >> testHidingAndShowingAnOpenSpaceShowsTheWindow [ | ||
|
||
| aSpace | | ||
|
||
Smalltalk vm operatingSystemName = 'unix' ifTrue: [ ^ self skip ]. | ||
|
||
aSpace := self newTestingSpace. | ||
|
||
aSpace show. | ||
self waitTestingOpenedSpaces. | ||
|
||
self assert: aSpace hostSpace isVisible. | ||
|
||
aSpace hide. | ||
|
||
self deny: aSpace hostSpace isVisible. | ||
|
||
aSpace show. | ||
self waitTestingOpenedSpaces. | ||
|
||
self assert: aSpace hostSpace isVisible. | ||
|
||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Class { | ||
#name : #BlStartupShutdownTest, | ||
#superclass : #BlParameterizedHostTest, | ||
#category : #'Bloc-Tests-Space' | ||
} | ||
|
||
{ #category : #running } | ||
BlStartupShutdownTest >> runCaseManaged [ | ||
|
||
^ self runCase | ||
] | ||
|
||
{ #category : #tests } | ||
BlStartupShutdownTest >> testShutdownAndStartupKeepsSpacesInSamePosition [ | ||
|
||
| aSpace | | ||
|
||
hostClass = BlMorphicWindowHost ifTrue: [ ^ self skip ]. | ||
Smalltalk vm operatingSystemName = 'unix' ifTrue: [ ^ self skip ]. | ||
|
||
aSpace := self newTestingSpace. | ||
|
||
aSpace show. | ||
self waitTestingOpenedSpaces. | ||
aSpace position: 100@100. | ||
aSpace extent: 200@200. | ||
|
||
self assert: aSpace position equals: 100@100. | ||
self assert: aSpace extent equals: 200@200. | ||
|
||
aSpace universe stopUniverse. | ||
aSpace universe startUniverse. | ||
|
||
self assert: aSpace position equals: 100@100. | ||
self assert: aSpace extent equals: 200@200. | ||
|
||
] | ||
|
||
{ #category : #tests } | ||
BlStartupShutdownTest >> testShutdownAndStartupKeepsSpacesOpen [ | ||
|
||
| aSpace | | ||
|
||
hostClass = BlMorphicWindowHost ifTrue: [ ^ self skip ]. | ||
Smalltalk vm operatingSystemName = 'unix' ifTrue: [ ^ self skip ]. | ||
|
||
aSpace := self newTestingSpace. | ||
|
||
aSpace show. | ||
self waitTestingOpenedSpaces. | ||
self assert: aSpace isVisible. | ||
|
||
aSpace universe stopUniverse. | ||
aSpace universe startUniverse. | ||
|
||
self assert: aSpace isVisible. | ||
|
||
] | ||
|
||
{ #category : #tests } | ||
BlStartupShutdownTest >> testShutdownAndStartupKeepsSpacesOpenWithInvalidation [ | ||
|
||
| aSpace | | ||
|
||
hostClass = BlMorphicWindowHost ifTrue: [ ^ self skip ]. | ||
Smalltalk vm operatingSystemName = 'unix' ifTrue: [ ^ self skip ]. | ||
|
||
aSpace := self newTestingSpace. | ||
|
||
aSpace show. | ||
self waitTestingOpenedSpaces. | ||
self assert: aSpace isVisible. | ||
|
||
aSpace universe stopUniverse. | ||
aSpace hostSpace invalidate. | ||
|
||
aSpace universe startUniverse. | ||
|
||
self assert: aSpace isVisible. | ||
|
||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,8 @@ Class { | |
'reference', | ||
'iconStencil', | ||
'rootElement', | ||
'userData' | ||
'userData', | ||
'previousVisibleStatus' | ||
], | ||
#classVars : [ | ||
'UniqueIdGenerator' | ||
|
@@ -139,7 +140,10 @@ BlSpace class >> pulseUntilEmptyTaskQueue: aSpace timeout: aDuration [ | |
aSpace universe hasDeferredActions or: [ | ||
(aSpace taskQueue isEmpty or: [ | ||
aSpace time now >= deadline ]) not ] ] | ||
do: [ aSpace pulse ]. | ||
do: [ | ||
"We delegate to the host class also to run a cycle, it is needed when using morphic host, as this can run in the same UI thread blocking everything." | ||
aSpace host runOneCycle. | ||
aSpace pulse ]. | ||
|
||
aSpace pulse. | ||
|
||
|
@@ -864,6 +868,15 @@ BlSpace >> ensureSession [ | |
self onSessionChanged: Smalltalk session | ||
] | ||
|
||
{ #category : #'private - display' } | ||
BlSpace >> ensureWindowOpen [ | ||
|
||
hostSpace ifNotNil: [ | ||
hostSpace isValid ifFalse: [ | ||
host createHostSpaceFor: self. | ||
previousVisibleStatus ifTrue: [ hostSpace open ] ] ] | ||
] | ||
|
||
{ #category : #'event management accessing' } | ||
BlSpace >> eventDispatcher [ | ||
^ eventDispatcher | ||
|
@@ -1480,6 +1493,12 @@ BlSpace >> pulseRequested [ | |
^ nextPulseRequested | ||
] | ||
|
||
{ #category : #'startup - shutdown' } | ||
BlSpace >> rememberVisibleStatus [ | ||
|
||
previousVisibleStatus := self isVisible | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I trust in your solution, but I didn't realize yet why isVisible is not enough, and we need a new flag There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we need to store the flag. Once the real window is destroyed / do not exist in the starting image, the window is always not visible. We need to know how it was before saving the image. Thanks for the review. I tried to avoid it but the space only delegates this behaviour to the real window. |
||
] | ||
|
||
{ #category : #pulse } | ||
BlSpace >> render [ | ||
"Render this space in my host window if it is assigned, otherwise do nothing" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,3 +91,15 @@ BlSpaceManager >> spaces [ | |
|
||
^ spaces | ||
] | ||
|
||
{ #category : #'startup - shutdown' } | ||
BlSpaceManager >> start [ | ||
|
||
spaces do: [ :aSpace | aSpace ensureWindowOpen ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class has the only sends of ensureWindowOpen and rememberVisibleStatus. Maybe previousVisibleStatus flag fits better here in BlSpaceManager instead of BlSpace. It is here where this previousVisibleStatus is stored and restored. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The visible status is of the window (aka the space) if we put the flag in the space manager we need a collection of flags (one per each space). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the review. We need to store the state of the open windows if we want to reopen in the same place. |
||
] | ||
|
||
{ #category : #'startup - shutdown' } | ||
BlSpaceManager >> stop [ | ||
|
||
spaces do: [ :anSpace | anSpace rememberVisibleStatus ] | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to review this change together with #636. Maybe what needed to happen in this case is to attach the space to the universe as if it was a host switch.