查看单个帖子
旧 2009-05-04, 04:13 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】assert exception in adding a new linetypetable record

assert exception in adding a new linetypetable record
assert exception in adding a new linetypetable record
1. i want to add a new linetypetable record in one oddbdatabase to another one, the main code is as follows:
//////////////
oddblayertableptr players = c_pdb->getlayertableid().safeopenobject();
players->generateusagedata();
oddblinetypetableptr m_dhfrom = (oddblinetypetableptr)c_pdb->getlinetypetableid().safeopenobject(oddb::kforwri te);
//
for(int j=0;j<m_amaptolayer.getsize();j++)
{
oddbobjectid newltype;
oddbsymboltableiteratorptr piter = players->newiterator();
int i = 0;
for (piter->start(); !piter->done(); piter->step(), ++i)
{
oddblayertablerecordptr player = piter->getrecordid().safeopenobject(oddb::kforwrite);
if (player->getname() == m_amapfromlayer[j].name)
{
player->setname(m_amaptolayer[j].name);
player->setcolorindex((odint16)m_amaptolayer[j].color);
player->setlineweight((oddb::lineweight)m_amaptolayer[j].lineweight);
if (!m_dhfrom->has(m_amaptolayer[j].linetypename))
{ //to add a new record
oddblinetypetablerecordptr pltype = m_amaptolayer[j].linetypeobjhandle.safeopenobject();
newltype = m_dhfrom->add(pltype);
player->setlinetypeobjectid(newltype);
}
else
{
player->setlinetypeobjectid(getltypeid(m_amaptolayer[j].linetypename, false));
}
break;
}
}
}
try
{
c_pdb->writefile(theapp.m_fpath, c_pdb->originalfiletype(), c_pdb->originalfileversion());
}
catch(oderror& /*e*/)
{
}
catch(userbreak)
{
afxmessagebox("failed to save:" + theapp.m_fpath);
return ;
}
cstring strtemp;
strtemp = theapp.m_fpath + "is saved.";
afxmessagebox(strtemp, mb_ok|mb_iconinformation);
return;
/////////////
at runtime in debug mode, there is an assert exception at the code line "newltype = m_dhfrom->add(pltype);". the record is failed to be add. why? how to resolve it?
2. when i save the file, it is ok. but the size of saved file is less than 2kb(the origional one is more than 100kb). what's the wrong? the file is opend by using:
c_pdb = theapp.readfile(lpszpathname, false, false);
thanks for any answer.
i have resolved it now.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)