I have a class that derives from AcDbployLine, (Not a custom Object) after I add a few of these objects to the database then try to unload my ARX app, Acad crashes.

Am I doing something wrong?

code I am using to add the entity

` AcDbObjectId pid;`

AcDbPolyline *p = new CrpRectangle(AcGePoint2d(0,0),400,400,PCode::kUpperRight);

//closes the entity

if (DatabaseTools::AddToCurrentSpace(p,pid) == Acad::eOk)

acutPrintf(_T("\nok")

);

.h

`#pragma once`

#include "TypedValue.h"

#include "pcode.h"

#define ISEOK(statement) { Acad::ErrorStatus st = (statement); if (st != Acad::eOk) return st; }

class CrpRectangle: public AcDbPolyline

{

public:

CrpRectangle(DataMap &tvmap);

CrpRectangle(const AcGePoint2d &pt, double width, double height, PCode::Location loc);

virtual ~CrpRectangle(void);

public:

Acad::ErrorStatus getWidth(double &width) const;

Acad::ErrorStatus setWidth(double width);

Acad::ErrorStatus getHeight(double &height) const;

Acad::ErrorStatus setHeight(double height);

Acad::ErrorStatus drawFrom(const AcGePoint3d &point);

Acad::ErrorStatus drawFrom(const AcGePoint2d &point);

Acad::ErrorStatus drawFrom(const AcGeVector2d &vec);

private:

void calcLocation(const AcGePoint2d &startPoint, double width, double height, PCode::Location loc);

public:

AcGePoint2d getPt1() const;

AcGePoint2d getPt2() const;

AcGePoint2d getPt3() const;

AcGePoint2d getPt4() const;

AcGePoint2d getMPB() const;

AcGePoint2d getMPR() const;

AcGePoint2d getMPT() const;

AcGePoint2d getMPL() const;

AcGePoint2d getCenter() const;

__declspec(property(get = getPt1))AcGePoint2d PT1;

__declspec(property(get = getPt2))AcGePoint2d PT2;

__declspec(property(get = getPt3))AcGePoint2d PT3;

__declspec(property(get = getPt4))AcGePoint2d PT4;

__declspec(property(get = getMPB))AcGePoint2d MPB;

__declspec(property(get = getMPR))AcGePoint2d MPR;

__declspec(property(get = getMPT))AcGePoint2d MPT;

__declspec(property(get = getMPL))AcGePoint2d MPL;

__declspec(property(get = getCenter))AcGePoint2d Center;

};

.cpp

`#include "StdAfx.h"`

#include "CrpRectangle.h"

CrpRectangle::CrpRectangle(DataMap &tvmap):AcDbPolyline(4)

{

AcGePoint2d pt;

double width;

double height;

short location;

tvmap[1000].getPoint2d(pt);

tvmap[1001].getDouble(width);

tvmap[1002].getDouble(height);

tvmap[1003].getShort(location);

AcGePoint2d pt1 (pt.x + width,pt.y);

AcGePoint2d pt2 (pt.x + width, pt.y + height);

AcGePoint2d pt3 (pt.x, pt.y + height);

if(this->isWriteEnabled())

{

this->addVertexAt(0,pt);

this->addVertexAt(1,pt1);

this->addVertexAt(2,pt2);

this->addVertexAt(3,pt3);

this->setClosed(Adesk::kTrue);

}

calcLocation(pt, width, height, (PCode::Location)location);

}

CrpRectangle::CrpRectangle(const AcGePoint2d &pt, double width, double height, PCode::Location loc):AcDbPolyline(4)

{

AcGePoint2d pt1 (pt.x + width,pt.y);

AcGePoint2d pt2 (pt.x + width, pt.y + height);

AcGePoint2d pt3 (pt.x, pt.y + height);

if(this->isWriteEnabled())

{

this->addVertexAt(0,pt);

this->addVertexAt(1,pt1);

this->addVertexAt(2,pt2);

this->addVertexAt(3,pt3);

this->setClosed(Adesk::kTrue);

}

calcLocation(pt, width, height, loc);

}

CrpRectangle::~CrpRectangle(void)

{

}

Acad::ErrorStatus CrpRectangle::getWidth(double &width) const

{

Acad::ErrorStatus res;

AcGePoint2d p0;

AcGePoint2d p1;

if((res = this->getPointAt(0,p0)) != Acad::eOk)

return res;

if((res = this->getPointAt(1,p1)) != Acad::eOk)

return res;

width = fabs(p0.x - p1.x);

return Acad::eOk;

}

Acad::ErrorStatus CrpRectangle::setWidth(double width)

{

Acad::ErrorStatus res;

AcGePoint2d p0;

AcGePoint2d p1;

AcGePoint2d p2;

if((res = this->getPointAt(0,p0)) != Acad::eOk)

return res;

if((res = this->getPointAt(1,p1)) != Acad::eOk)

return res;

if((res = this->getPointAt(2,p2)) != Acad::eOk)

return res;

p1.x = p0.x + width;

p2.x = p0.x + width;

if(!this->isWriteEnabled())

return Acad::eNotOpenForWrite;

if((res = this->setPointAt(1,p1)) != Acad::eOk)

return res;

if((res = this->setPointAt(2,p2)) != Acad::eOk)

return res;

return Acad::eOk;

}

Acad::ErrorStatus CrpRectangle::getHeight(double &height) const

{

Acad::ErrorStatus res;

AcGePoint2d p0;

AcGePoint2d p4;

if((res = this->getPointAt(0,p0)) != Acad::eOk)

return res;

if((res = this->getPointAt(4,p4)) != Acad::eOk)

return res;

height = fabs(p4.y - p0.y);

return Acad::eOk;

}

Acad::ErrorStatus CrpRectangle::setHeight(double height)

{

Acad::ErrorStatus res;

AcGePoint2d p0;

AcGePoint2d p2;

AcGePoint2d p3;

if((res = this->getPointAt(0,p0)) != Acad::eOk)

return res;

if((res = this->getPointAt(2,p2)) != Acad::eOk)

return res;

if((res = this->getPointAt(3,p3)) != Acad::eOk)

return res;

p2.y = p0.y + height;

p3.y = p0.y + height;

if(!this->isWriteEnabled())

return Acad::eNotOpenForWrite;

if((res = this->setPointAt(2,p2)) != Acad::eOk)

return res;

if((res = this->setPointAt(3,p3)) != Acad::eOk)

return res;

return Acad::eOk;

}

void CrpRectangle::calcLocation( const AcGePoint2d &startPoint, double width,

double height, PCode::Location loc )

{

AcGePoint2d point;

switch ((int)loc)

{

case (int)PCode::kLowerLeft:

{

point = startPoint;

}

break;

case (int)PCode::kLowerMid:

{

point = AcGePoint2d((startPoint[0] - (width / 2)), startPoint[1]);

}

break;

case (int)PCode::kLowerRight:

{

point = AcGePoint2d((startPoint[0] - width), startPoint[1]);

}

break;

case (int)PCode::kRightMid:

{

point = AcGePoint2d((startPoint[0] - width), (startPoint[1] - (height / 2)));

}

break;

case (int)PCode::kUpperRight:

{

point = AcGePoint2d((startPoint[0] - width), (startPoint[1] - height));

}

break;

case (int)PCode::kUpperMid:

{

point = AcGePoint2d((startPoint[0] - (width / 2)), (startPoint[1] - height));

}

break;

case (int)PCode::kUpperLeft:

{

point = AcGePoint2d(startPoint[0], (startPoint[1] - height));

}

break;

case (int)PCode::kLeftMid:

{

point = AcGePoint2d(startPoint[0], (startPoint[1] - (height / 2)));

}

break;

}

drawFrom(point);

}

Acad::ErrorStatus CrpRectangle::drawFrom( const AcGePoint3d &point )

{

return drawFrom(AcGePoint2d(point.x,point.y));

}

Acad::ErrorStatus CrpRectangle::drawFrom( const AcGePoint2d &point )

{

return drawFrom(point.asVector());

}

Acad::ErrorStatus CrpRectangle::drawFrom( const AcGeVector2d &vec )

{

Acad::ErrorStatus res;

if(!this->isWriteEnabled())

return Acad::eNotOpenForWrite;

AcGePoint2d pt0;

AcGePoint2d pt1;

AcGePoint2d pt2;

AcGePoint2d pt3;

ISEOK(this->getPointAt(0,pt0));

ISEOK(this->getPointAt(1,pt1));

ISEOK(this->getPointAt(2,pt2));

ISEOK(this->getPointAt(3,pt3));

ISEOK(this->setPointAt(0, pt0 + vec));

ISEOK(this->setPointAt(1, pt1 + vec));

ISEOK(this->setPointAt(2, pt2 + vec));

ISEOK(this->setPointAt(3, pt3 + vec));

return Acad::eOk;

}

AcGePoint2d CrpRectangle::getPt1(void) const

{

AcGePoint2d pt;

this->getPointAt(0,pt);

return pt;

}

AcGePoint2d CrpRectangle::getPt2(void) const

{

AcGePoint2d pt;

this->getPointAt(1,pt);

return pt;

}

AcGePoint2d CrpRectangle::getPt3(void) const

{

AcGePoint2d pt;

this->getPointAt(2,pt);

return pt;

}

AcGePoint2d CrpRectangle::getPt4(void) const

{

AcGePoint2d pt;

this->getPointAt(3,pt);

return pt;

}

AcGePoint2d CrpRectangle::getMPB() const

{

AcGePoint2d pt0;

this->getPointAt(0,pt0);

AcGePoint2d pt1;

this->getPointAt(1,pt1);

return AcGePoint2d((pt1[0] - pt0[0]) / 2.0, pt0[1]);

}

AcGePoint2d CrpRectangle::getMPL() const

{

AcGePoint2d pt1;

this->getPointAt(0,pt1);

AcGePoint2d pt4;

this->getPointAt(3,pt4);

return AcGePoint2d(pt1[0], (pt4[1] - pt1[1]) / 2.0);

}

AcGePoint2d CrpRectangle::getMPR() const

{

AcGePoint2d pt2;

this->getPointAt(1,pt2);

AcGePoint2d pt3;

this->getPointAt(2,pt3);

return AcGePoint2d(pt2[0], (pt3[1] - pt2[1]) / 2.0);

}

AcGePoint2d CrpRectangle::getMPT() const

{

AcGePoint2d pt3;

this->getPointAt(2,pt3);

AcGePoint2d pt4;

this->getPointAt(3,pt4);

return AcGePoint2d((pt3[0] - pt4[0]) / 2.0, pt3[1]);

}

AcGePoint2d CrpRectangle::getCenter() const

{

AcGePoint2d pt1;

this->getPointAt(0,pt1);

AcGePoint2d pt2;

this->getPointAt(1,pt2);

AcGePoint2d pt4;

this->getPointAt(3,pt4);

return AcGePoint2d((pt2[0] - pt1[0]) / 2.0, (pt4[1] - pt1[1]) / 2.0);

}

added the arx for 07 (command is test)