We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

crash around ACAPI_3D_GetCurrentWindowSight

Anonymous
Not applicable
Hi, guys.

There is something strange occurs in my add-on. I am quite sure the crash happens around ACAPI_3D_GetCurrentWindowSight when it is called for its 3rd time.

I was wondering if the destructor of Modeler::SightPtr itself releases the space created before so I have to create Modeler::SightPtr on the heap rather than stack?

Here is my code:
	AttributeReader attrReader; 
	ModelerAPI::Model model;

	Modeler::SightPtr currentSightPtr;

	GSErrCode sightErr = ACAPI_3D_GetCurrentWindowSight((void**)&currentSightPtr);
	if (sightErr != NoError) {
		return APIERR_CANCEL;
	}

	EXPGetModel(currentSightPtr, &model, &attrReader);
Could anyone help me please? Thanks in advance.
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Anonymous
Not applicable
Maybe I have solved the problem.

Here is my new code:
	AttributeReader attrReader; 
	ModelerAPI::Model model;

	Modeler::Sight* sight = nullptr;
	//Modeler::SightPtr currentSightPtr(sight);

	//GSErrCode sightErr = ACAPI_3D_GetCurrentWindowSight((void**)&currentSightPtr);
	GSErrCode sightErr = ACAPI_3D_GetCurrentWindowSight((void**)&sight);
	if (sightErr != NoError) {
		return APIERR_CANCEL;
	}
	Modeler::SightPtr currentSightPtr(sight);
	EXPGetModel(currentSightPtr, &model, &attrReader);

I am testing it.

View solution in original post

1 REPLY 1
Solution
Anonymous
Not applicable
Maybe I have solved the problem.

Here is my new code:
	AttributeReader attrReader; 
	ModelerAPI::Model model;

	Modeler::Sight* sight = nullptr;
	//Modeler::SightPtr currentSightPtr(sight);

	//GSErrCode sightErr = ACAPI_3D_GetCurrentWindowSight((void**)&currentSightPtr);
	GSErrCode sightErr = ACAPI_3D_GetCurrentWindowSight((void**)&sight);
	if (sightErr != NoError) {
		return APIERR_CANCEL;
	}
	Modeler::SightPtr currentSightPtr(sight);
	EXPGetModel(currentSightPtr, &model, &attrReader);

I am testing it.