| Summary: | Changing history lines count to 1 causes a crash while scrolling up | ||
|---|---|---|---|
| Product: | [Applications] konsole | Reporter: | Dmitry Suzdalev <dimsuz> |
| Component: | general | Assignee: | Konsole Bugs <konsole-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | crash | ||
| Priority: | NOR | ||
| Version First Reported In: | 1.4 | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Dmitry Suzdalev
2004-12-29 18:37:00 UTC
Well, after playing around for awhile, I got it to crash... QGVector::operator[]: Index 1 out of range QGVector::operator[]: Index 1 out of range To reproduce, first have the History to > 1 (the default 1000 is O.K.); do something to produce output in history (ls /dev). Now, change History to 1; scroll up until it crashes.... It appears that the # of lines saved is History->Number of lines - 1. Example: set number of lines to 10, 9 lines are saved. set to 1, 0 lines are saved. set to 2, 1 line is saved. ...etc. 0x4009c9fd in HistoryScrollBuffer::getLineLen(int) (this=0x807bb24, lineno=1)
at qgarray.h:79
79 uint size() const { return shd->len; }
It appears that for viewing history is actually History->lines - 1, which causes this error. Note that for saving history all the lines are saved.
This appears to fix this by having viewing history to actually be history->lines.
Needs testing....
Index: TEHistory.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/TEHistory.cpp,v
retrieving revision 1.25
diff -u -p -r1.25 TEHistory.cpp
--- TEHistory.cpp 28 Jun 2003 10:31:38 -0000 1.25
+++ TEHistory.cpp 31 Dec 2004 19:51:50 -0000
@@ -230,7 +230,8 @@ void HistoryScrollBuffer::addCells(ca a[
m_buffFilled = true;
}
- if (m_nbLines < m_maxNbLines - 1) ++m_nbLines;
+// if (m_nbLines < m_maxNbLines - 1) ++m_nbLines;
+ if (m_nbLines < m_maxNbLines ) ++m_nbLines; // Fixes BR95990 ?!?
// m_histBuffer.remove(m_arrayIndex); // not necessary
m_histBuffer.insert(m_arrayIndex, newLine);
Comment #3 is not enough to prevent the crashing. Index: TEHistory.cpp =================================================================== RCS file: /home/kde/kdebase/konsole/konsole/TEHistory.cpp,v retrieving revision 1.25 diff -u -p -r1.25 TEHistory.cpp --- TEHistory.cpp 28 Jun 2003 10:31:38 -0000 1.25 +++ TEHistory.cpp 8 Jan 2005 19:27:04 -0000 @@ -230,7 +230,7 @@ void HistoryScrollBuffer::addCells(ca a[ m_buffFilled = true; } - if (m_nbLines < m_maxNbLines - 1) ++m_nbLines; + if (m_nbLines < m_maxNbLines) ++m_nbLines; // m_histBuffer.remove(m_arrayIndex); // not necessary m_histBuffer.insert(m_arrayIndex, newLine); @@ -329,6 +329,7 @@ void HistoryScrollBuffer::setMaxNbLines( int HistoryScrollBuffer::adjustLineNb(int lineno) { + if (lineno == 0) return 0; if (m_buffFilled) return (lineno + m_arrayIndex + 2) % m_maxNbLines; else On another note, changing the history line # to a smaller # when there is text in the buffer is buggy. Looks like void HistoryScrollBuffer::setMaxNbLines() needs fixed. CVS commit by hindenburg:
Prevent crash when History changed to 1. Konsole's History needs some TLC.
BUG: 95990
M +1 -1 TEHistory.cpp 1.26
--- kdebase/konsole/konsole/TEHistory.cpp #1.25:1.26
@@ -333,5 +333,5 @@ int HistoryScrollBuffer::adjustLineNb(in
return (lineno + m_arrayIndex + 2) % m_maxNbLines;
else
- return lineno + 1;
+ return lineno ? lineno + 1 : 0;
}
|