Skip to content

Commit ac6cc13

Browse files
committed
BookMacster 1.15.7 "point 5".
1 parent ec85d14 commit ac6cc13

12 files changed

+93
-36
lines changed

SSYAlert.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ + (void)supportError:(NSError*)error {
663663
if ([mailableDescription hasSuffix:SSYDidTruncateErrorDescriptionTrailer]) {
664664
// We'll write a file to package the error's longDescription which was too long to
665665
// fit in the email, and ask the user to zip and attach it.
666-
NSString* longDescription = [error performSelector:@selector(longDescription)] ;
666+
NSString* longDescription = [error longDescription] ;
667667

668668
NSString* filename = [NSString stringWithFormat:
669669
@"%@-Error-%lx.txt",

SSYDebug.m

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
[[NSThread currentThread] name]] ;
1414

1515
[nsString appendString:@" Slide(0x) Library\n"] ;
16-
NSUInteger i;
16+
uint32_t i;
1717
NSUInteger count = _dyld_image_count();
1818

1919
for (i = 0; i < count; i++) {
20-
intptr_t slide = _dyld_get_image_vmaddr_slide(i);
20+
intptr_t slide = (intptr_t)_dyld_get_image_vmaddr_slide(i);
2121
NSString* name = [NSString stringWithUTF8String:_dyld_get_image_name(i)] ;
2222
NSString* exclude1 = @"/usr/lib/" ;
2323
NSString* exclude2 = @"/System/Library/" ;
@@ -34,7 +34,7 @@
3434
// An infinite loop will "blow its stack" at 512 calls, so
3535
// we allow a little more than that.
3636
void* callstack[514] ;
37-
NSInteger frames = backtrace(callstack, 514) ;
37+
int frames = backtrace(callstack, 514) ;
3838
char** strs = backtrace_symbols(callstack, frames) ;
3939
NSInteger iFrame ;
4040
for (iFrame = 1; iFrame < frames; ++iFrame) {
@@ -73,7 +73,7 @@ NSInteger SSYDebugStackDepth(void) {
7373
NSMutableString* nsString = [[NSMutableString alloc] init] ;
7474

7575
void* callstack[depth] ;
76-
NSInteger frames = backtrace(callstack, depth) ;
76+
int frames = backtrace(callstack, (int)depth) ;
7777
char** strs = backtrace_symbols(callstack, frames) ;
7878
NSInteger iFrame ;
7979
for (iFrame = 2; iFrame < frames; ++iFrame) {
@@ -92,7 +92,7 @@ NSInteger SSYDebugStackDepth(void) {
9292

9393
NSString* SSYDebugCaller(void) {
9494
void* callstack[3] ;
95-
NSInteger frames = backtrace(callstack, 3) ;
95+
int frames = backtrace(callstack, 3) ;
9696
char** strs = backtrace_symbols(callstack, frames) ;
9797
NSString* caller = [NSString stringWithCString:strs[2]
9898
encoding:NSUTF8StringEncoding] ;

SSYDooDooUndoManager.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ - (id)initWithDocument:(NSPersistentDocument*)document {
3333
if (self != nil) {
3434
NSAssert(document != nil, @"SSYDooDooUndoManager got no document") ;
3535

36-
// [self setGroupsByEvent:NO] ; // Causes all hell to break loose with Core Data.
36+
// [self setGroupsByEvent:NO] ; // Causes all hell to break loose with Core Data.
3737

3838
// We cast to an id since the compiler expects these to methods
3939
// to get something which inherits from NSUndoManager, which

SSYDropboxGuy.h

+16-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ __attribute__((visibility("default"))) @interface SSYDropboxGuy : NSObject
2020
*/
2121
+ (void)getDropbox ;
2222

23-
/*!
24-
@brief Returns whether or not a given path is in the Dropbox
25-
archive, indicating that it was replaced by Dropbox.
26-
*/
27-
+ (BOOL)wasReplacedByDropboxPath:(NSString*)path ;
28-
2923
+ (NSString*)defaultDropboxPath ;
3024

3125
+ (BOOL)dropboxIsAvailable ;
@@ -43,6 +37,22 @@ __attribute__((visibility("default"))) @interface SSYDropboxGuy : NSObject
4337
*/
4438
+ (NSInteger)isInDropboxPath:(NSString*)path ;
4539

40+
/*!
41+
@brief Returns whether or not a given path is probably in the user's
42+
Dropbox "cache", which is its "Trash".
43+
44+
@details A folder gets in the Dropbox "Trash" if it is trashed on another
45+
computer, or replaced on another computer.
46+
47+
This method detects whether or not any of the given path's ancester
48+
folders are ".dropbox.cache". Therefore, it can return a false positive if
49+
some user creates such a folder of their own accord and puts stuff in it.
50+
51+
If path is nil, returns NO.
52+
*/
53+
+ (NSInteger)isInDropboxTrashPath:(NSString*)path ;
54+
55+
4656
#if 0
4757
/*
4858
The following methods no longer work if user has Dropbox 1.2 or later, because

SSYDropboxGuy.m

+11-5
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ + (void)getDropbox {
3030
activate:YES] ;
3131
}
3232

33-
+ (BOOL)wasReplacedByDropboxPath:(NSString*)path {
34-
return [path hasPrefix:[NSHomeDirectory() stringByAppendingPathComponent:@".dropbox/cache/"]] ;
35-
}
36-
3733
+ (NSString*)defaultDropboxPath {
3834
NSString* path = [NSHomeDirectory() stringByAppendingPathComponent:@"Dropbox"] ;
3935

@@ -72,7 +68,17 @@ + (NSInteger)isInDropboxPath:(NSString*)path {
7268
return NSOffState ;
7369
}
7470

75-
71+
+ (NSInteger)isInDropboxTrashPath:(NSString*)path {
72+
BOOL answer = NO ;
73+
if (path) {
74+
NSArray* components = [path pathComponents] ;
75+
if ([components indexOfObject:@".dropbox.cache"] != NSNotFound) {
76+
answer = YES ;
77+
}
78+
}
79+
80+
return answer ;
81+
}
7682

7783
/*
7884
The following methods no longer work if user has Dropbox 1.2 or later, because

SSYLaunchdGuy.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ + (pid_t)pidIfRunningLabel:(NSString*)label {
382382
NSArray* words = [trimmedResponse componentsSeparatedByString:@" "] ;
383383
if ([words count] > 0) {
384384
NSString* pidString = [words objectAtIndex:0] ;
385-
pid = [pidString integerValue] ;
385+
pid = [pidString intValue] ;
386386
}
387387
}
388388

SSYMojo.m

+9-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,15 @@ - (NSManagedObject*)freshObject {
187187

188188
NSManagedObject* object = [NSEntityDescription insertNewObjectForEntityForName:[self entityName]
189189
inManagedObjectContext:moc] ;
190-
return object ;
190+
#if 11
191+
#warning Testing insertions not on main thread
192+
if (![[NSThread currentThread] isMainThread]) {
193+
NSLog(@"Internal Error 523-0024 %@\n%@",
194+
[self entityName],
195+
SSYDebugBacktraceDepth(8)) ;
196+
}
197+
#endif
198+
return object ;
191199
}
192200

193201
- (NSManagedObject*)objectWithID:(NSManagedObjectID*)objectID {

SSYPathObserver.m

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
@interface SSYPathWatch : NSObject {
2626
NSString* m_path ;
2727
id m_userInfo ;
28-
NSInteger m_fileDescriptor ;
28+
uint32_t m_fileDescriptor ;
2929
NSThread* m_notifyThread ;
3030
}
3131

3232
@property (retain) NSString* path ;
3333
@property (retain) id userInfo ;
34-
@property (assign) NSInteger fileDescriptor ;
34+
@property (assign) uint32_t fileDescriptor ;
3535
@property (assign) NSThread* notifyThread ;
3636

3737
@end
@@ -120,7 +120,7 @@ camping on kevent(), outside of these two blocks of code, but,
120120
oh, well if you don't try to write perfect code, you'll have
121121
lots of bugs. */
122122

123-
NSInteger fileDescriptor ;
123+
int fileDescriptor ;
124124
@synchronized(self) {
125125
NSAutoreleasePool* pool1 = [[NSAutoreleasePool alloc] init] ;
126126

@@ -210,7 +210,7 @@ -(id)init {
210210
[self setIsWatching:YES] ;
211211
[self setPathWatches:[NSMutableSet set]] ;
212212

213-
NSInteger kqueueFileDescriptor = kqueue() ;
213+
uint32_t kqueueFileDescriptor = kqueue() ;
214214
if (kqueueFileDescriptor == -1) {
215215
NSLog(@"Internal Error 153-9092. Failed creating kqueue") ;
216216
// See http://lists.apple.com/archives/Objc-language/2008/Sep/msg00133.html ...
@@ -335,7 +335,7 @@ - (oneway void)release {
335335
// Close any file descriptors which might still be open
336336
for (SSYPathWatch* pathWatch in [self pathWatches]) {
337337
// Unregister kqueue of the target pathWatch
338-
NSInteger fileDescriptor = [pathWatch fileDescriptor] ;
338+
uint32_t fileDescriptor = [pathWatch fileDescriptor] ;
339339
NSInteger result = close(fileDescriptor) ;
340340
if (result != 0) {
341341
}
@@ -352,7 +352,7 @@ - (oneway void)release {
352352
}
353353
#endif
354354

355-
NSInteger kqfd = [self kqueueFileDescriptor] ;
355+
uint32_t kqfd = [self kqueueFileDescriptor] ;
356356

357357
// The following causes the watcher thread to exit in Mac OS 10.6,
358358
// but not in Mac OS 10.5.
@@ -384,7 +384,7 @@ - (BOOL)addPath:(NSString*)path
384384
BOOL ok = YES ;
385385

386386
// Get file descriptor for given path
387-
NSInteger fileDescriptor = open([path UTF8String], O_RDONLY) ;
387+
uint32_t fileDescriptor = open([path UTF8String], O_RDONLY) ;
388388
if (fileDescriptor == -1) {
389389
if (error_p) {
390390
NSDictionary* userInfo = [NSDictionary dictionaryWithObjectsAndKeys:

SSYPersistentDocumentMultiMigrator.h

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern NSString* const SSYPersistentDocumentMultiMigratorDidEndMigrationNotifica
3232
#define SSYPersistentDocumentMultiMigratorErrorCodeCouldNotCopyFile 315015
3333
#define SSYPersistentDocumentMultiMigratorErrorCodeCouldNotSwapFile 315016
3434
#define SSYPersistentDocumentMultiMigratorErrorCodeCouldNotRemoveTempFile 315020
35+
#define SSYPersistentDocumentMultiMigratorErrorCodeCouldNotCopyUnwriteableFile 315021
3536

3637
@interface SSYPersistentDocumentMultiMigrator : NSObject
3738

SSYPersistentDocumentMultiMigrator.m

+27-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,33 @@ + (BOOL)migrateIfNeededStoreAtUrl:(NSURL*)url
251251
goto end ;
252252
}
253253

254-
// Do the migration, creating a new file at destempUrl.
254+
#if 0
255+
// Fix 20130610
256+
BOOL isWritable = [[NSFileManager defaultManager] isWritableFileAtPath:[url absoluteString]] ;
257+
BOOL isInViewingMode = [document isInViewingMode] ;
258+
/*SSYDBL*/ NSLog(@"isWritable = %ld isInViewingMode = %ld ", isWritable, isInViewingMode) ;
259+
if (isInViewingMode) {
260+
NSString* fileNameExtension = [[url absoluteString] pathExtension] ;
261+
NSString* writablePath = [[[NSFileManager defaultManager] temporaryFilePath] stringByAppendingPathExtension:fileNameExtension] ;
262+
/*SSYDBL*/ NSLog(@"Not writable.\nCopying: %@\n To: %@", [url absoluteString], writablePath) ;
263+
ok = [[NSFileManager defaultManager] copyItemAtPath:[url absoluteString]
264+
toPath:writablePath
265+
error:&underlyingError] ;
266+
if (!ok) {
267+
errorCode = SSYPersistentDocumentMultiMigratorErrorCodeCouldNotCopyUnwriteableFile ;
268+
[errorInfo setValue:writablePath
269+
forKey:@"Writable Path"] ;
270+
[errorInfo setValue:[url absoluteString]
271+
forKey:@"Source Path"] ;
272+
goto end ;
273+
}
274+
275+
url = [NSURL fileURLWithPath:writablePath] ;
276+
[document setFileURL:url] ;
277+
}
278+
#endif
279+
280+
// Do the migration, creating a new file at destempUrl.
255281
// Because the Core Data Model Versioning and Data Migration Programming Guide
256282
// indicates that this method reads the whole store into memory, and this
257283
// could be a lot, we use a local autorelease pool, transferring any

SSYSqliter.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ - (BOOL)checkpointAndCloseError_p:(NSError**)error_p {
795795
SQLITE_CHECKPOINT_PASSIVE,
796796
&nFramesLogged,
797797
&nFramesCheckpointed) ;
798-
if ((result != SQLITE_OK) && error_p) {
798+
if ((result != SQLITE_OK) && error_p) {
799799
*error_p = [self makeErrorWithAppCode:453035
800800
sqliteCode:result
801801
sqliteDescription:sqlite3_errmsg([self db])

SSYTasker.m

+13-7
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,27 @@ @implementation SSYTasker
9797
@synthesize error = m_error ;
9898

9999
- (void)processNote:(NSNotification*)note
100+
logAs:(NSString*)logAs
100101
intoData:(NSMutableData *)mutableData {
101102
NSFileHandle* fileHandle = (NSFileHandle*)[note object] ;
102103
NSError* error = nil ;
103104
NSData* data = [fileHandle availableDataError_p:&error] ;
104105
if (error) {
105106
[self setError:error] ;
106107
}
108+
109+
/*SSYDBL*/ NSLog(@"Got from %@ %04ld bytes.", logAs, [data length]) ;
107110
if ([data length] > 0) {
108-
[mutableData appendData:data] ;
111+
112+
[mutableData appendData:data] ;
109113
// Tell the fileHandle that we want more data.
110114
[fileHandle waitForDataInBackgroundAndNotify] ;
111115
}
112116
else {
113-
// I've not seen this happen, because I always get
114-
// NSTaskDidTerminateNotification first. But it might?? If it does,
115-
// according to documentation, it tells us that either stdout or stderr
116-
// is done. We ignore it and wait instead for
117-
// NSTaskDidTerminateNotification.
117+
// According to documentation, it tells us that either stdout or stderr
118+
// is done. In my experience, this branch usually does not execute
119+
// in a typical program run. But somtimes it does. We ignore it and
120+
// wait instead for NSTaskDidTerminateNotification which is reliable.
118121
}
119122
}
120123

@@ -126,6 +129,7 @@ - (void)eatStdoutNote:(NSNotification*)note {
126129
}
127130

128131
[self processNote:note
132+
logAs:@"stdout"
129133
intoData:mutableData];
130134
}
131135

@@ -137,6 +141,7 @@ - (void)eatStderrNote:(NSNotification*)note {
137141
}
138142

139143
[self processNote:note
144+
logAs:@"stderr"
140145
intoData:mutableData];
141146
}
142147

@@ -256,7 +261,8 @@ - (NSInteger)runCommand:(NSString*)launchPath
256261
// Just run the loop again, to wait for next notification or done.
257262
}
258263
} while ([self isTaskDone] == NO) ;
259-
264+
/*SSYDBL*/ NSLog(@"Done") ;
265+
260266
exitStatus = [task terminationStatus] ;
261267

262268
[[NSNotificationCenter defaultCenter] removeObserver:self] ;

0 commit comments

Comments
 (0)