RHASHMAP Remove USER 208

RHASHMAP Remove USER 208

@import url(http://www.cppblog.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
 1  for  (CImageIndexItem *   const *  p  =  iter.NextValue(); p; p  =  iter.NextValue() )
 2      {
 3           if ( * p)
 4          {
 5              TTime temp(( * p) -> iImageTime );
 6              TTimeIntervalDays iInterval  =  homeTime.DaysFrom(temp);
 7               if (iInterval.Int()  >   2 )
 8              { 
 9                   // 如果超出期限,删除本地图片文件           
10                  ( * p) -> DeleteBitmap();               
11                  TBuf8 < 64 >  iname;
12                  iname.Copy(  * (( * p) -> iImageName) );
13                  delete  * p;
14                  TInt why  =  iImageIndexArrayHashMap -> Remove(iname);
15                  iter.Reset();
16              }            
17          }        
18      }

图片引擎使用了RHashMap,结果在RHashMap::Remove的时候出现了很奇怪的问题,指针*p执行完Remove后被改变了指向地址,造成再次调用出现空指针错误,将对*p的调用调至Remove语句之上,在循环中会出现User208错误,根据官方的文档描述如下:This panic is raised by the member function Next() of the internal class THashTableIterBase if, while attempting to step a hash table iterator to the next entry, the iterator is found to point to an invalid table entry. This will typically occur if elements have been removed from the hash table without resetting the iterator. 于是在Remove之后添加iter.Reset(),问题解决,不过仍然不了解Remove里面对其做了什么操作造成类似的问题,Mark求解

你可能感兴趣的:(RHASHMAP Remove USER 208)