Archicad C++ API
About Archicad add-on development using the C++ API.

Archicad crashes after closing dialog box

Anonymous
Not applicable
Hi,

I've got working code for retrieving and displaying the amount of unique operators and targets of SEOs within a project. This works fine until I close the dialog box, and Archicad crashes. I've debugged and this is the error Visual Studio gave me:
Exception thrown at 0x000000000033203A in Archicad.exe: 0xC0000005: Access violation executing location 0x000000000033203A. occurred

Here's the code for getting the operators:
static int GetNumberOfOperators() {

	int size = 0;
	GSErrCode err = NoError;

	GS::Array<API_Guid>	allElements;
	GS::Array<GS::UniString> currentOperators;
	ACAPI_Element_GetElemList(API_ZombieElemID, &allElements);

	for (const API_Guid& guid : allElements) {
		GS::Array<GS::UniString> allOperators;
		API_Guid** guid_Operators = nullptr;
		Int32 nLinks;
		bool insert = true;
		err = ACAPI_Element_SolidLink_GetOperators(guid, &guid_Operators, &nLinks);

		if (err != NoError)
			continue;

		for (int i = 0; i < nLinks; i++) {
			GS::Guid nGuid = APIGuid2GSGuid(guid_Operators[0]);
			GS::UniString sGuid = nGuid.ToUniString();
			for (USize a = 0; a < currentOperators.GetSize(); a++) {
				if (sGuid == currentOperators)
					insert = false;
			}
			if (insert) {
				allOperators.Insert(i, sGuid);
				currentOperators...

The code for getting targets is pretty much exactly the same except for getting targets instead of operators.

Any help with this would be gratefully received.

Thanks
8 REPLIES 8
Akos Somorjai
Graphisoft
Graphisoft
Hi,

This is the correct line:

GS::Guid nGuid = APIGuid2GSGuid((*guid_Operators));

Best, Akos
Akos Somorjai
Graphisoft
Graphisoft
Akos wrote:
Hi,

This is the correct line:

GS::Guid nGuid = APIGuid2GSGuid((*guid_Operators));

Best, Akos


Sorry, bbcode tricked me:
GS::Guid nGuid = APIGuid2GSGuid((*guid_Operators));
Anonymous
Not applicable
Hi,

Thanks for the reply, although unfortunately this didn't fix my issue. Is there anything else that could be the cause of the crash?

Thanks
Akos Somorjai
Graphisoft
Graphisoft
Hi,

Then I guess the problem is not in this function. Could you please send me the bug ID from GSReport?

Thanks, Akos

P.S.: you can use a GS::HashSet instead of the GS::Array, then you don't have to check if the guid is already in there.
Anonymous
Not applicable
Hi,

Here's the bug ID:
AC21-2019-07-26-09-42-25-4517

Also, thanks for the suggestion to use GS::HashSet.

Cheers
Akos Somorjai
Graphisoft
Graphisoft
Thanks!

It hasn't showed up in our crash report database yet; did you send it in?

Best, Akos
Anonymous
Not applicable
Hi,

I've tried sending it again:
AC21-2019-07-30-11-04-47-2331

Cheers

EDIT: I've managed to solve the problem, as I was looking at the entirely wrong function. My output function had a memory error which was causing the problem. Thanks for the assistance anyway.
Akos Somorjai
Graphisoft
Graphisoft
Hi,

This crash happens when your add-on is being unloaded, and its coming from your add-on. Maybe you free something twice?

SEO_Counter_Export.apx + 19243
C0000005 ACCESS_VIOLATION reading location 0xffffffffffffffff

Best, Akos