Permalink
Browse files

Fixed #45 - notify not working in cocoaDialog beta 3.0.0 beta6 [on 10.6]

Thanks @gregwjacobs for helping me debug this issue very quickly! Determined that the -32 and -64 parameters were added to /usr/bin/arch in 10.7.  Also refactored the relaunch tool to not wait on parent cocoaDialog to quit before launching.
  • Loading branch information...
1 parent d2da7d1 commit f0bf3a7704437bc0b6df52709735589a06bfd8a0 @markcarver markcarver committed May 17, 2012
View
4 Resources/Info.plist
@@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>3.0-beta6</string>
+ <string>3.0-beta7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>3.0.0-beta6</string>
+ <string>3.0.0-beta7</string>
<key>LSMinimumSystemVersion</key>
<string>10.4</string>
<key>LSMinimumSystemVersionByArchitecture</key>
View
4 Resources/en-US.lproj/InfoPlist.strings
@@ -1,6 +1,6 @@
/* Localized versions of Info.plist keys */
CFBundleName = "cocoaDialog";
-CFBundleVersion = "3.0.0-beta6";
-CFBundleShortVersionString = "3.0-beta6";
+CFBundleVersion = "3.0.0-beta7";
+CFBundleShortVersionString = "3.0-beta7";
NSHumanReadableCopyright = "Copyright © 2004-2011, Mark A. Stratman";
View
19 Source/AppController.m
@@ -64,17 +64,16 @@ - (void) awakeFromNib
[arguments replaceObjectAtIndex:1 withObject:@"CDNotifyControl"];
// Relaunch cocoaDialog with the new runMode
NSString *launcherSource = [[NSBundle mainBundle] pathForResource:@"relaunch" ofType:@""];
- NSString *launcherTarget = [NSTemporaryDirectory() stringByAppendingPathComponent:[launcherSource lastPathComponent]];
- NSString *pid = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]];
- [arguments insertObject:pid atIndex:1];
- [arguments insertObject:launcherTarget atIndex:0];
-#if defined __ppc__ || defined __i368__
- [arguments insertObject:@"-32" atIndex:0];
-#elif defined __ppc64__ || defined __x86_64__
- [arguments insertObject:@"-64" atIndex:0];
+ [arguments insertObject:launcherSource atIndex:0];
+#if defined __ppc__
+ [arguments insertObject:@"-ppc" atIndex:0];
+#elif defined __i368__
+ [arguments insertObject:@"-i386" atIndex:0];
+#elif defined __ppc64__
+ [arguments insertObject:@"-ppc64" atIndex:0];
+#elif defined __x86_64__
+ [arguments insertObject:@"-x86_64" atIndex:0];
#endif
- [[NSFileManager defaultManager] removeItemAtPath:launcherTarget error:NULL];
- [[NSFileManager defaultManager] copyItemAtPath:launcherSource toPath:launcherTarget error:NULL];
NSTask *task = [[[NSTask alloc] init] autorelease];
// Output must be silenced to not hang this process
[task setStandardError:[NSFileHandle fileHandleWithNullDevice]];
View
1 Source/CDControl/CDFileDialogControl/CDFileDialogControl.m
@@ -113,7 +113,6 @@ - (void) setMisc {
- (BOOL)isExtensionAllowed:(NSString *)filename {
if (extensions != nil && [extensions count]) {
NSString* extension = [filename pathExtension];
- NSLog(@"%@: %@", extension, [extensions containsObject:extension] ? @"YES" : @"NO");
return [extensions containsObject:extension];
}
else {
View
107 Source/relaunch/main.m
@@ -9,95 +9,62 @@
#import <Cocoa/Cocoa.h>
#import <unistd.h>
-@interface TerminationListener : NSObject
-{
+@interface Relaunch : NSObject {
@private
NSString *executablePath;
NSMutableArray *executableArguments;
- pid_t parentProcessId;
}
-
-- (void)relaunch __dead2;
-
@end
-@implementation TerminationListener
-
-- (void)watchdog:(NSTimer *)timer
-{
- ProcessSerialNumber psn;
- if (GetProcessForPID(parentProcessId, &psn) == procNotFound)
- [self relaunch];
+int main (int argc, const char * argv[]) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ [NSApplication sharedApplication];
+ [[[Relaunch alloc] init] autorelease];
+ [[NSApplication sharedApplication] run];
+
+ [pool drain];
+ return EXIT_SUCCESS;
}
-- (id) init
-{
+@implementation Relaunch
+
+- (id) init {
self = [super init];
- if (self != nil)
- {
+ if (self != nil) {
executableArguments = [[[NSMutableArray alloc] initWithArray:[[NSProcessInfo processInfo] arguments]] autorelease];
// Remove the first three arguments
- if ([executableArguments count] >= 3) {
+ if ([executableArguments count] >= 2) {
// Remove relaunch path
[executableArguments removeObjectAtIndex:0];
// Set and remove executablePath
executablePath = [executableArguments objectAtIndex:0];
[executableArguments removeObjectAtIndex:0];
- // Set and remove parentProcessId
- parentProcessId = (pid_t)[[executableArguments objectAtIndex:0] intValue];
- [executableArguments removeObjectAtIndex:0];
+ if ([[executablePath pathExtension] isEqualToString:@""]) {
+ NSTask *task = [[NSTask alloc] init];
+ [task setLaunchPath:@"/usr/bin/arch"];
+ [executableArguments insertObject:executablePath atIndex:0];
+#if defined __ppc__
+ [executableArguments insertObject:@"-ppc" atIndex:0];
+#elif defined __i368__
+ [executableArguments insertObject:@"-i386" atIndex:0];
+#elif defined __ppc64__
+ [executableArguments insertObject:@"-ppc64" atIndex:0];
+#elif defined __x86_64__
+ [executableArguments insertObject:@"-x86_64" atIndex:0];
+#endif
+ [task setArguments:executableArguments];
+ [task launch];
+ [task release];
+ }
+ // Relaunch GUI application
+ else {
+ [[NSWorkspace sharedWorkspace] openFile:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:[executablePath UTF8String] length:strlen([executablePath UTF8String])]];
+ }
+ exit(0);
}
- if (getppid() == 1) // ppid is launchd (1) => parent terminated already
- [self relaunch];
- [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(watchdog:) userInfo:nil repeats:YES];
}
return self;
}
-- (void) relaunch
-{
- // Relaunch binary application
- if ([[executablePath pathExtension] isEqualToString:@""]) {
- NSTask *task = [[NSTask alloc] init];
- [task setLaunchPath:@"/usr/bin/arch"];
- [executableArguments insertObject:executablePath atIndex:0];
-#if defined __ppc__ || defined __i368__
- [executableArguments insertObject:@"-32" atIndex:0];
-#elif defined __ppc64__ || defined __x86_64__
- [executableArguments insertObject:@"-64" atIndex:0];
-#endif
- [task setArguments:executableArguments];
- [task launch];
- [task release];
- }
- // Relaunch GUI application
- else {
- [[NSWorkspace sharedWorkspace] openFile:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:[executablePath UTF8String] length:strlen([executablePath UTF8String])]];
- }
-
- NSString* path = NSTemporaryDirectory();
- if (path)
- {
- path = [path stringByAppendingPathComponent:@"relaunch"];
-#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
- [[NSFileManager defaultManager] removeFileAtPath:path handler:nil];
-#else
- [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
-#endif
- }
- exit(0);
-}
-
@end
-
-int main (int argc, const char * argv[])
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- [NSApplication sharedApplication];
- [[[TerminationListener alloc] init] autorelease];
- [[NSApplication sharedApplication] run];
-
- [pool drain];
- return EXIT_SUCCESS;
-}
View
17 cocoaDialog.xcodeproj/project.pbxproj
@@ -477,6 +477,7 @@
8D11072C0486CEB800E47090 /* Sources */,
8D11072E0486CEB800E47090 /* Frameworks */,
A78A8CEA143784BD007AE363 /* CopyFiles */,
+ A7D4043E153C38E0005FA3CD /* ShellScript */,
);
buildRules = (
);
@@ -554,6 +555,22 @@
};
/* End PBXResourcesBuildPhase section */
+/* Begin PBXShellScriptBuildPhase section */
+ A7D4043E153C38E0005FA3CD /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "/server/repositories/github/sparkle-release/src/sparkle-release";
+ };
+/* End PBXShellScriptBuildPhase section */
+
/* Begin PBXSourcesBuildPhase section */
8D11072C0486CEB800E47090 /* Sources */ = {
isa = PBXSourcesBuildPhase;

1 comment on commit f0bf3a7

@gregwjacobs

Thanks again Mark! Cheers!

Please sign in to comment.