• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk ObjectARX

    Reply
    Active Member
    Posts: 9
    Registered: ‎09-02-2005

    pb with explode and AcDbVoidPtrArray

    409 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]

    Please use plain text.
    ADN Support Specialist
    Posts: 175
    Registered: ‎06-02-2009

    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

    Please use plain text.
    Mentor
    Posts: 239
    Registered: ‎08-06-2002

    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
    Please use plain text.
    Active Member
    Posts: 9
    Registered: ‎09-02-2005

    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

    Please use plain text.
    New Member
    Anodl
    Posts: 2
    Registered: ‎03-13-2011

    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
    Please use plain text.
    Member
    Madon77
    Posts: 3
    Registered: ‎02-23-2012

    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.

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,168
    Registered: ‎04-09-2008

    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

    Please use plain text.