Hi,
I noticed there is a bug in nglConsole AddToHistory and SetHistory
methods, which causes an aplication to crash when console
history limit is reached. The following patch seems to resolve
the problem:
--- nglConsole_shr.cpp Sat Jul 16 21:27:38 2005
+++ nglConsole_shr_new.cpp Sat Jul 16 21:37:46 2005
@@ -76,12 +76,13 @@
((CharMax > 0) && (mCharCnt > CharMax))))
{
list<nglString*>::iterator tail = mHistory.end();
+ tail--; //mHistory.end() return an iterator just past the last element
of a list, so tail needs to be decremented
if (*tail)
{
mCharCnt -= (*tail)->GetLength();
mLineCnt--;
+ delete (*tail);
mHistory.erase (tail);
- delete (*tail);
}
}
mLineMax = LineMax;
@@ -113,12 +114,14 @@
((mCharMax > 0) && (new_charcnt > mCharMax))))
{
list<nglString*>::iterator tail = mHistory.end();
+ tail--;
if (*tail)
{
new_charcnt -= (*tail)->GetLength();
new_linecnt--;
+ delete (*tail);
mHistory.erase (tail);
- delete (*tail);
}
}
newline = new nglString (rLine);
cheers,
Bart
--
"When the only tool you know is a hammer,
every problem looks like a nail."