Replace abort() with Q_ASSERT and Q_UNREACHABLE
This change replaces abort() with Q_ASSERT and Q_UNREACHABLE() macros to make kwin code base consistent. Besides that, Q_UNREACHABLE may potentially provide the compiler more info that can be used to generate more efficient machine code.
This commit is contained in:
parent
dde3010353
commit
5f83f2a781
9 changed files with 22 additions and 19 deletions
|
@ -1237,7 +1237,7 @@ void AbstractClient::handleInteractiveMoveResize(int x, int y, int x_root, int y
|
||||||
break;
|
break;
|
||||||
case PositionCenter:
|
case PositionCenter:
|
||||||
default:
|
default:
|
||||||
abort();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1442,8 +1442,9 @@ void AbstractClient::handleInteractiveMoveResize(int x, int y, int x_root, int y
|
||||||
}
|
}
|
||||||
if (moveResizeGeometry().topLeft() != previousMoveResizeGeom.topLeft())
|
if (moveResizeGeometry().topLeft() != previousMoveResizeGeom.topLeft())
|
||||||
update = true;
|
update = true;
|
||||||
} else
|
} else {
|
||||||
abort();
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
if (!update)
|
if (!update)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -116,8 +116,9 @@ InputRedirection::KeyboardKeyState KeyEvent::state() const
|
||||||
return InputRedirection::KeyboardKeyPressed;
|
return InputRedirection::KeyboardKeyPressed;
|
||||||
case LIBINPUT_KEY_STATE_RELEASED:
|
case LIBINPUT_KEY_STATE_RELEASED:
|
||||||
return InputRedirection::KeyboardKeyReleased;
|
return InputRedirection::KeyboardKeyReleased;
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t KeyEvent::time() const
|
uint32_t KeyEvent::time() const
|
||||||
|
@ -183,8 +184,9 @@ InputRedirection::PointerButtonState PointerEvent::buttonState() const
|
||||||
return InputRedirection::PointerButtonPressed;
|
return InputRedirection::PointerButtonPressed;
|
||||||
case LIBINPUT_BUTTON_STATE_RELEASED:
|
case LIBINPUT_BUTTON_STATE_RELEASED:
|
||||||
return InputRedirection::PointerButtonReleased;
|
return InputRedirection::PointerButtonReleased;
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<InputRedirection::PointerAxis> PointerEvent::axis() const
|
QVector<InputRedirection::PointerAxis> PointerEvent::axis() const
|
||||||
|
|
|
@ -1857,7 +1857,7 @@ void EffectWindowImpl::refWindow()
|
||||||
if (auto d = qobject_cast<Deleted *>(toplevel)) {
|
if (auto d = qobject_cast<Deleted *>(toplevel)) {
|
||||||
return d->refWindow();
|
return d->refWindow();
|
||||||
}
|
}
|
||||||
abort(); // TODO
|
Q_UNREACHABLE(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectWindowImpl::unrefWindow()
|
void EffectWindowImpl::unrefWindow()
|
||||||
|
@ -1865,7 +1865,7 @@ void EffectWindowImpl::unrefWindow()
|
||||||
if (auto d = qobject_cast<Deleted *>(toplevel)) {
|
if (auto d = qobject_cast<Deleted *>(toplevel)) {
|
||||||
return d->unrefWindow(); // delays deletion in case
|
return d->unrefWindow(); // delays deletion in case
|
||||||
}
|
}
|
||||||
abort(); // TODO
|
Q_UNREACHABLE(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectScreen *EffectWindowImpl::screen() const
|
EffectScreen *EffectWindowImpl::screen() const
|
||||||
|
|
|
@ -1998,7 +1998,7 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abort(); // Should never get here
|
Q_UNREACHABLE(); // Should never get here
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectWindow* PresentWindowsEffect::findFirstWindow() const
|
EffectWindow* PresentWindowsEffect::findFirstWindow() const
|
||||||
|
|
|
@ -189,7 +189,7 @@ int Monitor::selectedEdgeItem(int edge) const
|
||||||
return actions.indexOf(act);
|
return actions.indexOf(act);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abort();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::popup(Corner* c, QPoint pos)
|
void Monitor::popup(Corner* c, QPoint pos)
|
||||||
|
@ -209,7 +209,7 @@ void Monitor::popup(Corner* c, QPoint pos)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abort();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::flip(Corner* c, QPoint pos)
|
void Monitor::flip(Corner* c, QPoint pos)
|
||||||
|
@ -225,7 +225,7 @@ void Monitor::flip(Corner* c, QPoint pos)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abort();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
Monitor::Corner::Corner(Monitor* m)
|
Monitor::Corner::Corner(Monitor* m)
|
||||||
|
|
|
@ -1382,8 +1382,7 @@ void WindowMotionManager::apply(EffectWindow *w, WindowPaintData &data)
|
||||||
void WindowMotionManager::moveWindow(EffectWindow *w, QPoint target, double scale, double yScale)
|
void WindowMotionManager::moveWindow(EffectWindow *w, QPoint target, double scale, double yScale)
|
||||||
{
|
{
|
||||||
QHash<EffectWindow*, WindowMotion>::iterator it = m_managedWindows.find(w);
|
QHash<EffectWindow*, WindowMotion>::iterator it = m_managedWindows.find(w);
|
||||||
if (it == m_managedWindows.end())
|
Q_ASSERT(it != m_managedWindows.end()); // Notify the effect author that they did something wrong
|
||||||
abort(); // Notify the effect author that they did something wrong
|
|
||||||
|
|
||||||
WindowMotion *motion = &it.value();
|
WindowMotion *motion = &it.value();
|
||||||
|
|
||||||
|
|
|
@ -179,8 +179,9 @@ void UserActionsMenu::helperDialog(const QString& message, AbstractClient* clien
|
||||||
"activated using the %1 keyboard shortcut.",
|
"activated using the %1 keyboard shortcut.",
|
||||||
shortcut(QStringLiteral("Window Operations Menu")));
|
shortcut(QStringLiteral("Window Operations Menu")));
|
||||||
type = QStringLiteral("altf3warning");
|
type = QStringLiteral("altf3warning");
|
||||||
} else
|
} else {
|
||||||
abort();
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
if (!type.isEmpty()) {
|
if (!type.isEmpty()) {
|
||||||
KConfig cfg(QStringLiteral("kwin_dialogsrc"));
|
KConfig cfg(QStringLiteral("kwin_dialogsrc"));
|
||||||
KConfigGroup cg(&cfg, "Notification Messages"); // Depends on KMessageBox
|
KConfigGroup cg(&cfg, "Notification Messages"); // Depends on KMessageBox
|
||||||
|
|
|
@ -2718,7 +2718,7 @@ QRect Workspace::adjustClientSize(AbstractClient* c, QRect moveResizeGeom, int m
|
||||||
SNAP_BORDER_LEFT
|
SNAP_BORDER_LEFT
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2846,7 +2846,7 @@ QRect Workspace::adjustClientSize(AbstractClient* c, QRect moveResizeGeom, int m
|
||||||
SNAP_WINDOW_C_LEFT
|
SNAP_WINDOW_C_LEFT
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1189,7 +1189,7 @@ void X11Client::detectNoBorder()
|
||||||
noborder = false;
|
noborder = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
// NET::Override is some strange beast without clear definition, usually
|
// NET::Override is some strange beast without clear definition, usually
|
||||||
// just meaning "noborder", so let's treat it only as such flag, and ignore it as
|
// just meaning "noborder", so let's treat it only as such flag, and ignore it as
|
||||||
|
@ -4660,7 +4660,7 @@ StrutRect X11Client::strutRect(StrutArea area) const
|
||||||
), StrutAreaLeft);
|
), StrutAreaLeft);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort(); // Not valid
|
Q_UNREACHABLE(); // Not valid
|
||||||
}
|
}
|
||||||
return StrutRect(); // Null rect
|
return StrutRect(); // Null rect
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue