diff options
author | welch <welch> | 1998-08-17 11:56:45 (GMT) |
---|---|---|
committer | welch <welch> | 1998-08-17 11:56:45 (GMT) |
commit | 5f87638c7314cbf831c3f54cdd78f30304035191 (patch) | |
tree | 9f7c117541016a56b541eff227ca138c9ffee029 /mac | |
parent | d68ee6b7bc4ace8da902d08f5ecfa87caf914201 (diff) | |
download | tcl-5f87638c7314cbf831c3f54cdd78f30304035191.zip tcl-5f87638c7314cbf831c3f54cdd78f30304035191.tar.gz tcl-5f87638c7314cbf831c3f54cdd78f30304035191.tar.bz2 |
Updates for Jim
Diffstat (limited to 'mac')
-rw-r--r-- | mac/tclMacResource.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/mac/tclMacResource.c b/mac/tclMacResource.c index db06571..0689860 100644 --- a/mac/tclMacResource.c +++ b/mac/tclMacResource.c @@ -1241,7 +1241,7 @@ Tcl_MacEvalResource( Handle sourceText; Str255 rezName; char msg[200]; - int result; + int result, iOpenedResFile = false; short saveRef, fileRef = -1; char idStr[64]; FSSpec fileSpec; @@ -1257,7 +1257,8 @@ Tcl_MacEvalResource( if (nativeName == NULL) { return TCL_ERROR; } - err = FSpLocationFromPath(strlen(nativeName), nativeName, &fileSpec); + err = FSpLocationFromPath(strlen(nativeName), nativeName, + &fileSpec); Tcl_DStringFree(&buffer); if (err != noErr) { Tcl_AppendResult(interp, "Error finding the file: \"", @@ -1273,6 +1274,7 @@ Tcl_MacEvalResource( } UseResFile(fileRef); + iOpenedResFile = true; } else { /* * The default behavior will search through all open resource files. @@ -1313,7 +1315,8 @@ Tcl_MacEvalResource( if (result == TCL_RETURN) { result = TCL_OK; } else if (result == TCL_ERROR) { - sprintf(msg, "\n (rsrc \"%.150s\" line %d)", resourceName, + sprintf(msg, "\n (rsrc \"%.150s\" line %d)", + resourceName, interp->errorLine); Tcl_AddErrorInfo(interp, msg); } @@ -1330,12 +1333,27 @@ Tcl_MacEvalResource( ".", NULL); rezEvalCleanUp: + + /* + * TRICKY POINT: The code that you are sourcing here could load a + * shared library. This will go AHEAD of the resource we stored away + * in saveRef on the resource path. + * If you restore the saveRef in this case, you will never be able + * to get to the resources in the shared library, since you are now + * pointing too far down on the resource list. + * So, we only reset the current resource file if WE opened a resource + * explicitly, and then only if the CurResFile is still the + * one we opened... + */ + + if (iOpenedResFile && (CurResFile() == fileRef)) { + UseResFile(saveRef); + } + if (fileRef != -1) { CloseResFile(fileRef); } - UseResFile(saveRef); - return result; } |