Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!olivea!apple!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Is this possible with the Resource Manager? Message-ID: <12158@goofy.Apple.COM> Date: 19 Feb 91 03:17:50 GMT References: <1CE00001.ed5n0r@tbomb.ice.com> Organization: Apple Computer, Inc. Lines: 47 In article <1CE00001.ed5n0r@tbomb.ice.com> time@ice.com writes: > > if (*resHand!=NULL) { /* The resource was loaded */ > DetatchResource(resHand); > onDiskHand = GetResource(type, id); > DetachResource(onDiskHand); > /* Now move that resource back into place... */ > onDiskHand2 = GetResource(type, id); > SizeResource(onDiskHand2, GetHandleSize(resHand)); > BlockMove(*resHand, *onDiskHand2, GetHandleSize(resHand)); > ChangedResource(resHand); > } I think you may have mis-typed something here. It doesn't make much sense to call ChangedResource with something that's been detached (resHand). Anyway, a more fundamental problem is that the "current" handle to the resource is onDiskHand2, not resHand. It's possible that some piece of code was using resHand, and that code will be screwed. You have to do this without calling DetachResource. One way that comes to mind is: if (*resHand != NULL) { /* save current contents */ oldSize = GetHandleSize(resHand); save = NewHandle(oldSize); BlockMove(*resHand, *save, oldSize); EmptyHandle(resHand); LoadResource(resHand); /* re-load disk copy */ diskCopy = resHand; HandToHand(diskCopy); /* make a copy of it */ /* restore original version */ SetHandleSize(resHand, oldSize); BlockMove(*save, *resHand, oldSize); DisposHandle(save); } -- Larry Rosenstein, Object Specialist Apple Computer, Inc. 20525 Mariani Ave, MS 3-PK Cupertino, CA 95014 AppleLink:Rosenstein1 domain:lsr@Apple.COM UUCP:{sun,voder,nsc,decwrl}!apple!lsr