<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: locking handles in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/locking-handles/m-p/31583#M7024</link>
    <description>Hi! &lt;BR /&gt;
 &lt;BR /&gt;
Actually, the usage of handle locks is deprecated - as in "not needed anymore". It's only there for compatibility's sake (it does nothing, but you don't have to modify your existing codes). &lt;BR /&gt;
 &lt;BR /&gt;
So feel free to get rid of them. &lt;BR /&gt;
 &lt;BR /&gt;
HTH: &lt;BR /&gt;
Andras.</description>
    <pubDate>Thu, 23 Feb 2006 14:37:46 GMT</pubDate>
    <dc:creator>Andras Babos</dc:creator>
    <dc:date>2006-02-23T14:37:46Z</dc:date>
    <item>
      <title>locking handles</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/locking-handles/m-p/31581#M7022</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am a bit confused as to when I should lock/set handles.&lt;BR /&gt;&lt;BR /&gt;From looking at some examples eg. Do_CreatePicture() in Element_Basics.cpp it looks like I should lock handles when I use them. Also in the 'About BM Manager' help file it says that BMAllocateHandle allocates a relocatable block of memory and you must use BMModifyHandle to lock a relocatable before using and unlock after!&lt;BR /&gt;&lt;BR /&gt;My APX does not currently lock any handles and I've noticed that sometimes it throws an exception when I delete or change elements (both operations allocate and manipulate handles).&lt;BR /&gt;&lt;BR /&gt;These things have caused me to start the long process of updating all my code so that it locks handles before using them.&lt;BR /&gt;&lt;BR /&gt;What makes me unsure (and why I never considered this before) is that many examples do not lock handles before they use them.&lt;BR /&gt;eg. &lt;BR /&gt;* The ACAPI_ElementSet_Create help file&lt;BR /&gt;* Do_CreateLabel() in Element_Basics.cpp&lt;BR /&gt;&lt;BR /&gt;Also:&lt;BR /&gt;* Are the handles returned from functions such as ACAPI_Element_GetMemo relocatable?&lt;BR /&gt;&lt;BR /&gt;* Do I have to lock handles to access them or only to write to them.&lt;BR /&gt;eg. should i lock the params handle before this&lt;BR /&gt;if((*memo.params)[paramIndex].value.real &amp;gt; 0.0001)&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;* Do have to unlock handles before reallocating them&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Adam&lt;/DIV&gt;</description>
      <pubDate>Mon, 07 Aug 2023 09:23:01 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/locking-handles/m-p/31581#M7022</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-07T09:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: locking handles</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/locking-handles/m-p/31582#M7023</link>
      <description>&lt;BLOCKQUOTE&gt;adambutler wrote:&lt;BR /&gt;I am a bit confused as to when I should lock/set handles.&lt;/BLOCKQUOTE&gt;

I can't tell you definitively about the implementation of Handles in the ArchiCAD API, but some general advice may help.&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
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.</description>
      <pubDate>Wed, 22 Feb 2006 23:43:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/locking-handles/m-p/31582#M7023</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2006-02-22T23:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: locking handles</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/locking-handles/m-p/31583#M7024</link>
      <description>Hi! &lt;BR /&gt;
 &lt;BR /&gt;
Actually, the usage of handle locks is deprecated - as in "not needed anymore". It's only there for compatibility's sake (it does nothing, but you don't have to modify your existing codes). &lt;BR /&gt;
 &lt;BR /&gt;
So feel free to get rid of them. &lt;BR /&gt;
 &lt;BR /&gt;
HTH: &lt;BR /&gt;
Andras.</description>
      <pubDate>Thu, 23 Feb 2006 14:37:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/locking-handles/m-p/31583#M7024</guid>
      <dc:creator>Andras Babos</dc:creator>
      <dc:date>2006-02-23T14:37:46Z</dc:date>
    </item>
  </channel>
</rss>

