adambutler wrote:
I am a bit confused as to when I should lock/set handles.
I can't tell you definitively about the implementation of Handles in the ArchiCAD API, but some general advice may help.
Under the Mac OS prior to Mac OS X, handles could be relocated under a wide variety of circumstances, but under Mac OS X they might only be relocated if the size is increased. Therefore, locking handles is redundant in many cases.
It has always been safe to read a value from a handle by double dereferencing the address, on the assumption that nothing could possibly occur to relocate the handle in the interim.
My practice is to be cautious and lock handles before accessing data, particularly because I often work with a pointer which is the dereferenced handle address. If the block was to be relocated, the pointer would be invalidated. A locked handle should be unlocked to avoid subsequent problems on the Mac OS.
Ralph Wessel BArch
Software Engineer Speckle Systems