summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorwolfsuit <wolfsuit>2001-10-19 07:14:18 (GMT)
committerwolfsuit <wolfsuit>2001-10-19 07:14:18 (GMT)
commitcc3206dc8ed8d9a3578bed4c9f1418bc599ed405 (patch)
tree5f0eadab93883bee2dc580704565401c22daa687 /macosx
parent806c368f2c7102d7f0b7f5a47566338fd359e0df (diff)
downloadtk-cc3206dc8ed8d9a3578bed4c9f1418bc599ed405.zip
tk-cc3206dc8ed8d9a3578bed4c9f1418bc599ed405.tar.gz
tk-cc3206dc8ed8d9a3578bed4c9f1418bc599ed405.tar.bz2
Two things:
1) Use the Tcl_SetStartupScript API - a cleaner way than inserting the name into argv. 2) Can't rely on # of arguments from the Finder to see whether we should look for the AppMain. Now it inserts argv[1] = -psn_xxxxx, and who knows what it might do in the future.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXAppInit.c62
1 files changed, 28 insertions, 34 deletions
diff --git a/macosx/tkMacOSXAppInit.c b/macosx/tkMacOSXAppInit.c
index 52d17c4..501a1a3 100644
--- a/macosx/tkMacOSXAppInit.c
+++ b/macosx/tkMacOSXAppInit.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXAppInit.c,v 1.1.2.2 2001/10/17 07:04:22 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXAppInit.c,v 1.1.2.3 2001/10/19 07:14:18 wolfsuit Exp $
*/
#include <pthread.h>
#include "tk.h"
@@ -80,6 +80,7 @@ main(argc, argv)
* Variable used to take care of
* lazy font initialization
*/
+ CFBundleRef bundleRef;
/*
* The following #if block allows you to change the AppInit
@@ -124,41 +125,34 @@ main(argc, argv)
* the auto_path. If we don't find the startup script, we just bag
* it, assuming the user is starting up some other way.
*/
-
- if (argc == 1) {
- CFBundleRef bundleRef;
- bundleRef = CFBundleGetMainBundle();
- if (bundleRef != NULL) {
- CFURLRef appMainURL;
- appMainURL = CFBundleCopyResourceURL(bundleRef,
- CFSTR("AppMain"),
- CFSTR("tcl"),
- CFSTR("Scripts"));
+
+ bundleRef = CFBundleGetMainBundle();
+
+ if (bundleRef != NULL) {
+ CFURLRef appMainURL;
+ appMainURL = CFBundleCopyResourceURL(bundleRef,
+ CFSTR("AppMain"),
+ CFSTR("tcl"),
+ CFSTR("Scripts"));
- if (appMainURL != NULL) {
- CFURLRef scriptFldrURL;
- char *argv1 = malloc(MAX_PATH_LEN + 1);
-
- if (CFURLGetFileSystemRepresentation (appMainURL, true,
- argv1, MAX_PATH_LEN)) {
- char *tmpArg0 = argv[0];
- argv = (char **) malloc(2*sizeof(char *));
- argv[0] = tmpArg0;
- argv[1] = argv1;
- argc = 2;
-
- scriptFldrURL = CFBundleCopyResourceURL(bundleRef,
- CFSTR("Scripts"),
- NULL,
- NULL);
- CFURLGetFileSystemRepresentation(scriptFldrURL,
- true, scriptPath, MAX_PATH_LEN);
- CFRelease(scriptFldrURL);
- } else {
- free(argv1);
- }
- CFRelease(appMainURL);
+ if (appMainURL != NULL) {
+ CFURLRef scriptFldrURL;
+ char *startupScript = malloc(MAX_PATH_LEN + 1);
+
+ if (CFURLGetFileSystemRepresentation (appMainURL, true,
+ startupScript, MAX_PATH_LEN)) {
+ TclSetStartupScriptFileName(startupScript);
+ scriptFldrURL = CFBundleCopyResourceURL(bundleRef,
+ CFSTR("Scripts"),
+ NULL,
+ NULL);
+ CFURLGetFileSystemRepresentation(scriptFldrURL,
+ true, scriptPath, MAX_PATH_LEN);
+ CFRelease(scriptFldrURL);
+ } else {
+ free(startupScript);
}
+ CFRelease(appMainURL);
}
}