几何尺寸与公差论坛------致力于产品几何量公差标准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-05, 08:31 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】dwgdirect crash when drawing dxf file

dwgdirect crash when drawing dxf file
dwgdirect crash when drawing dxf file
we use the wingdi renderer to draw autocad files within our application. currently we are on version 1.13.xx, so we are behind in versions.
we are having a problem with some dxf files in that our application crashes with an access violation when we turn off a layer that had been on. the crash seems to be related to the gsmodel caching. we use gsmodel caching. if we turn it off, we don't have any more crashes. it seems to not crash if the layer we turn off does not have any elements (at least not any that we can tell).
so far, we have not been able to reproduce the problem in odamfcapp.
we have spent a lot of time debugging through the dwgdirect code, but we haven't found any obvious solution to our problem.
here is what we can tell (by comparing the path that odamfcapp takes - and doesn't crash - vs the path that our application takes - and crashes):
we turn the level on or off the same way that odamfcapp does it in odalayerpropmanagerdlg.cpp. we call player->setisoff, passing true or false, depending on whether we are turning the layer off or on. during our next draw/paint, we detect (based on our own internal data) that the layer status has changed so we use
code:
pdevice->gsmodel()->invalidate(odgsmodel::kinvalidateall)
to invalidate the model. then, we delegate the draw to dwgdirect via pdevice->update.
during the drawing/vectorization, we eventually get to
code:
odgibasevectorizer::draw(const odgidrawable* pdrawable) with this stack:
odgibasevectorizer::draw(const odgidrawable * 0x1968a9a8) line 765 + 18 bytes
odgsentitynode::update(odgsbasevectorizeview & {...}, odgscontainernode * 0x1a4b7968) line 864 + 49 bytes
odgscontainernode::update(odgsbasevectorizeview & {...}, odgscontainernode * 0x00000000) line 602 + 21 bytes
odgsbasevectorizeview::display(unsigned char 1) line 1599 + 19 bytes
odgsbasevectorizeview::update() line 1661 + 18 bytes
exgdivectorizeview::update() line 524
odgsbasevectorizedevice::update(odgsdcrect * 0x00000000) line 193 + 16 bytes
exgsgdivectorizedevice::update(odgsdcrect * 0x00000000) line 266
in odgibasevectorizer::draw, the code fails the compound drawable check and goes into the else:
code:
else
{
oduint32 ndrawableflags = setattributes(pdrawable);
if(needdraw(ndrawableflags))
dodraw(ndrawableflags, pdrawable);
}
next, we enter needdraw() and return false because of this statement:
code:
if(!getbit(m_flags, kdrawlayeroff) &&
!getbit(ndrawableflags, odgidrawable::kdrawableiscompoundobject | odgidrawable::kdrawableusesnesting) &&
traits.islayeroff()
the "getbit" tests are always the same, but traits.islayeroff() returns true (when the layer is off - i.e. it has just been turned off by our application). since needdraw returns false, dodraw is skipped. if we force the dodraw to execute by using "set next statement" in the debugger, we don't get a crash.
(the crash does not happen here, but it appears that if we execute dodraw we do not get the crash in the future, but if we don't execute dodraw, we do get a crash).
later we get to odgsentitynode::update. in that function, pgsmetafile == 0 (which seems right, based on the comments in the code, since we invalidated the gsmodel cache).
eventually, it gets to this section of code:
code:
// update extents
if( getbit(m_flags, karrayallocated) && metafilearray().size() > 1)
{
const vpmetafileholderptr* pmetafileptr = metafilearray().begin();
const vpmetafileholderptr* pmetafileendptr = metafilearray().end();
oda_assert(pmetafileptr!=pmetafileendptr);
while(pmetafileptr->isnull() && pmetafileptr!=pmetafileendptr)
{
++pmetafileptr;
}
if(pmetafileptr!=pmetafileendptr)
{
m_extents = (*pmetafileptr)->extents;
++pmetafileptr;
while(pmetafileptr!=pmetafileendptr)
{
if(pmetafileptr->get() && (*pmetafileptr)->extents.isvalidextents())
m_extents.addext((*pmetafileptr)->extents);
++pmetafileptr;
}
}
setbit(m_flags, khasextents, m_extents.isvalidextents());
}
metafilearray().size() is 0xfdfdfdfd (uninitialized data???)fff"> in the case where we crash. it is 1 when we don't crash (i.e. when we have not changed the state of any layers). both pmetafileptr and pmetafileendptr are 0. so, when the while loop starts, pmetafileptr->isnull() is being called with pmetafileptr == 0. this is where the crash happens.
in both odamfcapp and our application, the draw starts with exgsgdivectorizedevice::update and eventually gets to odgscontainernode::update.
odgscontainernode::update is called from this loop in odgsbasevectorizeview::display:
code:
void odgsbasevectorizeview::display(bool bupdate)
{
for(unsigned int i = 0; !regenabort() && i < m_drawables.size(); ++i)
{
drawableholder& holder = m_drawables[i];
odgsnode* pnode = getrootnode(holder);
if(pnode)
{
setbit(m_flags, kmodelcache, true);
if(bupdate)
pnode->update(*this, 0);
pnode->display(*this);
}
else // no model cache
{
setbit(m_flags, kmodelcache, false);
if(holder.m_pmetafile.get())
{
playmetafile(holder.m_pmetafile);
holder.m_pmetafile.release();
}
else
{
draw(drawableat(holder));
}
}
}
}
on both cases, since gsmodel caching is in effect, the code branches to the if(pnode)fff"> section, not the else // no model cachefff"> section. then control goes to odgscontainernode::needregen. in odamfcapp, when needregen calls childrenuptodate(), true is returned which causes the return statement at the end of the function (needregen) to execute, eventually causing needregen to return false. in our application, childrenuptodate() returns false, causing needregen to return true.
since needregen returns true in our application, the rest of odgscontainernode::update is executed. in odamfaapp, the rest of the function is skipped.
i know that this is a lot of information (hopefully at least some of it is useful!), but we really hope to get an answer. as much as we have tried, we cannot reproduce the problem in odamfcapp.
at this point, we can't tell if it is a bug in our code with maintaining the gsmodel cache or the layer status or if it is a bug in dwgdirect (wingdi or "real" dwgdirect code), or it is a problem in our dxf files. we were first notified of the problem based on dxf files that a customer created (don't know how they created them at the moment), but we have since found some dxf files that we already had and they had the same problem. so far, we have not seen the problem with dwg files. maybe it is a problem in wingdi/dwgdirect that exists in our version but has been fixed in a more recent version.
any help would be greatly appreciated.
i forgot to attach the file.
here is a dxf file that causes us to crash (again, it doesn't crash odamfcapp).
attached files (23.4 kb, 4 views)
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】creating a sat file out of dxf solid file yang686526 DirectDWG 0 2009-05-04 06:47 PM
【转帖】crash in dxf reading file yang686526 DirectDWG 0 2009-05-04 06:27 PM
【转帖】auto create 11 flat pattern and save as dxf yang686526 SolidWorks二次开发 0 2009-04-13 09:08 AM
【转帖】how to save to dxf in active drawing file location yang686526 SolidWorks二次开发 0 2009-04-12 09:23 PM
【转帖】how to save to dxf in active drawing file location yang686526 SolidWorks二次开发 0 2009-04-12 06:38 PM


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


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