mirror of
https://github.com/KDE/konsole.git
synced 2026-06-12 07:55:07 -04:00
Use a return value instead of just Q_ASSERT - don't crash in production
(cherry picked from commit cb1536aaba)
This commit is contained in:
@@ -507,7 +507,11 @@ int CompactHistoryScroll::getLines()
|
||||
|
||||
int CompactHistoryScroll::getLineLen(int lineNumber)
|
||||
{
|
||||
Q_ASSERT(lineNumber >= 0 && lineNumber < _lines.size());
|
||||
if ((lineNumber < 0) || (lineNumber >= _lines.size())) {
|
||||
kDebug() << "requested line invalid: 0 < " << lineNumber << " < " <<_lines.size();
|
||||
Q_ASSERT(lineNumber >= 0 && lineNumber < _lines.size());
|
||||
return 0;
|
||||
}
|
||||
CompactHistoryLine* line = _lines[lineNumber];
|
||||
//kDebug() << "request for line at address " << line;
|
||||
return line->getLength();
|
||||
|
||||
@@ -126,8 +126,8 @@ void HistoryTest::testHistoryScroll()
|
||||
historyScroll = new CompactHistoryScroll(42);
|
||||
QVERIFY(historyScroll->hasScroll());
|
||||
QCOMPARE(historyScroll->getLines(), 0);
|
||||
// QASSERT catches this - QCOMPARE(historyScroll->getLineLen(0), 0);
|
||||
// QASSERT catches this - QCOMPARE(historyScroll->getLineLen(10), 0);
|
||||
QCOMPARE(historyScroll->getLineLen(0), 0);
|
||||
QCOMPARE(historyScroll->getLineLen(10), 0);
|
||||
|
||||
const HistoryType& compactHistoryType = historyScroll->getType();
|
||||
QCOMPARE(compactHistoryType.isEnabled(), true);
|
||||
|
||||
Reference in New Issue
Block a user