buanhui 发表于 2003-7-10 15:50:00

一个文挡反映器的错误,希望得到解决

问题,我的程序在没有加文挡反映器时,一切正常,可一加上文挡反映器时,关闭文挡抱错(见图)后经过进一步调试,发现问提在于
if (pActivatingDoc){.......}里头的代码有关,我自己实在找不出问题在那里,请教各位斑竹
我加了一个文挡反映器class bahQieTiDocManagReactor : public AcApDocManagerReactor
添加了如下功能函数
void bahQieTiDocManagReactor::documentBecameCurrent(AcApDocument* pActivatingDoc)
{
      // TODO: implement this function.
      if (pActivatingDoc)//问题在于下面在{...}之间的代码
      {
                        acDocManager->lockDocument( acDocManager->curDocument(), AcAp::kWrite,NULL,NULL,true) ;
                        AcDbDictionary *pNamedobj;
                        AcDbDictionary *pDict;
                        acdbHostApplicationServices()->workingDatabase()
                              ->getNamedObjectsDictionary(pNamedobj, AcDb::kForRead);
                        // Get a pointer to the ASDK_DICT dictionary.
                        
                        AcGeIntArray layerHaoArry;
                        if(pNamedobj->getAt("MYLAYER_DICT",(AcDbObject*&)pDict,AcDb::kForRead)==Acad::eOk )
                        {
                              
                              // Run through the entries and list their backpointers.
                              
                              
                              AcDbDictionaryIterator *pDictItr = pDict->newIterator();
                              for (; !pDictItr->done(); pDictItr->next())
                              {
                                        //printOut(pDictItr->objectId());
                                        AcDbObjectId      id=pDictItr->objectId();
                                        AcDbMyLayer *pDemo;
                                        acdbOpenObject((AcDbObject*&)pDemo, id, AcDb::kForRead);
                                        layerHaoArry.append(pDemo->intData());
                                        acutPrintf("====2=======:%d\n",pDemo->intData());
                                        pDemo->close();
                                       
                              }
                        }
                        pNamedobj->close();
                        pDict->close();
                        int tempLayerHao0,tempLayerHao1;
                        for(int p=0;punlockDocument( acDocManager->curDocument());
                        
                        for(int i=0;im_cmbDrawingLayer.InsertString( i, cr );}
                        }
                        
                        
      }
m_AihuiToolBar为全局toolBar指针
在void InitApplication()
{
      if(pQieTiDoc==NULL){
      
                pQieTiDoc=new bahQieTiDocManagReactor();
      }
      
      acDocManager->addReactor(pQieTiDoc);
}
void UnloadApplication()
{
      acDocManager->removeReactor(pQieTiDoc);
}
其中pQieTiDoc为全局bahQieTiDocManagReactor 指针

goldenshin 发表于 2003-7-10 18:01:00

1) pDictItr 没delete?
2) 以下3个文档同时使用有没有问题,我不明白:
acdbHostApplicationServices()->workingDatabase(),
pActivatingDoc
acDocManager->curDocument()
页: [1]
查看完整版本: 一个文挡反映器的错误,希望得到解决