[squeak-dev] The Inbox: System-lrnp.1362.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Jun 17 03:41:58 UTC 2022

A new version of System was added to project The Inbox:

==================== Summary ====================

Name: System-lrnp.1362
Author: lrnp
Time: 16 June 2022, 9:41:53.909823 pm
UUID: 54ddffc8-4493-44ca-9249-544be1acfb97
Ancestors: System-eem.1361

fix loading preferences from disk

If a preference file is saved and then loaded in an image that lacks a given class, preference loading should not fail just because that class is gone now.

This is only safe to do because the preferences file doesn't need that class to load successfully, and having a nil for that instance variable is okay.

=============== Diff against System-eem.1361 ===============

Item was changed:
  ----- Method: Preferences class>>loadPreferencesFrom: (in category 'initialization - save/load') -----
  loadPreferencesFrom: aFile
  	| stream params dict desktopColor patternsToIgnore |
  	patternsToIgnore := #('*updateMapName' '*defaultUpdateURL').
  	stream := ReferenceStream fileNamed: aFile.
+ 	[params := stream next]
+ 		on: Error
+ 		do: [:ex |
+ 			((ex messageText beginsWith: 'Global "') and: [ex messageText endsWith: '" not found'])
+ 				ifFalse: [ex pass]
+ 				ifTrue: [
+ 					Transcript showln: 'Preference for undefined class ', (ex messageText findTokens: '"') second.
+ 					ex signalerContext return: nil]].
- 	params := stream next.
  	self assert: (params isKindOf: IdentityDictionary).
  	params removeKey: #PersonalDictionaryOfPreferences.
  	dict := stream next.
  	self assert: (dict isKindOf: IdentityDictionary).
  	desktopColor := stream next.
  	stream close.
  	dict rehash. "See http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-December/217817.html"
  	dict keys
  		reject: [:key | patternsToIgnore anySatisfy: [:pattern | pattern match: key]]
  		thenDo: [:key | | value |
  			value := dict at: key.
  			(self preferenceAt: key ifAbsent: [nil]) ifNotNil:
  				[:pref | [pref preferenceValue: value preferenceValue]
  					on: Deprecation do: [ : err | "Ignore preferences which may not be supported anymore."]]].
  	params keysAndValuesDo: [ :key :value | self setParameter: key to: value ].
  	Smalltalk isMorphic
  		ifTrue: [ Project current world fillStyle: desktopColor ]
  		ifFalse: [ self desktopColor: desktopColor. ScheduledControllers updateGray ]!

More information about the Squeak-dev mailing list