Skip to content

Post NSUserDefaultsDidChangeNotification when a lookup changes - #761

Merged
rfm merged 2 commits into
gnustep:masterfrom
DTW-Thalion:fix/defaults-change-notification
Aug 15, 2026
Merged

Post NSUserDefaultsDidChangeNotification when a lookup changes#761
rfm merged 2 commits into
gnustep:masterfrom
DTW-Thalion:fix/defaults-change-notification

Conversation

@DTW-Thalion

Copy link
Copy Markdown
Contributor

Nothing is posted when these methods alter what objectForKey: can see: registerDefaults:, setVolatileDomain:forName:, removeVolatileDomainForName:, addSuiteNamed:, removeSuiteNamed: and setSearchList:. Everything else that changes the mapping posts already, through _changePersistentDomain: or its own call.

Each now posts, in the shape _changePersistentDomain: already uses, a flag set under the lock and the post made after unlocking.

setSearchList: keeps its existing isEqual: guard, so an equal list still posts nothing. The rest post unconditionally, matching the note in setObject:forKey: about notifying even where the value has not changed. The registration domain that resetStandardUserDefaults reinstalls on the new shared instance is not covered here.

Tests/base/NSUserDefaults/notifications.m exercises all of them.

On master 6 of its 8 assertions fail, one for each method, and all 8 pass with the change. The suite passes 13488 with 44 dashed hopes and no failures. #756 discusses this.

addSuiteNamed:, removeSuiteNamed:, setSearchList:,
setVolatileDomain:forName:, removeVolatileDomainForName: and
registerDefaults: alter what objectForKey: can see and posted nothing.
The post uses the shape _changePersistentDomain: already has, a flag
set under the lock and the post after unlocking.  setSearchList: keeps
its existing guard, so an equal list still posts nothing.
@DTW-Thalion
DTW-Thalion requested a review from rfm as a code owner August 13, 2026 18:59

@rfm rfm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@rfm
rfm merged commit 96a4c1e into gnustep:master Aug 15, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants