unix.c
changeset 2736 1ea068235989
parent 2731 97a409a62741
child 2940 ce57a148333e
--- a/unix.c	Sat Dec 10 07:29:31 2005 +0000
+++ b/unix.c	Sat Dec 10 11:16:45 2005 +0000
@@ -444,8 +444,26 @@
 #endif
 }
 
+#ifdef WITH_COCOA
+void cocoaSetWorkingDirectory(void);
+void cocoaSetupAutoreleasePool(void);
+void cocoaReleaseAutoreleasePool(void);
+#endif
+
 int CDECL main(int argc, char* argv[])
 {
+	int ret;
+
+#ifdef WITH_COCOA
+	cocoaSetupAutoreleasePool();
+    /* This is passed if we are launched by double-clicking */
+	if(argc >= 2 && strncmp (argv[1], "-psn", 4) == 0) {
+		argv[1] = NULL;
+		argc = 1;
+		cocoaSetWorkingDirectory();
+	}
+#endif
+
 	// change the working directory to enable doubleclicking in UIs
 #if defined(__BEOS__) || defined(__linux__)
 	ChangeWorkingDirectory(argv[0]);
@@ -456,7 +474,13 @@
 
 	signal(SIGPIPE, SIG_IGN);
 
-	return ttd_main(argc, argv);
+	ret = ttd_main(argc, argv);
+
+#ifdef WITH_COCOA
+	cocoaReleaseAutoreleasePool();
+#endif
+
+	return ret;
 }
 
 void DeterminePaths(void)