[求助]求助高手!!我的这段程序错在哪里?
各位高手:假如我先运行getData函数,不运行setData函数,则一切正常,或者只运行setData函数也一切正常,<B><FONT color=#dd4822>但如果我先运行getData再运行 setData函数</FONT></B>,AUTOCAD就出错并关闭(出错的地方已标出),高手能告诉我为什么吗?程序如下:<BR>char* getData()<BR>{<BR> Acad::ErrorStatus es;<BR> AcDbDictionary *pNamedObj;<BR> acdbCurDwg()->getNamedObjectsDictionary (pNamedObj,AcDb::kForRead );<BR> AcDbDictionary *pDict;es=pNamedObj->getAt("SmartDict",(AcDbObject*&)pDict,AcDb::kForRead );<BR> if (es==Acad::eOk )<BR> {<BR> AcDbXrecord * pXrec1;<BR> es=pDict->getAt("XREC1",(AcDbObject*&)pXrec1,AcDb::kForRead );<BR> if (es==Acad::eOk )<BR> {<BR> struct resbuf *pHead;<BR> pXrec1->rbChain(&pHead);<BR> for(int i=0;i<index;i++,pHead=pHead->rbnext)<BR> { }<BR><BR> return pHead->resval.rstring;<BR> ads_relrb(pHead);<BR> <BR> }<BR><BR> //pXrec1=NULL;<BR> //delete pXrec1;<BR> /* pXrec1->close ();<BR> pDict->close ();<BR> pNamedObj->close ();*/<BR> }<BR> else<BR> {<BR> //pDict->close ();<BR> //pNamedObj->close (); <BR> return NULL;<BR> }
<BR>}
/*---------------------------------------------------------------*/<BR>void setData() <BR>{<BR> Acad::ErrorStatus es;<BR> AcDbDictionary *pNamedObj;<BR> AcDbDictionary *pDict=new AcDbDictionary;<BR> AcDbObjectId DictId;
acDocManager->lockDocument( acDocManager->curDocument(), AcAp::kWrite,NULL,NULL,true);
acdbCurDwg()->getNamedObjectsDictionary (pNamedObj,AcDb::kForWrite );
es=pNamedObj->setAt("SmartDict",pDict,DictId);//<FONT color=#ff0000><B>在这出错<BR></B></FONT> acutPrintf(_T("\n无法执行:pNamedObj->setAt (%s)"),acadErrorStatusText(es));<BR> <BR>if (es==Acad::eOk)<BR>{ <BR>//。。。。。<BR> }<BR><BR> //pNamedObj->close ();<BR> //pDict->close();<BR> // pDict=NULL;<BR> //delete pDict;<BR> acDocManager->unlockDocument( acDocManager->curDocument()) ;<BR>}
页:
[1]