diff --git a/src/SessionController.cpp b/src/SessionController.cpp index 0e286e45f..cc7cbfa54 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -450,25 +450,23 @@ void SessionController::sendBackgroundColor() bool SessionController::eventFilter(QObject* watched , QEvent* event) { - if (watched == _view) { - if (event->type() == QEvent::FocusIn) { - // notify the world that the view associated with this session has been focused - // used by the view manager to update the title of the MainWindow widget containing the view - emit focused(this); + if (event->type() == QEvent::FocusIn && watched == _view) { + // notify the world that the view associated with this session has been focused + // used by the view manager to update the title of the MainWindow widget containing the view + emit focused(this); - // when the view is focused, set bell events from the associated session to be delivered - // by the focused view + // when the view is focused, set bell events from the associated session to be delivered + // by the focused view - // first, disconnect any other views which are listening for bell signals from the session - disconnect(_session.data(), &Konsole::Session::bellRequest, 0, 0); - // second, connect the newly focused view to listen for the session's bell signal - connect(_session.data(), &Konsole::Session::bellRequest, _view.data(), &Konsole::TerminalDisplay::bell); + // first, disconnect any other views which are listening for bell signals from the session + disconnect(_session.data(), &Konsole::Session::bellRequest, 0, 0); + // second, connect the newly focused view to listen for the session's bell signal + connect(_session.data(), &Konsole::Session::bellRequest, _view.data(), &Konsole::TerminalDisplay::bell); - if (_copyInputToAllTabsAction && _copyInputToAllTabsAction->isChecked()) { - // A session with "Copy To All Tabs" has come into focus: - // Ensure that newly created sessions are included in _copyToGroup! - copyInputToAllTabs(); - } + if (_copyInputToAllTabsAction && _copyInputToAllTabsAction->isChecked()) { + // A session with "Copy To All Tabs" has come into focus: + // Ensure that newly created sessions are included in _copyToGroup! + copyInputToAllTabs(); } } diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index a609c195b..dd9117792 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -3466,9 +3466,9 @@ bool AutoScrollHandler::eventFilter(QObject* watched, QEvent* event) Q_ASSERT(watched == parent()); Q_UNUSED(watched); - QMouseEvent* mouseEvent = (QMouseEvent*)event; switch (event->type()) { case QEvent::MouseMove: { + QMouseEvent* mouseEvent = (QMouseEvent*)event; bool mouseInWidget = widget()->rect().contains(mouseEvent->pos()); if (mouseInWidget) { if (_timerId) @@ -3483,6 +3483,7 @@ bool AutoScrollHandler::eventFilter(QObject* watched, QEvent* event) break; } case QEvent::MouseButtonRelease: { + QMouseEvent* mouseEvent = (QMouseEvent*)event; if (_timerId && (mouseEvent->buttons() & ~Qt::LeftButton)) { killTimer(_timerId); _timerId = 0; diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 2857c81a5..c187e6461 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -720,8 +720,8 @@ void ViewManager::viewDestroyed(QWidget* view) { // Note: the received QWidget has already been destroyed, so // using dynamic_cast<> or qobject_cast<> does not work here - TerminalDisplay* display = static_cast(view); - Q_ASSERT(display); + // We only need the pointer address to look it up below + TerminalDisplay* display = reinterpret_cast(view); // 1. detach view from session // 2. if the session has no views left, close it