高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】add xdata to some entity cant be save in dwg forma
add xdata to some entity can't be save in dwg format
add xdata to some entity can't be save in dwg format
hi
i add some xdata to some kind of entity,like circle,line...
everything is ok,but when i save to dwg,it crash.the err msg is
"unhandled exception at 0x7c81eb33 in dwgviewer.exe: microsoft c++ exception: oderror @ 0x0012f258."
if i save as dxf,it,s ok.
can some one tell me why ?
regards,
heaven.jen
if the c++ exception is of oderror kind you can get error code and error description from it which may point out the reason.
probably you add an xdata providing application name which is absent in regapp table.
(you can use oddbdatabase::newregapp(const odstring& appname); to append the application to the database's regapp table.)
sergey slezkin
i have used newregapp in my app
i have used newregapp in my app.
if i haven,t use newregapp,it would crash in setxdata.
when i use setxdata,everything is ok until i save the file to "dwg".
i can't catch oderror,it crash immediately.
the code is show below
oddbentityptr pentity;
//get pentity use oddb::kforwrite
.....
byte *p;
long length;
//get some binary data i want to save to dwg
.....
odresbufptr xiter = odresbuf::newrb(odresbuf::kdxfregappname);
odresbufptr temp = xiter;
temp->setstring("xx");
temp->setnext( odresbuf::newrb(odresbuf::kdxfxdbinarychunk));
temp = temp->next();
odbitbinarydata data;
int i;
for(i=0;i<length;i++)
{
data.push_back(p[i]);
}
temp->setbinarychunk(data);
pentity->setxdata( xiter );
.....
cfilestreambuf filestreambuf; //inherit from odstreambuf
filestreambuf.attach(&file,false,false);
try
{
pdatabase->writefile(&filestreambuf,oddb::kdwg,oddb::vac15,f alse);//crash
}
catch(oderror *p)
{
//never into here
delete p;
}
if i use
pdatabase->writefile(&filestreambuf,oddb::kdxf,oddb::vac15,f alse)
.
it,s ok
last edited by yashu; 31st october 2004 at 05:23 pmfff">.
could you send me or post a dxf file with your xdata?
btw, probably you can't catch the oderror because catch should look like:
catch(oderror & err)
{
}
sergey slezkin
quote:
originally posted by sergey slezkin
could you send me or post a dxf file with your xdata?
btw, probably you can't catch the oderror because catch should look like:
catch(oderror & err)
{
}
i catch the err.
description is "object: (f9)"
code is 52
is it possible that by the moment you call writefile() a smart pointer still exists pointing to the circle?
if so it's the reason.
smart pointer holds the object in "opened" state. to release the object assign null to smart pointer or call
pcircle.release()
or smart pointer's destructor will release the object if the pointer goes out of scope.
sergey slezkin
quote:
originally posted by sergey slezkin
is it possible that by the moment you call writefile() a smart pointer still exists pointing to the circle?
if so it's the reason.
smart pointer holds the object in "opened" state. to release the object assign null to smart pointer or call
pcircle.release()
or smart pointer's destructor will release the object if the pointer goes out of scope.
no,
the oddbentityptr in my app is a local variant,when save to dwg,it have gone out of scope.
by the way,why dxf is ok ?
quote:
originally posted by yashu
no,
the oddbentityptr in my app is a local variant,when save to dwg,it have gone out of scope.
by the way,why dxf is ok ?
the bug have be found.it is my problem.
i create some cache to speed something.
you are right.i have something not be release before save.
thank's a lot. thank's
can you tell me why save to dxf is not crash ?
when object is closed it may perform some clean up, recalculations, send notifications to reactors which should perform some actions too etc.
in general it's not safe to save file with modified and not closed objects (invalid file may be produced).
the check is inserted in saving dwg but not inserted in saving dxf - our fault.
sergey slezkin
quote:
originally posted by sergey slezkin
when object is closed it may perform some clean up, recalculations, send notifications to reactors which should perform some actions too etc.
in general it's not safe to save file with modified and not closed objects (invalid file may be produced).
the check is inserted in saving dwg but not inserted in saving dxf - our fault.
thank you very much
|