<?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 Allow palette-using add-on to use FreeData in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Allow-palette-using-add-on-to-use-FreeData/m-p/289448#M4091</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;Hi!&lt;BR /&gt;&lt;BR /&gt;I am currently implementing a palette inside my add-on, and have run into a new problem.&lt;BR /&gt;My Add-on now has a palette that can be opened / closed. So far, so good.&lt;BR /&gt;&lt;BR /&gt;The problem is, during development, I cannot apply changes to the add-on and rebuild it, as it does not get unloaded when I close the palette.&lt;BR /&gt;In the "Control the Load unload mechanism" article, the following is said : &lt;BR /&gt;About FreeData : "Some operations (e.g. when an add-on has its own palette[...]) cause the add-on to stay in memory without calling this function."&lt;BR /&gt;And : "An add-on must be unloaded when [...], &lt;STRONG&gt;all the palettes have been dismissed&lt;/STRONG&gt;, [...]."&lt;BR /&gt;&lt;BR /&gt;So far, here are my "Init" functions (called separately through the code) and my "Closing" functions (called when the user closes the palette) :&lt;BR /&gt;&lt;BR /&gt;Init functions :
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;// Initialising callback
DGModelessInit(ACAPI_GetOwnResModule(), 32400,
			ACAPI_GetOwnResModule(), PaletteCallback, (DGUserData)&amp;amp;pltctrl, true);	

// Inside the callback, on DG_MSG_INIT :
ACAPI_RegisterModelessWindow(dialID, PaletteAPIControlCallBack,
			API_PalEnabled_FloorPlan + [...] + API_PalEnabled_Layout)
&lt;/PRE&gt;
Closing functions :
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;if (pltctrl.dialID != 0 &amp;amp;&amp;amp; DGIsDialogOpen(pltctrl.dialID))
		DGModelessClose(pltctrl.dialID);	
if (pltctrl.dialID != 0)
{		
	DGEndProcessEvents(pltctrl.dialID);
	ACAPI_UnregisterModelessWindow(pltctrl.dialID);
	DGDestroyModelessDialog(pltctrl.dialID);
	DGDestroyPalette(pltctrl.dialID);
}
&lt;/PRE&gt;
Using the debugger, I made sure every of these functions were launched.&lt;BR /&gt;Did I miss something to unload my Palettes?&lt;BR /&gt;Thanks !&lt;/DIV&gt;</description>
    <pubDate>Tue, 06 Dec 2022 12:39:23 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-12-06T12:39:23Z</dc:date>
    <item>
      <title>Allow palette-using add-on to use FreeData</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Allow-palette-using-add-on-to-use-FreeData/m-p/289448#M4091</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi!&lt;BR /&gt;&lt;BR /&gt;I am currently implementing a palette inside my add-on, and have run into a new problem.&lt;BR /&gt;My Add-on now has a palette that can be opened / closed. So far, so good.&lt;BR /&gt;&lt;BR /&gt;The problem is, during development, I cannot apply changes to the add-on and rebuild it, as it does not get unloaded when I close the palette.&lt;BR /&gt;In the "Control the Load unload mechanism" article, the following is said : &lt;BR /&gt;About FreeData : "Some operations (e.g. when an add-on has its own palette[...]) cause the add-on to stay in memory without calling this function."&lt;BR /&gt;And : "An add-on must be unloaded when [...], &lt;STRONG&gt;all the palettes have been dismissed&lt;/STRONG&gt;, [...]."&lt;BR /&gt;&lt;BR /&gt;So far, here are my "Init" functions (called separately through the code) and my "Closing" functions (called when the user closes the palette) :&lt;BR /&gt;&lt;BR /&gt;Init functions :
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;// Initialising callback
DGModelessInit(ACAPI_GetOwnResModule(), 32400,
			ACAPI_GetOwnResModule(), PaletteCallback, (DGUserData)&amp;amp;pltctrl, true);	

// Inside the callback, on DG_MSG_INIT :
ACAPI_RegisterModelessWindow(dialID, PaletteAPIControlCallBack,
			API_PalEnabled_FloorPlan + [...] + API_PalEnabled_Layout)
&lt;/PRE&gt;
Closing functions :
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;if (pltctrl.dialID != 0 &amp;amp;&amp;amp; DGIsDialogOpen(pltctrl.dialID))
		DGModelessClose(pltctrl.dialID);	
if (pltctrl.dialID != 0)
{		
	DGEndProcessEvents(pltctrl.dialID);
	ACAPI_UnregisterModelessWindow(pltctrl.dialID);
	DGDestroyModelessDialog(pltctrl.dialID);
	DGDestroyPalette(pltctrl.dialID);
}
&lt;/PRE&gt;
Using the debugger, I made sure every of these functions were launched.&lt;BR /&gt;Did I miss something to unload my Palettes?&lt;BR /&gt;Thanks !&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Dec 2022 12:39:23 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Allow-palette-using-add-on-to-use-FreeData/m-p/289448#M4091</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-06T12:39:23Z</dc:date>
    </item>
  </channel>
</rss>

