Silence ubsan warnings about invalid pointer casts

REVIEW: 129343
parent a30be88f
......@@ -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();
}
}
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment