License delivery maintenance is planned for Saturday, July 26, between 12:00 and 20:00 CEST. During this time, you may experience outages or limited availability across our services, including BIMcloud SaaS, License Delivery, Graphisoft ID (for customer and company management), Graphisoft Store, and BIMx Web Viewer. More details…
2021-10-15 09:15 AM
I noticed in the DG_Test Example project that the MyPrefs struct is made only from static variables. For some time I am struggling to Debug my code for saving this kind of struct into the preferences.
In the hashtable below I want to store multiple dialog Item settings, of the same class. I keep getting memory errors. Is this because I am trying to change the memory dynamically, by adding elements to the HashTable?
typedef struct {
Int32 version;
API_AttributeIndex layer;
API_AttributeIndex hatchLineType;
API_AttributeIndex hatchFill;
short hatchPen;
short hatchbkgPen;
short hatchContPen;
bool hatchGlobal;
bool hatchWithArea;
short filler;
GS::HashTable<Type1, short> someStuffToKeepHere;//This is what I want to do.
} MyPrefs;
Solved! Go to Solution.
2021-10-15 01:44 PM - edited 2021-10-15 03:40 PM
Yes, this is because GS::HashTable contains dynamically allocated data. DG_Test just writes it to the preferences based on the static size of the struct:
ACAPI_SetPreferences (CURR_ADDON_VERS, sizeof (MyPrefs), (GSPtr) &prefsData);
If you have complex structures in your class, you have to serialize it to a binary blob, and write that one in preferences.
You can find a detailed explanation here:
https://archicadapi.graphisoft.com/Archicad-maze-generator-add-on-tutorial-part-3
2021-10-15 01:44 PM - edited 2021-10-15 03:40 PM
Yes, this is because GS::HashTable contains dynamically allocated data. DG_Test just writes it to the preferences based on the static size of the struct:
ACAPI_SetPreferences (CURR_ADDON_VERS, sizeof (MyPrefs), (GSPtr) &prefsData);
If you have complex structures in your class, you have to serialize it to a binary blob, and write that one in preferences.
You can find a detailed explanation here:
https://archicadapi.graphisoft.com/Archicad-maze-generator-add-on-tutorial-part-3