Merge pull request '修复 AecDbXSlab 的 L1-L9 内存泄漏' (#85) from company-laptop/fix-aecdbslab-memory-leaks into main
Reviewed-on: https://git.ethereal-realm.top/gjm/envi-code/pulls/85
This commit was merged in pull request #85.
This commit is contained in:
commit
a29822cb69
1 file changed
+58
-15
@@ -203,6 +203,9 @@ DLLIMPEXP AcDbCurve* GetOffsetCurve(AcDbCurve* pCurve,double dOffset,bool bGetIn
|
||||
}
|
||||
return pCurveT;
|
||||
}
|
||||
|
||||
FreeBuffer(0,arCurOff1);
|
||||
FreeBuffer(0,arCurOff2);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -290,9 +293,13 @@ AcDbRegion* CreatePipeRegion(AcDbCurve* pOutSide,AcDbCurve* pInSide)
|
||||
Acad::ErrorStatus es;
|
||||
if ( Acad::eOk == (es = pRegOut->booleanOper(AcDb::kBoolSubtract,pRegIns)))
|
||||
{
|
||||
//booleanOper 不接管第二个操作数
|
||||
delete pRegIns;
|
||||
return pRegOut;
|
||||
}
|
||||
|
||||
delete pRegIns;
|
||||
delete pRegOut;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -922,6 +929,7 @@ bool AecDbXSlab::SetRegionSlab(LPCTSTR pszPoint2ds,double dThick,double dBomEl,c
|
||||
pPl->explode(arCurPtrs);
|
||||
|
||||
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
||||
FreeBuffer(0,arCurPtrs); //explode 碎片不在数据库中,建完截面即释放
|
||||
if (!arRegPtrs.isEmpty())
|
||||
{
|
||||
AcDbRegion* pReg = NULL;
|
||||
@@ -1273,6 +1281,7 @@ bool AecDbXSlab::SetEllipseBasin(double dRmaj,double radiusRatio,double dBomThic
|
||||
pEllipse->getOffsetCurves(dWallWidth,arCurPtrs);
|
||||
|
||||
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
||||
FreeBuffer(0,arCurPtrs); //offset 曲线只用于建截面
|
||||
|
||||
if (arRegPtrs.isEmpty())
|
||||
{
|
||||
@@ -1300,6 +1309,10 @@ bool AecDbXSlab::SetEllipseBasin(double dRmaj,double radiusRatio,double dBomThic
|
||||
SetBaseCurve(&lnPath);
|
||||
}
|
||||
|
||||
//只用到第一个截面,其余自行释放
|
||||
for (int i = 1;i < arRegPtrs.length();i++)
|
||||
delete (AcDbRegion*)arRegPtrs.at(i);
|
||||
|
||||
ptOrg += vt;
|
||||
GetSpecialtyData()->SetAt(KEY_ORGPT,ptOrg,TRUE);
|
||||
GetSpecialtyData()->SetAt(KEY_RAD,dRmaj);
|
||||
@@ -1551,6 +1564,10 @@ int AecDbXSlab::PeelBasinWall(AcDbVoidPtrArray& arWallPtrs)
|
||||
arWallPtrs.append(pWall);
|
||||
}
|
||||
}
|
||||
|
||||
//SetBaseCurve 内部会 clone,碎片用完即释放
|
||||
FreeBuffer(0,arPtrs);
|
||||
pBaseCrv = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1774,10 +1791,8 @@ bool AecDbXSlab::IsPointInSide(const AcGePoint3d& ptOn) const
|
||||
|
||||
delete [] pfPtx;
|
||||
delete [] pfPty;
|
||||
//delete pPl;
|
||||
delete pShapeCurve;
|
||||
|
||||
//pPl->setColorIndex(1);
|
||||
//AddToModelSpace(pPl);
|
||||
return bIn > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
@@ -2304,6 +2319,11 @@ Acad::ErrorStatus AecDbXSlab::Draw2d(AcGiDraw &dc) const
|
||||
dc.DrawEntity(pPl);
|
||||
Add2DBuffer(pPl);
|
||||
}
|
||||
else
|
||||
{
|
||||
//未进缓存,需自行释放
|
||||
delete pShape;
|
||||
}
|
||||
}
|
||||
|
||||
DrawHatch(dc);
|
||||
@@ -2360,6 +2380,9 @@ Acad::ErrorStatus AecDbXSlab::Draw2d(AcGiDraw &dc) const
|
||||
if (dPlotW > 1.e-3)
|
||||
{
|
||||
AcDbCircle* pCir = AcDbCircle::cast(pShape);
|
||||
AcDbEllipse* pElp = AcDbEllipse::cast(pShape);
|
||||
AcDbPolyline* pPlT = AcDbPolyline::cast(pShape);
|
||||
|
||||
if (pCir != NULL)
|
||||
{
|
||||
AcGePoint3d ptCen = pCir->center();
|
||||
@@ -2380,24 +2403,28 @@ Acad::ErrorStatus AecDbXSlab::Draw2d(AcGiDraw &dc) const
|
||||
pPl->setConstantWidth(dPlotW);
|
||||
dc.DrawEntity(pPl);
|
||||
Add2DBuffer(pPl);
|
||||
}
|
||||
|
||||
AcDbEllipse* pElp = AcDbEllipse::cast(pShape);
|
||||
if (pElp != NULL)
|
||||
//进缓存的是新建的 pPl,原始圆需自行释放
|
||||
delete pShape;
|
||||
}
|
||||
else if (pElp != NULL)
|
||||
{
|
||||
//椭圆暂时不宽度显示
|
||||
pShape->setColorIndex(nColor);
|
||||
dc.DrawEntity(pShape);
|
||||
Add2DBuffer(pShape);
|
||||
}
|
||||
|
||||
AcDbPolyline* pPl = AcDbPolyline::cast(pShape);
|
||||
if (pPl != NULL)
|
||||
else if (pPlT != NULL)
|
||||
{
|
||||
pPl->setColorIndex(nColor);
|
||||
pPl->setConstantWidth(dPlotW);
|
||||
dc.DrawEntity(pPl);
|
||||
Add2DBuffer(pPl);
|
||||
pPlT->setColorIndex(nColor);
|
||||
pPlT->setConstantWidth(dPlotW);
|
||||
dc.DrawEntity(pPlT);
|
||||
Add2DBuffer(pPlT);
|
||||
}
|
||||
else
|
||||
{
|
||||
//未进缓存,需自行释放
|
||||
delete pShape;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -4648,11 +4675,25 @@ void AecDbXSlab::DrawHatch(AcGiDraw &dc) const
|
||||
}
|
||||
|
||||
AcDbCurve *pCurve = KTCADUtilityEx::ConvertBoundCurve(arEntClnPtrs, arRelt);
|
||||
if (!pCurve) return;
|
||||
|
||||
//ConvertBoundCurve 只接管部分克隆,未被接管的需自行释放
|
||||
for (int i = 0; i < arEntClnPtrs.length(); i++)
|
||||
{
|
||||
AcDbEntity *pCln = (AcDbEntity *)arEntClnPtrs.at(i);
|
||||
if (pCln != NULL && arRelt.find(pCln) == -1)
|
||||
delete pCln;
|
||||
}
|
||||
arEntClnPtrs.removeAll();
|
||||
|
||||
FreeBuffer(0, arRelt);
|
||||
if (!pCurve) return;
|
||||
|
||||
AcDbPolyline *pPl = AcDbPolyline::cast(pCurve);
|
||||
if (!pPl) return;
|
||||
if (!pPl)
|
||||
{
|
||||
DELETE_PTR(pCurve);
|
||||
return;
|
||||
}
|
||||
|
||||
pPl->setElevation(.0);
|
||||
pPl->setClosed(Adesk::kTrue);
|
||||
@@ -5100,6 +5141,8 @@ bool AecDbXSlab::SetProperties(SimpleProperty::PropertySetByName & properties)
|
||||
AcDbLine tmpLine(ptCen, ptCen - AcGeVector3d::kZAxis * dT);
|
||||
SetBaseCurve(&tmpLine);
|
||||
SetSection(pXYPoly, ptCen);
|
||||
//SetSection 不接管入参,用完即释放
|
||||
delete pXYPoly;
|
||||
}
|
||||
SetAt(KEY_BOMTHICK, dT);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user