[Tclresource-commits] Source tclResourceOSX.c,1.16,1.17
Status: Beta
Brought to you by:
bdesgraupes
From: Bernard D. <bde...@us...> - 2004-09-15 09:41:44
|
Update of /cvsroot/tclresource/Source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23628 Modified Files: tclResourceOSX.c Log Message: Bug #1028460 in [attributes] fixed Index: tclResourceOSX.c =================================================================== RCS file: /cvsroot/tclresource/Source/tclResourceOSX.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- tclResourceOSX.c 7 Sep 2004 12:59:28 -0000 1.16 +++ tclResourceOSX.c 15 Sep 2004 09:41:34 -0000 1.17 @@ -461,60 +461,26 @@ saveRef = CurResFile(); UseResFile(resourceRef->fileRef); - if (gotInt == true) { // Don't load the resource in memory SetResLoad(false); - resource = Get1Resource(rezType, rsrcId); - SetResLoad(true); - err = ResError(); - - if (err == resNotFound || resource == NULL) { - Tcl_AppendStringsToObj(resultPtr, "resource not found", - (char *) NULL); - result = TCL_ERROR; - goto attributesDone; - } else if (err != noErr) { - sprintf(buffer, "resource error %d while trying to find resource", err); - Tcl_AppendStringsToObj(resultPtr, buffer, (char *) NULL); - result = TCL_ERROR; - goto attributesDone; - } - } - - if (resourceId != NULL) { - Handle tmpResource; - // Don't load the resource in memory - SetResLoad(false); - tmpResource = Get1NamedResource(rezType, (StringPtr) resourceId); + if (gotResID == true) { + resourceH = Get1Resource(rezType, rsrcId); + err = ResError(); + } else if (resourceName != NULL) { + resourceH = Get1NamedResource(rezType, (StringPtr) resourceName); + err = ResError(); + } + SetResLoad(true); - err = ResError(); - - if (err == resNotFound || tmpResource == NULL) { - Tcl_AppendStringsToObj(resultPtr, "resource not found", - (char *) NULL); - result = TCL_ERROR; - goto attributesDone; - } else if (err != noErr) { - sprintf(buffer, "resource error %d while trying to find resource", err); - Tcl_AppendStringsToObj(resultPtr, buffer, (char *) NULL); - result = TCL_ERROR; - goto attributesDone; - } - - if (gotInt) { - if (resource != tmpResource) { - Tcl_AppendStringsToObj(resultPtr, - "\"-id\" and \"-name\" ", - "values do not point to the same resource", - (char *) NULL); - result = TCL_ERROR; - goto attributesDone; - } - } else { - resource = tmpResource; - } - } + + if (err != noErr) { + sprintf(buffer, "resource error %d while trying to find resource", err); + Tcl_AppendStringsToObj(resultPtr, buffer, (char *) NULL); + result = TCL_ERROR; + goto attributesDone; + } + if (resourceH != NULL) { if (gotValue) { /* * Setting the resource attributes @@ -529,10 +495,17 @@ } theAttrs = GetResAttrs(resource); if (theAttrs != newValue) { - // Set the resChanged flag manually because, if the resProtected - // flag has to be set, it will be immediately active and - // ChangedResource(resource) would fail. - newValue |= resChanged; + // If the user is setting the resChanged flag on, load the + // resource in memory if it is not already there (i-e if its + // master pointer contains NULL) otherwise, upon updating, null + // data would be written to the disk. NB: no need to bother about + // releasing the resource because anyway ReleaseResource() wonÕt + // release a resource whose resChanged attribute has been set. + if (newValue & resChanged) { + if (*resourceH == NULL) { + LoadResource(resourceH); + } + } SetResAttrs(resource, newValue); err = ResError(); if (err != noErr) { @@ -560,6 +533,7 @@ result = TCL_OK; } } + } attributesDone: UseResFile(saveRef); |