马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 1121443108qaz 于 2019-4-22 03:34 编辑
我用一个acdbpolyline对象获得对应的acgecurve3d对象,在这个函数中文档明显提到文档调用者有责任负责删除这个得到的ge曲线,然后我强制转接这个ge曲线指针为复合ge曲线指针pcomp,用getcurvelist获得复合曲线下的子曲线。getcurvelist里文档也明显提到如果复合曲线删除,获得到的子曲线不会被删除。照我理解我应该delete pgecurve3d一次,对acgevoidparray中的每个指针delete一次。实际我测试,两者只可以有一个存在,要么只delete pgecurve3d,要么对voidparray里的每个指针delete。只要同时出现,调试就崩溃了,错误提示是acad.exe返回在afxwinterm()那里的。是文档有错误吗?测试代码见下,我delele pcomp后,curveList里的指针就变成野指针了,次次崩溃。如果把delete后面的语句放到前面都能正确打印。
getcurvelist文档说明为
Returns the list of pointers to the component curves which make up the composite. The curves in curveList are not deleted when the composite is deleted.
getacgecurve文档中说Output pointer to an AcGeCurve3d object that is geometrically identical to dbCurve. The caller of this function is responsible for deleting this AcGeCurve3d object
 - static void xxxMyGrouptest()
- {
- AcDbObjectId entId1 = CSSUtil::selectOne(L"\n请选择一条多段线");
- AcDbPolyline* pPoly = NULL;
- if (acdbOpenObject(pPoly,entId1,AcDb ::kForWrite)==Acad ::eOk)
- {
- AcGeCompositeCurve3d* pComp=NULL;
- if (pPoly->getAcGeCurve((AcGeCurve3d*&)pComp)==Acad ::eOk)
- {
- acutPrintf(L"\nThis a polyline");
- AcGeVoidPointerArray curveList;
- pComp->getCurveList(curveList);
- delete pComp;
- for (int i=0;i<curveList.length();i++)
- {
- AcGeEntity3d* pGe = (AcGeEntity3d*)curveList.at(i);
- if (pGe->isKindOf(AcGe::kLineSeg3d))
- {
- acutPrintf(L"\nIt is a line");
- }
- }
- }
- pPoly->close();
- }
- }
来自: 微社区 |