<?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: Archicad crashes sometimes when calling API function in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280496#M2477</link>
    <description>Hello Ralph,&lt;BR /&gt;
&lt;BR /&gt;
I tried it with Archicad 22, 23, and 24 on Windows. I compile with platform toolset Visual Studio 2019 (v142), C++20 &lt;BR /&gt;
&lt;BR /&gt;
These code findings are due to the fact that I removed some code from my example (of course made sure it still crashes).</description>
    <pubDate>Fri, 18 Sep 2020 06:45:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-09-18T06:45:37Z</dc:date>
    <item>
      <title>Archicad crashes sometimes when calling API function</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280492#M2473</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;in our team, we develop an Archicad plugin which uses the Archicad API. Here I encountered the following problem: &lt;BR /&gt;When I call the API function ACAPI_Attribute_Modify with a MaterialType attribute shortly before or after I click somewhere on the UI, Archicad crashes.&lt;BR /&gt;The values of the material attribute seem to be OK. Calling ACAPI_Attribute_Get immediately before does not cause any problems. Do you have &lt;BR /&gt;an idea of what I could do not to make it crash?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 11:46:51 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280492#M2473</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-14T11:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Archicad crashes sometimes when calling API function</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280493#M2474</link>
      <description>Would it be possible to post some of the code around the call to ACAPI_Attribute_Modify? I haven't seen a problem with it before – perhaps there is a bug in the code?</description>
      <pubDate>Tue, 15 Sep 2020 14:28:31 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280493#M2474</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-09-15T14:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Archicad crashes sometimes when calling API function</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280494#M2475</link>
      <description>Here is a code example I am able to reconstruct the problem with:
&lt;PRE&gt;GSErrCode makeRed(int id)
	{
		API_Attribute attrib;
		BNClear(attrib);

		attrib.header.typeID = API_MaterialID;
		attrib.header.index = API_AttributeIndex(id);
		if (auto err = ACAPI_Attribute_Get(&amp;amp;attrib); err != 0)
		{
			return err;
		}

		attrib.material.emissionAtt = 0;
		attrib.material.emissionRGB = API_RGBColor{0, 0, 0};
		attrib.material.mtype = APIMater_GeneralID;
		attrib.material.specularPc = 74;
		attrib.material.transpAtt = 0;
		attrib.material.transpPc = 0;
		attrib.material.surfaceRGB = API_RGBColor{ 1, 0, 0 };
		IO::Location loc;
		API_Texture texture;
		BNZeroMemory(&amp;amp;texture, sizeof(API_Texture));
		attrib.material.texture = texture;

		return ACAPI_Attribute_Modify(&amp;amp;attrib, NULL);
	}&lt;/PRE&gt;
I run this code and click somewhere in the UI very fast after I started it.</description>
      <pubDate>Thu, 17 Sep 2020 06:53:06 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280494#M2475</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-17T06:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Archicad crashes sometimes when calling API function</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280495#M2476</link>
      <description>Could you also tell me:&lt;BR /&gt;
- Which version of Archicad you're targeting&lt;BR /&gt;
- On what platform&lt;BR /&gt;
- With which compiler and version&lt;BR /&gt;
- And (if using VS) which toolset you're using, or (if Xcode) which C++ dialect you are using, e.g. C++14&lt;BR /&gt;
&lt;BR /&gt;
I only noticed a couple if unusual things in your code, but they shouldn't cause a crash:&lt;BR /&gt;
1) This line: IO::Location loc;&lt;BR /&gt;
The variable "loc" is declared but never used for anything&lt;BR /&gt;
&lt;BR /&gt;
2) These lines:&lt;BR /&gt;
	API_Texture texture;&lt;BR /&gt;
	BNZeroMemory(&amp;amp;texture, sizeof(API_Texture));&lt;BR /&gt;
	attrib.material.texture = texture;&lt;BR /&gt;
…could be just:&lt;BR /&gt;
	BNZeroMemory(&amp;amp;attrib.material.texture, sizeof(API_Texture));</description>
      <pubDate>Thu, 17 Sep 2020 08:48:07 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280495#M2476</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-09-17T08:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Archicad crashes sometimes when calling API function</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280496#M2477</link>
      <description>Hello Ralph,&lt;BR /&gt;
&lt;BR /&gt;
I tried it with Archicad 22, 23, and 24 on Windows. I compile with platform toolset Visual Studio 2019 (v142), C++20 &lt;BR /&gt;
&lt;BR /&gt;
These code findings are due to the fact that I removed some code from my example (of course made sure it still crashes).</description>
      <pubDate>Fri, 18 Sep 2020 06:45:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280496#M2477</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-18T06:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Archicad crashes sometimes when calling API function</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280497#M2478</link>
      <description>&lt;BLOCKQUOTE&gt;eziebarth wrote:&lt;BR /&gt;I tried it with Archicad 22, 23, and 24 on Windows. I compile with platform toolset Visual Studio 2019 (v142), C++20 &lt;BR /&gt;
These code findings are due to the fact that I removed some code from my example (of course made sure it still crashes).&lt;/BLOCKQUOTE&gt;
I suspect the cause of the problem may be due to the VS toolset you're using. It's important to observe the system requirements for each API version, e.g.: &lt;A href="http://archicadapi.graphisoft.com/documentation/system-requirements" target="_blank"&gt;&lt;LINK_TEXT text="http://archicadapi.graphisoft.com/docum ... quirements"&gt;http://archicadapi.graphisoft.com/documentation/system-requirements&lt;/LINK_TEXT&gt;&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
For AC22 you need to use the 2015 toolset (v140). For AC23 and 24 you need to use the 2017 toolset (v141). You can do this with VS 2019, but just make sure each target has the correct toolset selected (that's what we do). I would also recommend not exceeding C++14 at the moment – I don't know if this is critical, but GS does this in the API examples.</description>
      <pubDate>Fri, 18 Sep 2020 08:07:18 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280497#M2478</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-09-18T08:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Archicad crashes sometimes when calling API function</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280498#M2479</link>
      <description>Hello Ralph,&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your advice. I tried it with AC 24 and 2017 toolset (v141). Unfortunately, the crashes still happen. I can try if I can reproduce the crash by using one of the code examples which are delivered with the dev kit. That will take me some time. Would that be helpful?</description>
      <pubDate>Fri, 25 Sep 2020 07:25:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280498#M2479</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-25T07:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Archicad crashes sometimes when calling API function</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280499#M2480</link>
      <description>It is sometimes difficult to pinpoint the cause of a crash. The API has bugs, but it is rare for this to be the cause and it can require a lot of effort to prove it.&lt;BR /&gt;
&lt;BR /&gt;
I recommend trying to narrow the code to do as little as possible while still causing a crash. If you find that the crashing stops after a change, that could provide a clue to the source of the problem. It will be very useful if you can reproduce the crash using an API example. If the fault is narrowed to a specific function, forward it to the API support team and they will help to resolve it (either confirming a bug or providing guidance to avoid the problem).&lt;BR /&gt;
&lt;BR /&gt;
There are many approaches to debugging. A tool that performs bounds checking on all memory accesses could trap memory-handling errors. This is the worst kind of problem because a memory-handling fault does not always cause an immediate crash. The crash (or other odd behaviour) might follow much later.</description>
      <pubDate>Fri, 25 Sep 2020 09:32:17 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Archicad-crashes-sometimes-when-calling-API-function/m-p/280499#M2480</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-09-25T09:32:17Z</dc:date>
    </item>
  </channel>
</rss>

