Skip to content

Commit

Permalink
Avoid crash in GitHub integration script installUpdates
Browse files Browse the repository at this point in the history
  • Loading branch information
jvuletich committed Jul 28, 2024
1 parent 5a1601b commit b6f8222
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
'From Cuis7.1 [latest update: #6539] on 28 July 2024 at 3:50:15 pm'!

!Behavior methodsFor: 'enumerating' stamp: 'jmv 7/28/2024 15:44:50'!
allInstancesDoAlt: aBlock
"Evaluate aBlock with each of the current instances of the receiver."
"Alternative implementation of #allInstancesDo:
iterating using #someInstance / #nextInstance.
Use with care."

| inst next |
"Because aBlock might change the class of inst (for example,
using become:), it is essential to compute next before aBlock value: inst."
inst := self someInstance.
[inst == nil] whileFalse:
[next := inst nextInstance.
aBlock value: inst.
inst := next].! !

!Behavior methodsFor: 'enumerating' stamp: 'jmv 7/28/2024 15:45:08'!
allSubInstancesDoAlt: aBlock
"Evaluate the argument, aBlock, for each of the current instances of the
receiver and all its subclasses."
"Alternative implementation for #allSubInstancesDo:
iterating using #someInstance / #nextInstance.
Use with care."

self allInstancesDoAlt: aBlock.
self allSubclassesDo: [:sub | sub allInstancesDoAlt: aBlock].! !


!SystemDictionary methodsFor: 'snapshot and quit' stamp: 'jmv 7/28/2024 15:45:56'!
snapshot: save andQuit: quit embedded: embeddedFlag clearAllClassState: clearAllStateFlag
"This is the main method for image save and / or quit.
See senders."
"WARNING: Current process will be killed. UI Process will be restarted"
"Mark the changes file and close all files as part of #processShutdownList.
If save is true, save the current state of this Smalltalk in the image file.
If quit is true, then exit to the outer OS shell.
The latter part of this method runs when resuming a previously saved image. This resume logic
checks for a document file to process when starting up."
"
To test the full cleanup and startup procedures, evaluate:
Smalltalk snapshot: false andQuit: false embedded: false clearAllClassState: true
To test the cleanup done when saving the image, evaluate:
Smalltalk snapshot: false andQuit: false embedded: false clearAllClassState: false
"
| activeProc |
activeProc := Processor activeProcess.
[
| isARealStartup guiRootObject guiRootObjectClass |
save not & quit
ifTrue: [ (SourceFiles at: 2) ifNotNil: [ :changes |
ChangesInitialFileSize ifNotNil: [ changes truncate: ChangesInitialFileSize ]]]
ifFalse: [ self logSnapshot: save andQuit: quit ].
clearAllStateFlag ifTrue: [
TranscriptWindow allInstancesDoAlt: [ :each |
each isInWorld ifTrue: [ each delete.]].
UISupervisor ui tearDownDesktop.
Transcript logToFile: false ].
ActiveModel flushEventSystem.
self processShutDownList: quit.
"These could be moved to some #shutDown"
self stopLowSpaceWatcher.
WeakArray stopFinalizationProcess.
ProcessorScheduler stopBackgroundProcess.
"Stuff needed to relaunch UI on startup"
guiRootObjectClass := UISupervisor ui class.
"Replace with this to create a new world at startup after 'saveAsNewVersion'"
guiRootObject := clearAllStateFlag ifFalse: [ UISupervisor ui ].

UISupervisor stopUIProcess.
activeProc isTerminated ifFalse: [ activeProc terminate ].
guiRootObject ifNotNil: [ guiRootObject releaseCachedState ].
clearAllStateFlag ifTrue: [
Processor processesDo: [ :p |
(p name = 'Formerly: Morphic UI') ifTrue: [ p terminate ]]].
MorphicCanvas allSubInstancesDoAlt: [ :c |
(c ownerProcess notNil and: [c ownerProcess isTerminated]) ifTrue: [
c releaseEngine ]].

"Clean Globals"
self at: #Sensor put: nil.
self closeSourceFiles.
self at: #SourceFiles put: nil.
self allClassesDo: [ :cls |
cls releaseClassCachedState ].
clearAllStateFlag ifTrue: [
self allClassesDo: [ :cls |
cls releaseClassState ]].
"To keep cleaning stuff that shouldn't be saved..."
clearAllStateFlag ifTrue: [
Transcript clear.
"Enable this call to actually see the image clean report."
false ifTrue: [self printStuffToCleanOnImageSave]].
"Do image save & quit as apropriate"
(Cursor cursorAt: #writeCursor) activateCursor.
save
ifTrue: [
"The snapshot primitive answers false if it was just called to do the snapshot.
But image startup is resumed by returning (again) from the primitive, but this time answering true."
isARealStartup := embeddedFlag
ifTrue: [ self snapshotEmbeddedPrimitive ]
ifFalse: [ self snapshotPrimitive ]]
ifFalse: [ isARealStartup := false ].
quit & (isARealStartup == false) ifTrue: [ self quitPrimitive ].

"If starting from absolute scratch, this would be a good time to recreate Global names"
self at: #Sensor put: nil.
self at: #SourceFiles put: (Array new: 2).
self logStartupDebugAid: 'To #openSourceFiles'.
self openSourceFiles.
"Here, startup begins!! (isARealStartup might be nil)"
self logStartupDebugAid: 'To #initClassCachedState'.
self allClassesDo: [ :cls | cls initClassCachedState ].
self logStartupDebugAid: 'To #doStartUp:'.
self doStartUp: isARealStartup == true.
self logStartupDebugAid: 'To #spawnNewMorphicProcessFor: ', guiRootObject printString.
UISupervisor spawnNewMorphicProcessFor: (guiRootObject ifNil: [ guiRootObject := guiRootObjectClass newWorld ]).
isARealStartup == true
ifTrue: [
self logStartupDebugAid: 'To #restoreLostChangesIfNecessary'.
self restoreLostChangesIfNecessary ].
clearAllStateFlag ifTrue: [
UISupervisor whenUIinSafeState: [
self logStartupDebugAid: 'To #recreateDefaultDesktop'.
guiRootObject recreateDefaultDesktop; restoreDisplay ]]
ifFalse: [
UISupervisor whenUIinSafeState: [
self logStartupDebugAid: 'To #restoreDisplay'.
guiRootObject restoreDisplay ]].
isARealStartup == true
ifTrue: [
"If system is coming up (VM and image just started)"
UISupervisor whenUIinSafeState: [
self logStartupDebugAid: 'To #readAndApplyUserPrefs'.
self readAndApplyUserPrefs.
self logStartupDebugAid: 'To #processCommandLineArguments'.
self processCommandLineArguments.
self logStartupDebugAid: 'To #launchApp'.
AppLauncher launchApp ]]
ifFalse: [
"If we are just saving the image"
UISupervisor whenUIinSafeState: [
self logStartupDebugAid: 'To #readAndApplyUserPrefs'.
self readAndApplyUserPrefs ]].
"Now it's time to raise an error"
isARealStartup ifNil: [ self logStartupError: 'Failed to write image file (disk full?)' ]
]
forkAt: Processor timingPriority - 1
named: 'Startup process'.! !

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'From Cuis7.1 [latest update: #6539] on 28 July 2024 at 3:50:38 pm'!

!VectorCanvas methodsFor: 'private' stamp: 'jmv 7/28/2024 13:48:42'!
releaseEngine
super releaseEngine.
boundsFinderCanvas notNil ifTrue: [
boundsFinderCanvas releaseEngine ].
auxBitBltEngine := nil.! !


!BitBltCanvas methodsFor: 'private' stamp: 'jmv 7/28/2024 13:48:49'!
releaseEngine
super releaseEngine.
boundsFinderCanvas notNil ifTrue: [
boundsFinderCanvas releaseEngine ].! !

0 comments on commit b6f8222

Please sign in to comment.