summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-11-05 17:10:47 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-11-09 12:31:41 (GMT)
commit66e85acbc9db67b1f57e3dd6da0e9523e831728f (patch)
tree05c723f00794b8f9cf0df4e3a4390cc96307830e
parenta30be88f3bd62b84b1c4760cf7fa3fbef32ef23e (diff)
Silence ubsan warnings about invalid pointer casts
REVIEW: 129343
-rw-r--r--src/SessionController.cpp36
-rw-r--r--src/TerminalDisplay.cpp3
-rw-r--r--src/ViewManager.cpp4
3 files changed, 21 insertions, 22 deletions
diff --git a/src/SessionController.cpp b/src/SessionController.cpp
index 0e286e4..cc7cbfa 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);
-
- // 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);
-
- 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 (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
+
+ // 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();
}
}
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index a609c19..dd91177 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 2857c81..c187e64 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<TerminalDisplay*>(view);
- Q_ASSERT(display);
+ // We only need the pointer address to look it up below
+ TerminalDisplay* display = reinterpret_cast<TerminalDisplay*>(view);
// 1. detach view from session
// 2. if the session has no views left, close it