几何尺寸与公差论坛------致力于产品几何量公差标准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-04, 04:06 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】application wont run with my tooltips class

application won't run with my tooltips class
application won't run with my tooltips class
hello
when i run my application in debug mode i get this message box error:
______________ ______________
program: ...grams\seq2dwg dwg direct 251\debug\seq2dwg.exe
file: c:\dwgdirect251\include\debugstuff.h
line: 159
expression: ((char*)dest > (char*)src && (char*)dest >= ((char*)src + size)) || ((char*)dest < (char*)src && ((char*)dest + size) <= (char*)src) ||
dest == src
for information on how your program can cause an assertion
failure, see the visual c++ documentation on asserts
(press retry to debug the application - jit must be enabled)
______________ ______________
that relates to this part of your dwgdirect header:
#if !defined(dd_client_build) && defined(_msc_ver) && defined(_debug) && (_msc_ver < 1400)
#pragma function(memcpy)
inline void * memcpy(void * dest, const void * src, size_t size)
{ // memory blocks must not overlap
oda_assert(((char*)dest > (char*)src && (char*)dest >= ((char*)src + size)) ||
((char*)dest < (char*)src && ((char*)dest + size) <= (char*)src) ||
dest == src );
return memmove(dest, src, size);
}
#endif // _msc_ver
______________ ______________
i examined the call stack and it turns out that my own multiline tooltip class is getting asserted because of the dwgdirect debugging methodology:
void cmultilinetooltipctrl::refittext(toolinfo *psti)
{
cstring strfittedtext ;
uint ulength, umaxwidth ;
// delete any existing buffer.
if (m_pctextbuffer != null)
delete[] m_pctextbuffer ;
// allocate a new one.
if (psti != null)
{
strfittedtext = psti->lpsztext ;
umaxwidth = fittext(strfittedtext);
ulength = strfittedtext.getlength();
m_pctextbuffer = new tchar[ulength + 1];
if (m_pctextbuffer != null)
_tcscpy(m_pctextbuffer,(lpctstr)strfittedtext);
psti->lpsztext = m_pctextbuffer ;
m_mappwtoolsandwidths.setat( (void *)psti->hwnd,(word)umaxwidth);
}
}
this is the offending line:
umaxwidth = fittext(strfittedtext);
if i chnage that to somthing like umaxwidth = 100 then my application compiles and runs in debug mode with no asserts. so the problem relates to fittext:
uint cmultilinetooltipctrl::fittext(cstring &rstrtext)
{
cclientdc *pdc ;
cfont *pfnttip, *pfntold ;
crect rctmargin, rcttip ;
csize siztext ;
cstring strtextcopy, strline, strchaff ;
cstringarray arystrlines ;
uint umaxwidth, unumlines, ulineindex ;
umaxwidth = 0 ; // fallback.
getmargin(&rctmargin);
getclientrect(&rcttip);
// reduce by the given margins to get the true area.
rcttip.left += rctmargin.left ;
rcttip.top += rctmargin.top ;
rcttip.right -= rctmargin.right ;
rcttip.bottom -= rctmargin.bottom ;
pdc = new cclientdc(this);
if (pdc != null)
{
pfnttip = getfont();
pfntold = (cfont *)pdc->selectobject(pfnttip);
// first, find the longest line.
strtextcopy = rstrtext ;
umaxwidth = 0 ;
while (strtextcopy != _t("") )
{
strline = strtextcopy.spanexcluding(_t("\r\n") );
strtextcopy.delete(0, strline.getlength() );
strchaff = strtextcopy.spanincluding(_t("\r\n") );
strtextcopy.delete(0, strchaff.getlength() );
siztext = pdc->gettextextent(strline);
if (siztext.cx > (int)umaxwidth)
umaxwidth = siztext.cx ;
arystrlines.add(strline);
}
rstrtext = _t("");
unumlines = arystrlines.getsize();
// now, pad all lines to that max width.
for (ulineindex = 0 ; ulineindex < unumlines ; ulineindex++)
{
strline = arystrlines.getat(ulineindex);
siztext = pdc->gettextextent(strline);
while (siztext.cx <= (int)umaxwidth)
{
strline += _t(" ");
siztext = pdc->gettextextent(strline);
}
rstrtext += strline ;
}
sendmessage(ttm_setmaxtipwidth, 0, umaxwidth);
pdc->selectobject(pfntold);
delete pdc ;
}
return umaxwidth ;
}
sorry for putting yards of code in this message thread but i am abit out of my depth here. i can tell you that the problem relates to one of the cstring derived calls, specifically, it is failing here:
strchaff = strtextcopy.spanincluding(_t("\r\n") );
what can i do to get my code to work with dwgdirect so that it won't assert? thank you.
i added a define directive for dd_client_build to my application. problem resolved.
andrew
but note that the reason of assertion was that memcpy() was called for overlapping regions of memory which is incorrect (may not work).
memmove() should be used in such cases.
defining the symbol just hides the potential problem.
sergey slezkin
ok. but my class is using the cstring spanexcluding spanincluding (code is not to hand right now) functions which are microsoft mfc supplied. so i am not doing these memory calls myself ... so i don't really know what is wrong with the cstring class. if it were not for these mem replacements in dwgdirect, i would never know about such a problem.
andrew
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】2005 link error yang686526 DirectDWG 0 2009-05-04 02:57 PM
【转帖】asme美国机械工程师标准目录2 huangyhg American standards 5 2009-04-26 02:38 PM
【转帖】objectarx&dummies教程(十一)—— custom objectarx class yang686526 ObjectARX(C++) 0 2009-04-16 10:39 AM
C++风格与技巧(转) huangyhg vc编程 0 2008-10-27 11:03 AM
C++风格与技巧 Faq huangyhg vc编程 0 2007-10-29 02:24 PM


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


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