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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-07, 06:45 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】what Do I Need To Release

what do i need to release
what do i need to release
i have the following members in my class:
odstaticrxobject<qsservices> m_svcs;
oddbdatabaseptr m_pdb;
oddbobjectid m_layerid;
oddb3dpolylineptr m_p3dpl;
i set m_layerid to zero before writing out the file.
i set m_p3dpl to null after each call to appendoddbentity()
do i need to do anything with the other two?
am i doing the right thing?

it would be more correct to put members like oddb3dpolylineptr m_p3dpl;to some separate class and destruct object of the class before writing the file. you don't need to do anything with two others.
sincerely yours,
george udov
yes, that is correct.
do you still receive the exception?
maybe you could narrow down your problem to some complete sample and post it here?
vladimir

also, please check do you always use smartpointers?
for example, such code:
code:
oddbhatch* phatch = (oddbhatch*)pent->queryx(oddbhatch::desc());
can be reason of unclosed object. correct one is
code:
oddbhatchptr phatch = pent->queryx(oddbhatch::desc());
sincerely yours,
george udov
simple exception
i am hitting the second catch, int i = 2; so destruction of either the qsservices (modeled after the exservices example), or oddbdatabaseptr must be triggering the exception.
try
{
// for correct unicode translation apply the current system locale
setlocale(lc_all, "");
// but use usual conversion for scanf()/sprintf()
setlocale(lc_numeric, "c");
odstaticrxobject<qsservices> svcs;
oddbdatabaseptr pdb;
odinitialize(&svcs);
pdb = svcs.createdatabase(true);
m_filename = "c:\\dan.dwg";
try
{
odstreambufptr fb = svcs.createfile(
m_filename.c_str(),
oda::kfilewrite,
oda::ksharedenyno,
oda::kcreatealways);
pdb->writefile(fb, oddb::kdwg, oddb::vac18, false );
}
catch (...)
{
int i = 1;
}
oduninitialize();
}
catch (...)
{
int i = 2;
}
database should be released prior to oduninitialize()
vladimir
if i release the db before oduninitialize
if i release the db before oduninitialize i get:
exception c0000005 access violation read of address 0xc2c2c2d6
the only change i made was to add the line pdb->release();
call stack:
odsmartptr<oddbdatabase>::release
odsmartptr<oddbdatabase>::~odsmartptr<oddbdatabase >
do not call pdb->release(), this way you decrement object reference counter, and in smart pointer destructor, object wiil be deleted second time.
to release database (or any other object, owned by smart pointer) assign 0 to smart pointer, or create the pointer in local scope, to be destroyed at scope exit.
about smart pointer mechanics you may read for example in
"modern c++ design" by andrei alexandrescu
vladimir
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】problems shutting down in release builds yang686526 DirectDWG 0 2009-05-06 11:48 PM
【转帖】numerous link errors on macosx 9xcode 2.50 yang686526 DirectDWG 0 2009-05-06 06:43 PM
【转帖】naming convention of dlls cause problems yang686526 DirectDWG 0 2009-05-06 06:19 PM
【转帖】when to release prints yang686526 American standards 0 2009-05-04 11:20 AM


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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多