diff --git a/FlycutOperator.m b/FlycutOperator.m index ca5c581..c2c3d3d 100644 --- a/FlycutOperator.m +++ b/FlycutOperator.m @@ -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; @@ -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"];