Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 
Developer forum

Save preferences with ACAPI_SetPreferences(ver, size, preferences) where prefs contains a hashtable;

Mihalcea Bogdan

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;

Viktor Kovacs
Graphisoft Alumni
Graphisoft Alumni

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:


Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!