RHASHMAP Remove USER 208
@import url(http://www.shnenglu.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
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求解