查看单个帖子
旧 2009-05-04, 06:34 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】crash on exi

crash on exit
crash on exit
to get started using dd i wrote this small program. everything was cut out from the odwriteex example program, but the program seem to crash on the return statement, what could be wrong?
code:
class myservices : public exsystemservices, public exhostappservices
{
protected:
odrx_using_heap_operators(exsystemservices);
};
int main(int argc, char* argv[])
{
odstaticrxobject<myservices> svcs;
odinitialize(&svcs);
oddbdatabaseptr pdb = svcs.createdatabase(true,oddb::kmetric);
oddbblocktablerecordptr pps = pdb->getpaperspaceid().safeopenobject(oddb::kforwrite);
oddbcircleptr pcircle = oddbcircle::createobject();
pcircle->setradius(1.0);
pps->appendoddbentity(pcircle);
odwrfilebuf fb("jekout.dxf");
pdb->writefile( &fb, oddb::kdxf , oddb::vac12 , true );
oduninitialize();
return 0;
}
i just want to compile and run the simplest of all, could i do even simpler than something like this?
thanks
jesper

ohh, got it! seems like i need to release the database pointer pointer before uninitialize can be called, either by doing "pdb.release()", or letting the pointer go out of scope, before the "oduninitialize()" call.
you are absolutely right. in your initial variant smart pointer was holding the database and it was destroyed after call to oduninitialize().
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)