Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions FlycutOperator.m
Original file line number Diff line number Diff line change
Expand Up @@ -1078,8 +1078,20 @@ - (void)saveStore:(FlycutStore *)store toKey:(NSString *)key onDict:(NSMutableDi
}

-(void) saveEngine {
// While the favorites store is swapped in, clippingStore IS favoritesStore and the main
// store is held in stashedStore, so persist the main store from wherever it currently
// is. Saving clippingStore under "jcList" wrote the favorites list as the clipping
// history and never wrote the real history at all - and with savePreference at "after
// each change" that happens on the very next copy, no quit required.
//
// This relies on -switchToFavoritesStore / -restoreStashedStore keeping stashedStore
// non-NULL exactly while clippingStore is favoritesStore. A re-entrant
// -switchToFavoritesStore would break that (it would stash the favorites store over the
// main one), so keep that invariant in mind when touching either method.
FlycutStore *mainStore = ( NULL != stashedStore ) ? stashedStore : clippingStore;

// saveEngine saves to NSUserDefaults. If there have been no modifications, just skip this to avoid busy activity for any observers.
if ( !([clippingStore modifiedSinceLastSaveStore]
if ( !([mainStore modifiedSinceLastSaveStore]
|| [favoritesStore modifiedSinceLastSaveStore]) )
return;

Expand All @@ -1093,7 +1105,7 @@ -(void) saveEngine {

[saveTarget performSelector:saveSelector withObject:saveDict];

[self saveStore:clippingStore toKey:@"jcList" onDict:saveDict];
[self saveStore:mainStore toKey:@"jcList" onDict:saveDict];
[self saveStore:favoritesStore toKey:@"favoritesList" onDict:saveDict];

[[NSUserDefaults standardUserDefaults] setObject:saveDict forKey:@"store"];
Expand Down