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

Marcel Taeumel marcel.taeumel at hpi.de
Mon Jun 20 09:23:51 UTC 2022


Hi Lauren --

Hmm... one might think that ReferenceStream needs to take care of such things. Maybe even be configurable in the sense that "I do not care about missing classes".

-1 on this approach here because:
- Resume an un-resumable exception via "... signalerContext return: nil"

- Brittle check of #messageText via #beginsWith: and #endsWith:

This implementation is too smelly. We can do better. :-) Let's discuss this after the release.

Best,
Marcel
Am 17.06.2022 05:42:09 schrieb commits at source.squeak.org <commits at source.squeak.org>:
A new version of System was added to project The Inbox:
http://source.squeak.org/inbox/System-lrnp.1362.mcz

==================== 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 ]!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220620/01a3f729/attachment.html>


More information about the Squeak-dev mailing list