几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】oddbobjects alive beyond odinitialize and oduninitialize (http://www.dimcax.com/hust/showthread.php?t=17571)

yang686526 2009-05-06 07:58 PM

【转帖】oddbobjects alive beyond odinitialize and oduninitialize
 
oddbobjects alive beyond odinitialize and oduninitialize
oddbobjects alive beyond odinitialize and oduninitialize
i have problems while saving in dwgdirect database.
i have the smart database pointer alive even after the open of
existing document is executed. if i am using the same pointer for saving it to some .dwg file, its throws exception in the heap allocation portion.
it is documented that every database operations must be done inside one
odinitialize and odunintialize calls, and the oddbobjects (here oddbdatabase)should be deleted. my requirement is that i should have the database pointer alive even after i call oduninialize().
please explain to me the internal mechansims of memory allocation and deallocations for each oddbobjects inside the odinitialize (...) and oduninitialize() calls and any way-outs for keeping such objects beyond the scope of this calls.
thanks in advance!
odinitialize() creates internal dwgdirect data structures. oduninitialize() destroys them.
any attempt to use oddbobject after odunitialize() is invalid because may result in accessing already destroyed data. this may happen even in destructor of oddbobject.
so all smart pointers to all oddbobjects must go out of scope or zeroed before calling oduninitialize(). else oddbobject will be destroyed after odinitialize() and cause crash.
sergey slezkin
how important the oduninitialize() call is
thanks a lot!
i just want to know if we only initialize dwgdirect objects by odinitialize ()
and do not end up with uninitialize(), the database operations performed there will be valid or not. if the oduninitialize is called from a different follow-up routine, will that help? i mention that the pointer to odhostappservices object passed in odinitialize() call is not visible in the second follow-up routine where oduninitialize() is called.
the sample example codes, where it is used in the above fashion, if you paste here, will be ideal for understanding.
again thanks for reply.


所有的时间均为北京时间。 现在的时间是 08:35 PM.