From 17d8d12249376805fd8d5df4994e69fdb26ee87e Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 1 Jun 2007 11:24:11 +0000 Subject: [PATCH] Fix a couple of crashes. Sync configuration information in SessionManager's destructor and fix problem with scroll optimisation. Not sure about that first one, it shouldn't do any harm, but I don't think it should be necessary either. svn path=/trunk/KDE/kdebase/apps/konsole/; revision=670398 --- src/ColorScheme.h | 12 +++++----- src/SessionManager.cpp | 3 +++ src/TerminalDisplay.cpp | 50 ++++++++++++++++++++++++----------------- src/ViewContainer.cpp | 3 ++- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/ColorScheme.h b/src/ColorScheme.h index e11c52434..a40b3f804 100644 --- a/src/ColorScheme.h +++ b/src/ColorScheme.h @@ -82,13 +82,16 @@ public: const ColorEntry* colorTable() const; /** - * Convenience method. Returns the foreground color for this scheme, this - * is the primary color used to draw the text in this scheme. + * Convenience method. Returns the + * foreground color for this scheme, + * this is the primary color used to draw the + * text in this scheme. */ QColor foregroundColor() const; /** - * Convenience method. Returns the background color for this scheme, this - * is the primary color used to draw the terminal background in this scheme. + * Convenience method. Returns the background color for + * this scheme, this is the primary color used to + * draw the terminal background in this scheme. */ QColor backgroundColor() const; @@ -108,7 +111,6 @@ public: */ qreal opacity() const; - //void setCursorColor(const QColor& color); //QColor cursorColor() const; diff --git a/src/SessionManager.cpp b/src/SessionManager.cpp index 7e699a717..b31076d45 100644 --- a/src/SessionManager.cpp +++ b/src/SessionManager.cpp @@ -166,6 +166,9 @@ SessionManager::~SessionManager() while (infoIter.hasNext()) delete infoIter.next(); + +#warning "This prevents a crash to do with accessing a global static globalData() after destruction, but it is probably not the correct solution." + KGlobal::config()->sync(); } const QList SessionManager::sessions() diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 6f508e4d6..ef5a68160 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -706,28 +706,38 @@ void TerminalDisplay::setCursorPos(const int curx, const int cury) // scrolled aligns properly with the character grid - // which has a top left point at (_bX,_bY) , // a cell width of _fontWidth and a cell height of _fontHeight). -void TerminalDisplay::scrollImage(int lines , const QRect& region) +void TerminalDisplay::scrollImage(int lines , const QRect& screenWindowRegion) { + // constrain the region to the display + // the bottom of the region is capped to the number of lines in the display's + // internal image - 2, so that the height of 'region' is strictly less + // than the height of the internal image. + QRect region = screenWindowRegion; + region.setBottom( qMin(region.bottom(),this->_lines-2) ); + if ( lines == 0 - || _image == 0 - || (region.top() + abs(lines)) >= region.height() - || this->_usedLines <= region.height() ) return; + || _image == 0 + || !region.isValid() + || (region.top() + abs(lines)) >= region.bottom() + || this->_lines <= region.height() ) return; + + QRect scrollRect; - // qDebug() << "Scrolled region: top =" << region.top() - // << ", bottom =" << region.bottom() - // << ", height =" << region.height() << "lines. Image height =" - // << this->_usedLines << "lines" - // << ", scroll =" << lines << "lines"; + //qDebug() << "Scrolled region: top =" << region.top() + // << ", bottom =" << region.bottom() + // << ", height =" << region.height() << "lines. Image height =" + // << this->_usedLines << "lines" + // << ", scroll =" << lines << "lines"; - void* firstCharPos = &_image[ region.top() * this->_usedColumns ]; - void* lastCharPos = &_image[ (region.top() + abs(lines)) * this->_usedColumns ]; + void* firstCharPos = &_image[ region.top() * this->_columns ]; + void* lastCharPos = &_image[ (region.top() + abs(lines)) * this->_columns ]; int top = _bY + (region.top() * _fontHeight); int linesToMove = region.height() - abs(lines); int bytesToMove = linesToMove * - this->_usedColumns * + this->_columns * sizeof(Character); Q_ASSERT( linesToMove > 0 ); @@ -738,9 +748,9 @@ void TerminalDisplay::scrollImage(int lines , const QRect& region) { // check that the memory areas that we are going to move are valid Q_ASSERT( (char*)lastCharPos + bytesToMove < - (char*)(_image + (this->_usedLines * this->_usedColumns)) ); + (char*)(_image + (this->_lines * this->_columns)) ); - assert( (lines*this->_usedColumns) < _imageSize ); + assert( (lines*this->_columns) < _imageSize ); //scroll internal image down memmove( firstCharPos , lastCharPos , bytesToMove ); @@ -755,7 +765,7 @@ void TerminalDisplay::scrollImage(int lines , const QRect& region) { // check that the memory areas that we are going to move are valid Q_ASSERT( (char*)firstCharPos + bytesToMove < - (char*)(_image + (this->_usedLines * this->_usedColumns)) ); + (char*)(_image + (this->_lines * this->_columns)) ); //scroll internal image up memmove( lastCharPos , firstCharPos , bytesToMove ); @@ -800,8 +810,8 @@ void TerminalDisplay::updateImage() _screenWindow->resetScrollCount(); Character* const newimg = _screenWindow->getImage(); - int _lines = _screenWindow->windowLines(); - int _columns = _screenWindow->windowColumns(); + int lines = _screenWindow->windowLines(); + int columns = _screenWindow->windowColumns(); setScroll( _screenWindow->currentLine() , _screenWindow->lineCount() ); @@ -822,14 +832,14 @@ void TerminalDisplay::updateImage() CharacterColor _clipboard; // undefined int cr = -1; // undefined - const int linesToUpdate = qMin(this->_lines, qMax(0,_lines )); - const int columnsToUpdate = qMin(this->_columns,qMax(0,_columns)); + const int linesToUpdate = qMin(this->_lines, qMax(0,lines )); + const int columnsToUpdate = qMin(this->_columns,qMax(0,columns)); QChar *disstrU = new QChar[columnsToUpdate]; char *dirtyMask = new char[columnsToUpdate+2]; QRegion dirtyRegion; - // debugging variable, this records the number of _lines that are found to + // debugging variable, this records the number of lines that are found to // be 'dirty' ( ie. have changed from the old _image to the new _image ) and // which therefore need to be repainted int dirtyLineCount = 0; diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp index 23734f219..1b5869b48 100644 --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -574,7 +574,8 @@ void TabbedViewContainerV2::removeViewWidget( QWidget* view ) void TabbedViewContainerV2::setTabActivity(int index , bool activity) { - const QColor activityColor = _tabBar->palette().highlight().color(); + const QColor activityColor = _tabBar->palette() + .highlight().color().dark(120); const QColor normalColor = _tabBar->palette().text().color(); QColor color = activity ? activityColor : normalColor;