Skip to content

Commit 1c3fffc

Browse files
committedOct 17, 2013
Before trying cleanLines.pl
1 parent 190aad7 commit 1c3fffc

11 files changed

+63
-36
lines changed
 

‎SSWebBrowsing.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import "SSWebBrowsing.h"
2+
#import "NSBundle+MainApp.h"
23

34
@implementation NSString (FirefoxQuicksearch)
45

@@ -17,7 +18,7 @@ - (NSString*)stringByFixingFirefoxQuicksearch {
1718
// So, first we replace %s with our app name,
1819
NSMutableString* temp = [self mutableCopy] ;
1920
[temp replaceOccurrencesOfString:@"%s"
20-
withString:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]
21+
withString:[[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleName"]
2122
options:NSBackwardsSearch
2223
range:NSMakeRange(0, [temp length])] ;
2324
output = [NSString stringWithString:temp] ;

‎SSYAlert.m

+10-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#import "NSError+Recovery.h"
1616
#import "NSError+SSYInfo.h"
1717
#import "SSYWindowHangout.h"
18+
#import "NSBundle+MainApp.h"
1819

1920
NSObject <SSYAlertErrorHideManager> * gSSYAlertErrorHideManager = nil ;
2021

@@ -363,7 +364,7 @@ @implementation SSYAlert : NSWindowController
363364

364365

365366
+ (NSString*)supportEmailString {
366-
return [[NSBundle mainBundle] objectForInfoDictionaryKey:SSYAlert_ErrorSupportEmailKey] ;
367+
return [[NSBundle mainAppBundle] objectForInfoDictionaryKey:SSYAlert_ErrorSupportEmailKey] ;
367368
}
368369

369370
- (id)clickObject {
@@ -651,18 +652,18 @@ + (NSInteger)tryRecoveryAttempterForError:(NSError*)error
651652

652653
- (IBAction)help:(id)sender {
653654
[[NSHelpManager sharedHelpManager] openHelpAnchor:[self helpAnchorString]
654-
inBook:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleHelpBookName"]] ;
655+
inBook:[[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleHelpBookName"]] ;
655656
}
656657

657658
- (IBAction)support:(id)sender {
658659
[SSYAlert supportError:[self errorPresenting]] ;
659660
}
660661

661662
+ (void)supportError:(NSError*)error {
662-
NSString* appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"] ;
663+
NSString* appName = [[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"] ;
663664
// Note: If you'd prefer the app name to be localized, use "CFBundleName" instead.
664-
NSString* appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] ;
665-
NSString* appVersionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ;
665+
NSString* appVersion = [[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] ;
666+
NSString* appVersionString = [[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ;
666667
NSString* systemDescription = [SSYSystemDescriber softwareVersionAndArchitecture] ;
667668
NSString* mailableDescription ;
668669
if (
@@ -678,7 +679,7 @@ + (void)supportError:(NSError*)error {
678679

679680
NSString* filename = [NSString stringWithFormat:
680681
@"%@-Error-%lx.txt",
681-
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"],
682+
[[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleName"],
682683
(long)[NSDate timeIntervalSinceReferenceDate]] ;
683684
NSString* filePath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Desktop"] stringByAppendingPathComponent:filename] ;
684685
NSError* writeError = nil ;
@@ -836,7 +837,7 @@ - (void)setSupportEmail {
836837
[button setBezelStyle:NSRegularSquareBezelStyle] ;
837838
[button setTarget:self] ;
838839
[button setAction:@selector(support:)] ;
839-
NSString* imagePath = [[NSBundle mainBundle] pathForResource:@"support"
840+
NSString* imagePath = [[NSBundle mainAppBundle] pathForResource:@"support"
840841
ofType:@"tif"] ;
841842
NSImage* image = [[NSImage alloc] initByReferencingFile:imagePath] ;
842843
[button setImage:image] ;
@@ -858,7 +859,7 @@ - (void)setSupportEmail {
858859

859860
- (void)setWindowTitle:(NSString*)title {
860861
if (!title) {
861-
title = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"] ; // CFBundleName may be localized
862+
title = [[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleName"] ; // CFBundleName may be localized
862863
}
863864

864865
[[self window] setTitle:title] ;
@@ -1912,7 +1913,7 @@ - (id)init {
19121913
styleMask:NSTitledWindowMask
19131914
backing:NSBackingStoreBuffered
19141915
defer:NO] ;
1915-
NSString* appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"] ; // CFBundleName may be localized
1916+
NSString* appName = [[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleName"] ; // CFBundleName may be localized
19161917
if (appName) {
19171918
[window setTitle:appName] ;
19181919
}

‎SSYAlertSounder.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#import "SSYAlertSounder.h"
22
#import <AudioToolbox/AudioServices.h>
3+
#import "NSBundle+MainApp.h"
34

45

56
static SSYAlertSounder* static_sharedSounder = nil ;
@@ -79,7 +80,7 @@ - (void)playAlertSoundNamed:(NSString*)name {
7980

8081
// If not found, look in the current application's bundle
8182
if (!soundId) {
82-
path = [[NSBundle mainBundle] pathForResource:name
83+
path = [[NSBundle mainAppBundle] pathForResource:name
8384
ofType:@"aiff"] ;
8485

8586
soundId = [self soundIdForPath:path

‎SSYAppInfo.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import "SSYAppInfo.h"
2+
#import "NSBundle+MainApp.h"
23

34
NSString * const constKeyLastVersion = @"lastVersion" ;
45

@@ -72,7 +73,7 @@ + (SSYVersionTriplet*)rawPreviousVersionTriplet {
7273
}
7374

7475
+ (SSYVersionTriplet*)rawCurrentVersionTriplet {
75-
NSString* versionString = [SSYVersionTriplet rawVersionStringFromBundle:[NSBundle mainBundle]] ;
76+
NSString* versionString = [SSYVersionTriplet rawVersionStringFromBundle:[NSBundle mainAppBundle]] ;
7677
SSYVersionTriplet* cvt = [SSYVersionTriplet versionTripletFromString:versionString] ;
7778
return cvt ;
7879
}
@@ -86,7 +87,7 @@ - (void)calculateUpgradeState {
8687
[self setUpgradeState:upgradeState] ;
8788
if ([self upgradeState] != SSYCurrentRev) {
8889
// Get a nice, clean, filtered versionString of the form "major.minor.bugFix" using SSVersionTriplet methods
89-
SSYVersionTriplet* currentVersionTriplet = [SSYVersionTriplet versionTripletFromBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]] ;
90+
SSYVersionTriplet* currentVersionTriplet = [SSYVersionTriplet versionTripletFromBundleIdentifier:[[NSBundle mainAppBundle] bundleIdentifier]] ;
9091
NSString* currentVersionString = [currentVersionTriplet string] ;
9192

9293
// Record currently-launched version into prefs

‎SSYDooDooUndoManager.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ - (id)initWithDocument:(NSPersistentDocument*)document {
3838
// We cast to an id since the compiler expects these to methods
3939
// to get something which inherits from NSUndoManager, which
4040
// GCUndoManager does not.
41-
[document setUndoManager:(id)self] ;
41+
[document setUndoManager:(id)self] ; // Causes moc to be created, which causes persisten store to be created ??
4242
[[document managedObjectContext] setUndoManager:(id)self] ;
4343

4444
[self setManagedObjectContext:[document managedObjectContext]] ;

‎SSYMOCManager.m

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "NSObject+MoreDescriptions.h"
1212
#import "BkmxBasis.h"
1313
#import "NSBundle+SSYMotherApp.h"
14+
#import "NSBundle+MainApp.h"
1415

1516

1617
NSString* const constKeyMOC = @"moc" ;
@@ -85,7 +86,7 @@ - (void)attemptRecoveryFromError:(NSError*)error
8586
NSString* extension = [oldFilename pathExtension] ;
8687
NSString* newFilename = [NSString stringWithFormat:
8788
@"%@-Unreadable-%@",
88-
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"],
89+
[[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"],
8990
oldBaseFilename] ;
9091
// We used CFBundleExecutable instead of CFBundleName to get an unlocalized app name.
9192
newFilename = [newFilename stringByAppendingPathExtension:extension] ;
@@ -118,14 +119,16 @@ + (NSURL*)sqliteStoreURLWithIdentifier:(NSString*)identifier {
118119
identifier = @"Shared" ;
119120
}
120121
filename = [identifier stringByAppendingPathExtension:SSYManagedObjectContextPathExtensionForSqliteStores] ;
121-
NSString* path = [[[NSBundle mainBundle] applicationSupportPathForMotherApp] stringByAppendingPathComponent:filename] ;
122+
NSBundle* mainAppBundle = [NSBundle mainAppBundle] ;
123+
NSString* path = [[mainAppBundle applicationSupportPathForMotherApp] stringByAppendingPathComponent:filename] ;
122124
NSURL* url = nil ;
123125
if (path) {
124126
// Above if() was added in BookMacster 1.19 to eliminate crash in case
125127
// the app's Application Suppport folder is trashed while Worker is
126128
// watching one or more files in it for changes.
127129
url = [NSURL fileURLWithPath:path] ;
128130
}
131+
129132
return url ;
130133
}
131134

@@ -140,7 +143,7 @@ + (NSPersistentStoreCoordinator*)persistentStoreCoordinatorType:(NSString*)store
140143
error_p:(NSError**)error_p {
141144
NSPersistentStore* persistentStore = nil ;
142145

143-
NSArray* bundles = [NSArray arrayWithObject:[NSBundle mainBundle]] ;
146+
NSArray* bundles = [NSArray arrayWithObject:[NSBundle mainAppBundle]] ;
144147
NSManagedObjectModel* mergedMOM = [NSManagedObjectModel mergedModelFromBundles:bundles] ;
145148
NSPersistentStoreCoordinator* newPSC = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mergedMOM] ;
146149

@@ -155,7 +158,7 @@ + (NSPersistentStoreCoordinator*)persistentStoreCoordinatorType:(NSString*)store
155158
// is that if the parent folder does not exist, the method will fail to create a
156159
// persistent store with no explanation. So we make sure it exists
157160
NSString* parentPath = [[url path] stringByDeletingLastPathComponent] ;
158-
161+
159162
if (!parentPath) {
160163
ok = NO ;
161164
}
@@ -192,7 +195,7 @@ + (NSPersistentStoreCoordinator*)persistentStoreCoordinatorType:(NSString*)store
192195
}
193196
}
194197

195-
if (ok) {
198+
if (ok) {
196199
NSDictionary* options ;
197200
if (momdName) {
198201
// Using Multi-Hop Migration
@@ -230,7 +233,7 @@ + (NSPersistentStoreCoordinator*)persistentStoreCoordinatorType:(NSString*)store
230233
// If we did not get a store but file exists, must be a corrupt file.
231234
NSString* msg = [NSString stringWithFormat:@"Click 'Move' to move the unreadable database\n%@\nto your desktop and start a new database. The item properties in your old database will not be available to %@.",
232235
[url path],
233-
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"]] ;
236+
[[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"]] ;
234237
// We used CFBundleExecutable instead of CFBundleName to get an unlocalized app name.
235238
if (error_p) {
236239
*error_p = [*error_p errorByAddingLocalizedRecoverySuggestion:msg] ;

‎SSYManagedObject.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#import "NSSet+Identicalness.h"
66
#import "NSDocument+SyncModDate.h"
77
#import "NSObject+MoreDescriptions.h"
8+
#import "NSBundle+MainApp.h"
89

910
// Public Notifications
1011
NSString* const constNoteWillUpdateObject = @"willUpdateObject" ;
@@ -124,7 +125,7 @@ + (NSString*)entityNameForClass:(Class)class {
124125
}
125126

126127
+ (NSEntityDescription*)entityDescription {
127-
NSArray* bundles = [NSArray arrayWithObject:[NSBundle mainBundle]] ;
128+
NSArray* bundles = [NSArray arrayWithObject:[NSBundle mainAppBundle]] ;
128129
NSManagedObjectModel* mom = [NSManagedObjectModel mergedModelFromBundles:bundles] ;
129130
NSPersistentStoreCoordinator* psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom] ;
130131
NSManagedObjectContext* moc = [[NSManagedObjectContext alloc] init] ;

‎SSYMojo.m

+27-11
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,33 @@ - (NSArray*)allObjectsError_p:(NSError**)error_p {
154154
// when it invoked -[NSArrayController removeSelectionIndexes:[self selectionIndexes]] ;
155155
// [managedObjectContext processPendingChanges] ; // Do not do this
156156

157-
[fetchRequest setEntity:[NSEntityDescription entityForName:[self entityName]
158-
inManagedObjectContext:managedObjectContext]];
159-
// Since we didn't set a predicate in fetchRequest, we get all objects
160-
NSArray* allObjects = [managedObjectContext executeFetchRequest:fetchRequest
161-
error:&error] ;
162-
if (error) {
163-
NSLog(@"Internal Error 915-1874 %@", [error localizedDescription]) ;
164-
if (error_p) {
165-
*error_p = error ;
166-
}
167-
}
157+
NSEntityDescription* entity = [NSEntityDescription entityForName:[self entityName]
158+
inManagedObjectContext:managedObjectContext] ;
159+
NSArray* allObjects ;
160+
if (entity) {
161+
[fetchRequest setEntity:entity] ;
162+
// Since we didn't set a predicate in fetchRequest, we get all objects
163+
allObjects = [managedObjectContext executeFetchRequest:fetchRequest
164+
error:&error] ;
165+
if (error) {
166+
NSLog(@"Internal Error 915-1874 %@", [error localizedDescription]) ;
167+
if (error_p) {
168+
*error_p = error ;
169+
}
170+
}
171+
}
172+
else {
173+
// Defensive programming added in BookMacster 1.19.2. If data model
174+
// is not available, entity will be nil and if we didn't test for that,
175+
// -[NSManagedObjectContext executeFetchRequest:error] would crash
176+
// due to nil entity in fetch request.
177+
NSString* errorDesc = [NSString stringWithFormat:@"No entity for %@", [self entityName]] ;
178+
NSLog(@"Internal Error 915-0893 %@", errorDesc) ;
179+
if (error_p) {
180+
*error_p = SSYMakeError(262049, errorDesc) ;
181+
}
182+
allObjects = nil ;
183+
}
168184
[fetchRequest release] ;
169185

170186
return allObjects ;

‎SSYOAuthTalker.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "NSString+URIQuery.h"
1010
#import "NSString+LocalizeSSY.h"
1111
#import "NSObject+MoreDescriptions.h"
12+
#import "NSBundle+MainApp.h"
1213

1314
NSString* const constNoteGotOAuthInfo = @"gotOAuthInfo" ;
1415
NSString* const constPathOAuth = @"OAuth" ;
@@ -52,7 +53,7 @@ @implementation SSYOAuthTalker
5253
@synthesize accounter = m_accounter ;
5354

5455
+ (NSString*)keychainServiceNameForAccounter:(NSObject <SSYOAuthAccounter> *)accounter {
55-
NSString* answer = [[NSBundle mainBundle] bundleIdentifier] ;
56+
NSString* answer = [[NSBundle mainAppBundle] bundleIdentifier] ;
5657
if ([accounter respondsToSelector:@selector(serviceName)]) {
5758
answer = [answer stringByAppendingFormat:
5859
@".%@",

‎SSYPersistentDocumentMultiMigrator.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#import "NSString+MorePaths.h"
66
#import "NSDocument+SyncModDate.h"
77
#import "NSError+Recovery.h"
8+
#import "NSBundle+MainApp.h"
89

910
NSString* const SSYPersistentDocumentMultiMigratorErrorDomain = @"SSYPersistentDocumentMultiMigratorErrorDomain" ;
1011
NSString* const SSYPersistentDocumentMultiMigratorDidBeginMigrationNotification = @"SSYPersistentDocumentMultiMigratorDidBeginMigrationNotification" ;
@@ -71,7 +72,7 @@ + (BOOL)migrateIfNeededStoreAtUrl:(NSURL*)url
7172
}
7273

7374
// Read the "VersionInfo" plist.
74-
NSString* momdPath = [[NSBundle mainBundle] pathForResource:momdName
75+
NSString* momdPath = [[NSBundle mainAppBundle] pathForResource:momdName
7576
ofType:@"momd"] ;
7677
NSBundle* modelBundle = [NSBundle bundleWithPath:momdPath] ;
7778
if (!modelBundle) {
@@ -201,7 +202,7 @@ + (BOOL)migrateIfNeededStoreAtUrl:(NSURL*)url
201202
// successful destination the destinModel.
202203
NSManagedObjectModel* destinModel = nil ;
203204
NSMappingModel* mappingModel = nil ;
204-
NSArray* bundles = [NSArray arrayWithObject:[NSBundle mainBundle]] ;
205+
NSArray* bundles = [NSArray arrayWithObject:[NSBundle mainAppBundle]] ;
205206
NSString* destinModelVersionName = nil ;
206207
for (destinModelVersionName in modelVersionNames) {
207208
NSString* modelPath = [modelBundle pathForResource:destinModelVersionName

‎SSYSemaphore.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#import "SSYOtherApper.h"
44
#import "BkmxBasis.h"
55
#import "NSBundle+SSYMotherApp.h"
6+
#import "NSBundle+MainApp.h"
67

78
@implementation SSYSemaphorePidKey
89

@@ -99,7 +100,7 @@ + (SSYSemaphorePidKey*)pidKeyWithString:(NSString*)pidKeyString {
99100
@implementation SSYSemaphore
100101

101102
+ (NSString*)path {
102-
return [[[NSBundle mainBundle] applicationSupportPathForMotherApp] stringByAppendingPathComponent:@".SSYSemaphore"] ;
103+
return [[[NSBundle mainAppBundle] applicationSupportPathForMotherApp] stringByAppendingPathComponent:@".SSYSemaphore"] ;
103104
}
104105

105106
+ (SSYSemaphorePidKey*)currentPidKeyEnforcingTimeLimit:(NSTimeInterval)timeLimit {

0 commit comments

Comments
 (0)
Please sign in to comment.