Use Q_ASSERT to catch null pointers for _sessionController and session()

Summary:
Remove TerminalDisplay::sessionIsPrimaryScreen(), and use Q_ASSERT
instead, where if _sessionController is actually a nullptr it means
the current konsole process is doomed anyway. Better catch such cases in
debug builds.

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: konsole-devel, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D13271
wilder-portage
Ahmad Samir 8 years ago committed by Kurt Hindenburg
parent f9a2669486
commit 85ee52b10f
  1. 33
      src/TerminalDisplay.cpp
  2. 5
      src/TerminalDisplay.h

@ -795,15 +795,16 @@ void TerminalDisplay::setCursorStyle(Enum::CursorShapeEnum shape, bool isBlinkin
}
void TerminalDisplay::resetCursorStyle()
{
if (sessionController() != nullptr) {
Profile::Ptr currentProfile = SessionManager::instance()->sessionProfile(sessionController()->session());
Q_ASSERT(_sessionController != nullptr);
Q_ASSERT(_sessionController->session() != nullptr);
if (currentProfile != nullptr) {
Enum::CursorShapeEnum shape = static_cast<Enum::CursorShapeEnum>(currentProfile->property<int>(Profile::CursorShape));
Profile::Ptr currentProfile = SessionManager::instance()->sessionProfile(_sessionController->session());
setKeyboardCursorShape(shape);
setBlinkingCursorEnabled(currentProfile->blinkingCursorEnabled());
}
if (currentProfile != nullptr) {
Enum::CursorShapeEnum shape = static_cast<Enum::CursorShapeEnum>(currentProfile->property<int>(Profile::CursorShape));
setKeyboardCursorShape(shape);
setBlinkingCursorEnabled(currentProfile->blinkingCursorEnabled());
}
}
@ -2834,12 +2835,17 @@ void TerminalDisplay::wheelEvent(QWheelEvent* ev)
_scrollWheelState.addWheelEvent(ev);
_scrollBar->event(ev);
Q_ASSERT(_sessionController != nullptr);
_sessionController->setSearchStartToWindowCurrentLine();
_scrollWheelState.clearAll();
} else if (!_readOnly) {
_scrollWheelState.addWheelEvent(ev);
if(!_usesMouseTracking && !sessionIsPrimaryScreen() && _alternateScrolling) {
Q_ASSERT(_sessionController->session() != nullptr);
if(!_usesMouseTracking && !_sessionController->session()->isPrimaryScreen() && _alternateScrolling) {
// Send simulated up / down key presses to the terminal program
// for the benefit of programs such as 'less' (which use the alternate screen)
@ -2878,6 +2884,7 @@ void TerminalDisplay::wheelEvent(QWheelEvent* ev)
void TerminalDisplay::viewScrolledByUser()
{
Q_ASSERT(_sessionController != nullptr);
_sessionController->setSearchStartToWindowCurrentLine();
}
@ -3870,16 +3877,6 @@ SessionController* TerminalDisplay::sessionController()
return _sessionController;
}
bool TerminalDisplay::sessionIsPrimaryScreen()
{
Session *currentSession = _sessionController->session();
if (currentSession !=nullptr) {
return currentSession->isPrimaryScreen();
}
return true;
}
AutoScrollHandler::AutoScrollHandler(QWidget* parent)
: QObject(parent)
, _timerId(0)

@ -1037,11 +1037,6 @@ private:
SessionController *_sessionController;
// Returns true if the screen buffer used in the current session is
// the primary/normal buffer or false if it's the alternate/secondary
// one
bool sessionIsPrimaryScreen();
bool _trimLeadingSpaces; // trim leading spaces in selected text
bool _trimTrailingSpaces; // trim trailing spaces in selected text
bool _mouseWheelZoom; // enable mouse wheel zooming or not

Loading…
Cancel
Save