pb with explode and AcDbVoidPtrArray

pb with explode and AcDbVoidPtrArray

Anonymous
Not applicable
1,262 Views
6 Replies
Message 1 of 7

pb with explode and AcDbVoidPtrArray

Anonymous
Not applicable

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]

0 Likes
1,263 Views
6 Replies
Replies (6)
Message 2 of 7

philippe.leefsma
Alumni
Alumni

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

0 Likes
Message 3 of 7

owenwengerd
Advisor
Advisor

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
0 Likes
Message 4 of 7

Anonymous
Not applicable

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

0 Likes
Message 5 of 7

Anonymous
Not applicable
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
0 Likes
Message 6 of 7

Anonymous
Not applicable

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.

0 Likes
Message 7 of 7

Alexander.Rivilis
Mentor
Mentor

Maybe you post yours code?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes