Fix crash when making selections and add some safety checks.

svn path=/branches/work/konsole-split-view/; revision=626511
wilder-portage
Robert Knight 19 years ago
parent ac1e860c35
commit ed6c1057cc
  1. 30
      konsole/SessionController.cpp
  2. 34
      konsole/SessionController.h
  3. 24
      konsole/TEScreen.cpp

@ -24,6 +24,7 @@
// at the time of writing
#include <kio/job.h>
KIcon SessionController::_activityIcon;
KIcon SessionController::_silenceIcon;
@ -265,7 +266,7 @@ void SessionTask::addSession(TESession* session)
{
_sessions << session;
}
QList<SessionTask::SessionPtr> SessionTask::sessions() const
QList<SessionPtr> SessionTask::sessions() const
{
return _sessions;
}
@ -397,4 +398,31 @@ void SearchHistoryTask::execute()
// not yet implemented
}
SearchHistoryThread::SearchHistoryThread(SessionPtr session , QObject* parent)
: QThread(parent)
, _session(session)
, _lastLineFetched(-1)
, _decoder( new PlainTextDecoder() )
{
}
SearchHistoryThread::~SearchHistoryThread()
{
delete _decoder;
}
void SearchHistoryThread::setRegExp(const QRegExp& expression)
{
_regExp = expression;
}
QRegExp SearchHistoryThread::regExp() const
{
return _regExp;
}
void SearchHistoryThread::run()
{
}
#include "SessionController.moc"

@ -6,6 +6,7 @@
#include <QList>
#include <QPointer>
#include <QString>
#include <QThread>
// KDE
#include <KActionCollection>
@ -22,11 +23,14 @@ class UrlFilter;
class TerminalCharacterDecoder;
class KJob;
namespace KIO
{
class Job;
};
typedef QPointer<TESession> SessionPtr;
/**
* Provides the actions associated with a session in the Konsole main menu
* and exposes information such as the title and icon associated with the session to view containers.
@ -143,7 +147,6 @@ signals:
void completed();
protected:
typedef QPointer<TESession> SessionPtr;
/** Returns a list of sessions in the group */
QList< SessionPtr > sessions() const;
@ -196,6 +199,7 @@ private:
QHash<KJob*,SaveJob> _jobSession;
};
class SearchHistoryThread;
/**
* A task which searches through the output of sessions for matches for a given regular expression.
*
@ -234,8 +238,34 @@ signals:
* @param endColumn The column in the output where the matched text ends
*/
void foundMatch(TESession* session , int startLine , int startColumn , int endLine , int endColumn );
private:
private:
QRegExp _regExp;
};
class SearchHistoryThread : public QThread
{
Q_OBJECT
public:
SearchHistoryThread(SessionPtr session , QObject* parent);
virtual ~SearchHistoryThread();
void setRegExp(const QRegExp& expression);
QRegExp regExp() const;
signals:
void foundMatch(TESession* session , int startLine , int startColumn , int endLine , int endColumn );
protected:
virtual void run();
private:
SessionPtr _session;
int _lastLineFetched;
TerminalCharacterDecoder* _decoder;
QRegExp _regExp;
};

@ -1375,16 +1375,30 @@ void TEScreen::copyLineToStream(int line , int start, int count,
static ca characterBuffer[MAX_CHARS];
assert( count < MAX_CHARS );
//determine if the line is in the history buffer or the screen image
if (line < hist->getLines())
{
const int lineLength = hist->getLineLen(line);
// ensure that start position is before end of line
start = qMin(start,lineLength-1);
//retrieve line from history buffer
if (count == -1)
count = hist->getLineLen(line)-start;
{
count = lineLength-start;
}
else
count = qMin(start+count,hist->getLineLen(line))-start;
{
count = qMin(start+count,lineLength)-start;
}
// safety checks
assert( start >= 0 );
assert( count >= 0 );
assert( (start+count) <= hist->getLineLen(line) );
hist->getCells(line,start,count,characterBuffer);
}
else
@ -1392,6 +1406,8 @@ void TEScreen::copyLineToStream(int line , int start, int count,
if ( count == -1 )
count = columns - start;
assert( count >= 0 );
ca* data = screenLines[line-hist->getLines()].data();
int length = screenLines[line-hist->getLines()].count();

Loading…
Cancel
Save