From 683863a5b1dee05f49ac2dfa19111ab249c329cb Mon Sep 17 00:00:00 2001 From: Little Pan Date: Tue, 27 Oct 2026 14:10:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20AecDbXSlab=20=E7=9A=84=20L?= =?UTF-8?q?1-L9=20=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - L1 GetOffsetCurve 失败分支补 FreeBuffer,不再整批泄漏 offset 曲线 - L2 CreatePipeRegion 的 booleanOper 操作数未释放,成功/失败路径均补齐 - L3 IsPointInSide 折线分支返回前未删 GetBasinShapeCurve 新建的曲线 - L4 Draw2d 圆板分支与无 KEY_ORGPT 分支中未进缓存的 pShape 泄漏 - L5 SetRegionSlab(LPCTSTR) 的 explode 碎片未释放 - L6 SetEllipseBasin 的 offset 曲线与多余截面 region 未释放 - L7 PeelBasinWall 的 explode 碎片未释放(SetBaseCurve 内部 clone) - L8 SetProperties eXDB 分支的 pXYPoly 未释放 - L9 DrawHatch 未被 ConvertBoundCurve 接管的克隆、非 polyline 的 pCurve 泄漏 --- SourceCode/Code2026/CoreLibrary/AecDbSlab.cpp | 73 +++++++++++++++---- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/SourceCode/Code2026/CoreLibrary/AecDbSlab.cpp b/SourceCode/Code2026/CoreLibrary/AecDbSlab.cpp index 16c35b8..220440b 100644 --- a/SourceCode/Code2026/CoreLibrary/AecDbSlab.cpp +++ b/SourceCode/Code2026/CoreLibrary/AecDbSlab.cpp @@ -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); }