0
点赞
收藏
分享

微信扫一扫

如果没有选中任何线型, CAcUiLineTypeComboBox 崩溃的原因





软件架构师何志丹

如果没有选中任何线型,GetItemDataPtr 会返回-1而不是0,getOIDSel 只判断了NULL,没有判断-1,故崩溃。

开发环境:Win10+VS2010+acad2014

arx的代码:

inline 
AcDbObjectId
CAcUiLineTypeComboBox::getOIDSel(int sel)
{
AcDbObjectId oidLT;
CAcUiLTypeRecord* pLTRec =
(CAcUiLTypeRecord*)(GetItemDataPtr(sel));
if (NULL != pLTRec)
oidLT = pLTRec->objectId();
return oidLT;
}
修改的代码:
class CLineTypeComboBox : public CAcUiLineTypeComboBox
{
public:
AcDbObjectId
CLineTypeComboBox::getOIDSel(int sel)
{
AcDbObjectId oidLT;
CAcUiLTypeRecord* pLTRec =
(CAcUiLTypeRecord*)(GetItemDataPtr(sel));
if ( ( NULL != pLTRec ) && ( -1 != (int)pLTRec) )
oidLT = pLTRec->objectId();
return oidLT;
}
AcDbObjectId getOIDCurSel()
{
return getOIDSel(GetCurSel());
}
};

举报

相关推荐

0 条评论