The Trunk: System-eem.747.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-eem.747.mcz

commits-2
Chris Muller uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-eem.747.mcz

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

Name: System-eem.747
Author: eem
Time: 30 June 2015, 3:29:21.961 pm
UUID: b4f12663-36dd-4e16-9c83-5e446ea6e037
Ancestors: System-eem.746

Second part of putsch.  Move preferences dictionary from class var to inst var.  Remove the setter, and makde the getter, currently used only by SystemReporter, answer a copy.

=============== Diff against System-eem.746 ===============

Item was changed:
  ----- Method: Preferences class>>addPreference:categories:default:balloonHelp:projectLocal:changeInformee:changeSelector:type: (in category 'add preferences') -----
  addPreference: aName categories: categoryList default: aValue balloonHelp: helpString projectLocal: localBoolean changeInformee: informeeSymbol changeSelector: aChangeSelector type: aType
  "Add or replace a preference as indicated.  Reuses the preexisting Preference object for this symbol, if there is one, so that UI artifacts that interact with it will remain valid."
 
  | newPreference aPreference |
  (newPreference := Preference new)
  name: aName asSymbol
  defaultValue: aValue
  helpString: helpString
  localToProject: localBoolean
  categoryList: categoryList
  changeInformee: informeeSymbol
  changeSelector: aChangeSelector
  type: aType.
+ aPreference := preferencesDictionary
- aPreference := DictionaryOfPreferences
  at: newPreference name
  ifAbsent: [newPreference].
  aPreference == newPreference
  ifTrue: "Atomically add the new preference to the dictionary."
  [self atomicUpdatePreferences:
  [:preferenceDictionaryCopy|
  preferenceDictionaryCopy at: newPreference name put: newPreference]]
  ifFalse: "Use the copyFrom: primitive to atomically update the existing preference."
  [aPreference copyFrom: newPreference].
  self compileAccessMethodForPreference: aPreference!

Item was changed:
  ----- Method: Preferences class>>allPreferenceObjects (in category 'preference-object access') -----
  allPreferenceObjects
  "Answer a list of all the Preference objects registered in the system"
 
+ ^preferencesDictionary values!
- ^DictionaryOfPreferences values!

Item was changed:
  ----- Method: Preferences class>>atomicUpdatePreferences: (in category 'accessing') -----
  atomicUpdatePreferences: aBlock
  "Evaluate aBlock with a copy of the preferences dictionary and
  then assign (assignment is atomic) the copy to the dictionary."
+ | copyOfPreferences |
+ copyOfPreferences := preferencesDictionary
- | copyOfDictionaryOfPreferences |
- copyOfDictionaryOfPreferences := DictionaryOfPreferences
  ifNil: [IdentityDictionary new]
  ifNotNil: [:dict| dict copy].
+ aBlock value: copyOfPreferences.
+ preferencesDictionary := copyOfPreferences!
- aBlock value: copyOfDictionaryOfPreferences.
- DictionaryOfPreferences := copyOfDictionaryOfPreferences!

Item was changed:
  ----- Method: Preferences class>>dictionaryOfPreferences (in category 'accessing') -----
  dictionaryOfPreferences
+ "N.B.  Does /not/ answer the dictionary itself.  To burrow that deep use e.g. instVarNamed:"
+ ^preferencesDictionary copy!
- "The use of this accessor doesn't ensure that the dictionary is not accessed concurrently. Use #accessDictionaryOfPreferencesIn: instead."
-
- ^DictionaryOfPreferences!

Item was removed:
- ----- Method: Preferences class>>dictionaryOfPreferences: (in category 'accessing') -----
- dictionaryOfPreferences: anObject
- DictionaryOfPreferences := anObject!

Item was changed:
  ----- Method: Preferences class>>initializeDictionaryOfPreferences (in category 'initialization') -----
  initializeDictionaryOfPreferences
+ "Initialize the preferencesDictionary to be an empty IdentityDictionary"
- "Initialize the DictionaryOfPreferences to be an empty IdentityDictionary"
 
  "Preferences initializeDictionaryOfPreferences"
 
+ preferencesDictionary := IdentityDictionary new!
- self  dictionaryOfPreferences:IdentityDictionary new!

Item was changed:
  ----- Method: Preferences class>>inspectPreferences (in category 'preferences panel') -----
  inspectPreferences
  "Open a window on the current preferences dictionary, allowing the user to inspect and change the current preference settings.  This is fallen back upon if Morphic is not present. This is dangerous, the dictionary of preferences should not be accessed concurrently."
 
  "Preferences inspectPreferences"
 
+ preferencesDictionary inspectWithLabel: 'Preferences'!
- self dictionaryOfPreferences inspectWithLabel:'Preferences'!

Item was changed:
  ----- Method: Preferences class>>preferenceAt:ifAbsent: (in category 'preference-object access') -----
  preferenceAt: aSymbol ifAbsent: aBlock
  "Answer the Preference object at the given symbol, or the value of aBlock if not present"
 
+ ^preferencesDictionary at: aSymbol ifAbsent: aBlock!
- ^DictionaryOfPreferences at: aSymbol ifAbsent: aBlock!

Item was changed:
  ----- Method: Preferences class>>savePersonalPreferences (in category 'personalization') -----
  savePersonalPreferences
  "Save the current list of Preference settings as the user's personal choices"
 
  self
  setParameter: #PersonalDictionaryOfPreferences
+ to: preferencesDictionary deepCopy!
- to: DictionaryOfPreferences deepCopy!

Item was changed:
  ----- Method: Preferences class>>storePreferencesIn: (in category 'personalization') -----
  storePreferencesIn: aFileName
  | stream prefsSnapshot |
  #(Prevailing PersonalPreferences) do:
  [:ea |
  Parameters removeKey: ea ifAbsent: []].
  stream := ReferenceStream fileNamed: aFileName.
  stream nextPut: Parameters.
+ prefsSnapshot := preferencesDictionary copy.
- prefsSnapshot := DictionaryOfPreferences copy.
  prefsSnapshot keysAndValuesDo: [:key :pref | prefsSnapshot at: key put: pref asPreference].
  stream nextPut: prefsSnapshot.
  stream nextPut: (Smalltalk isMorphic
  ifTrue:[World fillStyle]
  ifFalse:[DesktopColor]).
  stream close!

Item was changed:
  (PackageInfo named: 'System') postscript: '" Convert SoundService registeredClasses to classes if necessary "
  [ | currentSoundSystem |
  currentSoundSystem := SoundService defaultOrNil.
  (SoundService registeredClasses copy collect: [:ss |
  SoundService unregister: ss.
  ss isBehavior
  ifTrue: [ss]
  ifFalse: [ss class]]
  ) do: [:ssClass |
  SoundService register: ssClass].
  SoundService default: (currentSoundSystem
  ifNotNil: [:css| css isBehavior ifTrue: [css] ifFalse: [css class]]).
  ] value.
 
  "Convert preferences dictionary from class var to inst var if necessary."
  (Preferences instVarNamed: ''preferencesDictionary'') ifNil:
  [(Preferences classPool at: #DictionaryOfPreferences) ifNotNil:
  [:dictionary|
  Preferences
  instVarNamed: ''preferencesDictionary''
+ put: dictionary]].
+
+ (Smalltalk classNamed: #ServicePreferences) ifNotNil:
+ [:sp|
+ (sp instVarNamed: ''preferencesDictionary'') ifNil:
+ [(sp classPool at: #ServiceDictionaryOfPreferences) ifNotNil:
+ [:dictionary|
+ sp
+ instVarNamed: ''preferencesDictionary''
+ put: dictionary]]]'!
- put: dictionary]]'!