ObjectARX

ObjectARX

Reply
Active Member
sebastien.letutour
Posts: 9
Registered: ‎09-02-2005
Message 1 of 7 (604 Views)

pb with explode and AcDbVoidPtrArray

604 Views, 6 Replies
08-30-2011 02:04 AM

Dear All,

 

I have a pb with using explode and especialy with AcDbVoidPtrArray.

I upgrade  my code from VS2008 to VS2010 and autocad 2011 and 2012.

 

And now when I execute this code I have a crash when the application try to free memory for the entitySet (AcDbVoidPtrArray). It's very strange because the same code works fine in VS2008 and AutoCad2010.

I tried to free and close all pointers but I still have the same pb.

 

 

The aim of this code is to find the crossing point between two lines (one of the two line is in a block). The result is ok (I found the point) but I have a Acad error :in acarray.h :

template <class T, class R>
AcArray<T,R>::~AcArray()
{
    if (mpArray != NULL)
        delete[] mpArray;
}

and then in free.c

oid __cdecl _free_base (void * pBlock)
{

        int retval = 0;


        if (pBlock == NULL)
            return;

        RTCCALLBACK(_RTC_Free_hook, (pBlock, 0));

        retval = HeapFree(_crtheap, 0, pBlock);
        if (retval == 0)
        {
            errno = _get_errno_from_oserr(GetLastError());
        }
}

 

 

 

[Code begin]

 AcDbEntity *pCurRefEnt;
 AcGePoint3dArray TestintersectionPoints;

 AcDbBlockReference *pBlockRef = AcDbBlockReference::cast (pEnt1);
 if (pBlockRef != NULL)
 {
      AcDbVoidPtrArray entitySet;
      // explode the block, this will return a load of pre-transfromed entities for our perusal
      Acad::ErrorStatus es = pBlockRef->explode (entitySet);
 
      // if it worked ok
      if (es == Acad::eOk)
      {
        // loop round getting the intersection points
        for (int i = 0; i < entitySet.length(); i++)
        {
            pCurRefEnt = (AcDbEntity*)entitySet.at(i);
            if ((pCurRefEnt->isKindOf(AcDbLine::desc())) && (TestintersectionPoints.isEmpty()))
            {
                Acad::ErrorStatus es1 = pCurRefEnt->intersectWith (pEnt2, AcDb::kOnBothOperands, TestintersectionPoints);
            }

            pCurRefEnt->close();
            delete pCurRefEnt;
        }
        TestintersectionPoints.setLogicalLength(0);
        entitySet.setLogicalLength(0);
      }
      pBlockRef->close();
      entitySet.removeAll();
      pEnt2->close();
      pEnt1->close();
 }==> acad.exe error!!!

[Code End]

ADN Support Specialist
philippe.leefsma
Posts: 676
Registered: ‎06-02-2009
Message 2 of 7 (604 Views)

Re: pb with explode and AcDbVoidPtrArray

08-30-2011 03:21 AM in reply to: sebastien.letutour

Hi Sebastien,

 

Try not to "Close" the "pCurRefEnt"... It is an exploded entity, so it isn't database resident, therefore closing it doesn't make much sense. You should simply delete it as you do at the nd of the loop.

 

I hope it helps.

 

 

Philippe Leefsma
Developer Consultant
Developer Technical Services

 

www.autodesk.com/joinadn



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Distinguished Mentor
owenwengerd
Posts: 687
Registered: ‎08-06-2002
Message 3 of 7 (596 Views)

Re: pb with explode and AcDbVoidPtrArray

08-30-2011 07:40 AM in reply to: philippe.leefsma

Closing a non-DBR entity should be harmless. If this is the reason for the crash, then there is a bug in the object's implementation or related code.

--
Owen Wengerd
ManuSoft
Active Member
sebastien.letutour
Posts: 9
Registered: ‎09-02-2005
Message 4 of 7 (594 Views)

Re: pb with explode and AcDbVoidPtrArray

08-30-2011 09:32 AM in reply to: owenwengerd

I do confirm that removing the fact to close the pointer doesn't change anything.

I still have a crash when Acad try to release the mpArray of the entityset. Even if I do a removeall of the entityset and if I put logicallength to 0.

Perhaps if I could release the pointer (?) because Acad test if this pointer is !=Null, but of course this pointer is read only.

 

Thanks for your help, if you have another suggest, you are welcome.

 

Regards

Active Member
Anodl
Posts: 10
Registered: ‎03-13-2011
Message 5 of 7 (582 Views)

Re: pb with explode and AcDbVoidPtrArray

08-31-2011 12:36 PM in reply to: sebastien.letutour
Hi, don't know if this causes the crash, but pEnt1 and pBlockRef are pointing to the same object (entity), and you call close on both pointers. Arnold
Member
Madon77
Posts: 3
Registered: ‎02-23-2012
Message 6 of 7 (350 Views)

Re: pb with explode and AcDbVoidPtrArray

02-25-2013 12:13 PM in reply to: sebastien.letutour

Has anyone found a solution to this problem? I am experiencing very similar behaviour. I try to delete an entity from an AcDbVoidPtrArray of exploded entities and I get a crash. Entities that I am deleting are not database resident so according to documentation of explode() function, I should delete them myself.

Moderator
Alexander.Rivilis
Posts: 1,458
Registered: ‎04-09-2008
Message 7 of 7 (347 Views)

Re: pb with explode and AcDbVoidPtrArray

02-25-2013 02:29 PM in reply to: Madon77

Maybe you post yours code?


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.