[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reopening resource files calls CurResFile!?

Hello. We discovered the following behavior with resource files while
developing with MCL 2.0 beta and system 7.0.1: When one calls
OpenResFile on an already-opened file, that file is made current in
direct opposition to Inside Mac, p. I-115 ("If the resource file is
already open, it [OpenResFile] doesn't make it the current resource
file;"). A session that shows the problem is at this message's end.
The gist:

- open file "a" (which contains "TEXT" resource "a")
- open file "b" (which contains "TEXT" resource "b")
- get "TEXT" resources "a" and "b", which returns nice (non-null) handles

- open file "a" again, which causes the current resource file to be a (!)
- get "TEXT" resources "b", which returns a null handles (no good)

Interestingly, if MCL does some paging activity (such as when we
switch to the Finder to open a file in FRED) the last get ("TEXT"
resource "b") returns a non-nil handle! Someone must reset the current
resource file. It seems to be a Mac OS bug. Are we missing something?
We'd appreciate any comments from you Mac/Resource wizzards!


==== The transcript ====

(defun print-cur-res-file ()
  (format t "~&CurResFile: ~S" (#_CurResFile )))

? (print-cur-res-file)
CurResFile: 2258                        ;MCL's resource file id is current
? (with-pstrs ((p-filename "a")) (#_OpenResFile p-filename))
2822                                    ;a's resource id
? (print-cur-res-file)
CurResFile: 2822                        ;now a is current
? (with-pstrs ((p-filename "b")) (#_OpenResFile p-filename))
2916                                    ;b's resource id
? (print-cur-res-file)
CurResFile: 2916                        ;now b is current
? (with-pstrs ((p-res-name "a")) (#_GetNamedResource :|TEXT| p-res-name))
#<A Mac Handle to resource 'TEXT'(128) : Unlocked, Size 17 #x286834>
? (with-pstrs ((p-res-name "b")) (#_GetNamedResource :|TEXT| p-res-name))
#<A Mac Handle to resource 'TEXT'(128) : Unlocked, Size 17 #x286820>
? (with-pstrs ((p-filename "a")) (#_OpenResFile p-filename))
? (print-cur-res-file)
CurResFile: 2822                        ;now a is current, again!!
? (with-pstrs ((p-res-name "b")) (#_GetNamedResource :|TEXT| p-res-name))
#<A Null Mac Pointer>                   ;bad news

==== End of transcript ====