kwin: repalce abort() calls with kFatal()

kFatal() also aborts but logs a message (if configured to do so)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-10 21:30:15 +03:00
parent 0b0b9261e5
commit 39644edba3
12 changed files with 54 additions and 46 deletions

View file

@ -601,7 +601,7 @@ void Client::detectNoBorder()
noborder = false; noborder = false;
break; break;
default: default:
abort(); kFatal() << "Something strange happened";
} }
} }

View file

@ -997,7 +997,7 @@ bool Client::shouldUnredirect() const
if (c->geometry().intersects(geometry())) if (c->geometry().intersects(geometry()))
return false; return false;
} }
abort(); kFatal() << "Something strange happened";
} }
return false; return false;
} }
@ -1023,7 +1023,7 @@ bool Unmanaged::shouldUnredirect() const
if (c->geometry().intersects(geometry())) if (c->geometry().intersects(geometry()))
return false; return false;
} }
abort(); kFatal() << "Something strange happened";
} }
return false; return false;
} }

View file

@ -1543,21 +1543,24 @@ const EffectWindowGroup* EffectWindowImpl::group() const
{ {
if (Client* c = qobject_cast< Client* >(toplevel)) if (Client* c = qobject_cast< Client* >(toplevel))
return c->group()->effectGroup(); return c->group()->effectGroup();
return NULL; // TODO // TODO
return NULL;
} }
void EffectWindowImpl::refWindow() void EffectWindowImpl::refWindow()
{ {
if (Deleted* d = qobject_cast< Deleted* >(toplevel)) if (Deleted* d = qobject_cast< Deleted* >(toplevel))
return d->refWindow(); return d->refWindow();
abort(); // TODO // TODO
kFatal() << "Something strange happened";
} }
void EffectWindowImpl::unrefWindow() void EffectWindowImpl::unrefWindow()
{ {
if (Deleted* d = qobject_cast< Deleted* >(toplevel)) if (Deleted* d = qobject_cast< Deleted* >(toplevel))
return d->unrefWindow(); // delays deletion in case return d->unrefWindow(); // delays deletion in case
abort(); // TODO // TODO
kFatal() << "Something strange happened";
} }
void EffectWindowImpl::setWindow(Toplevel* w) void EffectWindowImpl::setWindow(Toplevel* w)

View file

@ -1863,7 +1863,8 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i
} }
} }
abort(); // Should never get here // Should never get here
kFatal() << "Something strange happened";
} }
EffectWindow* PresentWindowsEffect::findFirstWindow() const EffectWindow* PresentWindowsEffect::findFirstWindow() const

View file

@ -313,7 +313,7 @@ QRect Workspace::clientArea(clientAreaOption opt, int screen, int desktop) const
case FullArea: case FullArea:
return QRect(0, 0, displayWidth(), displayHeight()); return QRect(0, 0, displayWidth(), displayHeight());
} }
abort(); kFatal() << "Something strange happened";
} }
@ -650,7 +650,7 @@ QRect Workspace::adjustClientSize(Client* c, QRect moveResizeGeom, int mode)
SNAP_BORDER_LEFT SNAP_BORDER_LEFT
break; break;
default: default:
abort(); kFatal() << "Something strange happened";
break; break;
} }
@ -779,7 +779,7 @@ QRect Workspace::adjustClientSize(Client* c, QRect moveResizeGeom, int mode)
SNAP_WINDOW_C_LEFT SNAP_WINDOW_C_LEFT
break; break;
default: default:
abort(); kFatal() << "Something strange happened";
break; break;
} }
} }
@ -987,7 +987,7 @@ StrutRect Client::strutRect(StrutArea area) const
), StrutAreaLeft); ), StrutAreaLeft);
break; break;
default: default:
abort(); // Not valid kFatal() << "Something strange happened"; // Not valid
} }
return StrutRect(); // Null rect return StrutRect(); // Null rect
} }
@ -2836,7 +2836,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root)
break; break;
case PositionCenter: case PositionCenter:
default: default:
abort(); kFatal() << "Something strange happened";
break; break;
} }
// adjust new size to snap to other windows/borders // adjust new size to snap to other windows/borders
@ -2936,7 +2936,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root)
break; break;
case PositionCenter: case PositionCenter:
default: default:
abort(); kFatal() << "Something strange happened";
break; break;
} }
@ -3026,8 +3026,9 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root)
} }
if (moveResizeGeom.topLeft() != previousMoveResizeGeom.topLeft()) if (moveResizeGeom.topLeft() != previousMoveResizeGeom.topLeft())
update = true; update = true;
} else } else {
abort(); kFatal() << "Something strange happened";
}
if (!update) if (!update)
return; return;

View file

@ -153,7 +153,7 @@ static void checkTransiency()
if (!performTransiencyCheck()) { if (!performTransiencyCheck()) {
kDebug(1212) << "BT:" << transiencyCheckStartBt; kDebug(1212) << "BT:" << transiencyCheckStartBt;
kDebug(1212) << "CLIENT:" << transiencyCheckClient; kDebug(1212) << "CLIENT:" << transiencyCheckClient;
abort(); kFatal() << "Something strange happened";
} }
transiencyCheckNonExistent = false; transiencyCheckNonExistent = false;
} }

View file

@ -46,6 +46,7 @@
#include <QScrollBar> #include <QScrollBar>
#include <QUiLoader> #include <QUiLoader>
// KDE // KDE
#include <KDebug>
#include <KAboutData> #include <KAboutData>
#include <KDialog> #include <KDialog>
#include <KLocalizedString> #include <KLocalizedString>
@ -54,7 +55,6 @@
#include <KConfigDialogManager> #include <KConfigDialogManager>
#include <KPluginFactory> #include <KPluginFactory>
#include <Plasma/ConfigLoader> #include <Plasma/ConfigLoader>
#include <qdeclarative.h>
// KCModule plugin interface // KCModule plugin interface
// ========================= // =========================
@ -124,7 +124,7 @@ void KWinDecorationModule::init()
"The resource<h2>kwin/kcm_kwindecoration/main.qml</h2>could not be located in any application data path." "The resource<h2>kwin/kcm_kwindecoration/main.qml</h2>could not be located in any application data path."
"<h2>Please contact your distribution</h2>" "<h2>Please contact your distribution</h2>"
"The application will now abort", "Installation Error"); "The application will now abort", "Installation Error");
abort(); kFatal() << "Something strange happened";
} }
KConfigGroup style(kwinConfig, "Style"); KConfigGroup style(kwinConfig, "Style");

View file

@ -273,7 +273,8 @@ static const char* tbl_num_lookup(const char* const arr[], int pos)
return arr[ i ]; return arr[ i ];
--pos; --pos;
} }
abort(); // should never happen this way // should never happen this way
kFatal() << "Something strange happened";
} }
static int tbl_txt_lookup(const char* const arr[], const char* txt) static int tbl_txt_lookup(const char* const arr[], const char* txt)
@ -291,20 +292,21 @@ static int tbl_txt_lookup(const char* const arr[], const char* txt)
void KTitleBarActionsConfig::setComboText(KComboBox* combo, const char*txt) void KTitleBarActionsConfig::setComboText(KComboBox* combo, const char*txt)
{ {
if (combo == m_ui->coTiDbl) if (combo == m_ui->coTiDbl) {
combo->setCurrentIndex(tbl_txt_lookup(tbl_TiDbl, txt)); combo->setCurrentIndex(tbl_txt_lookup(tbl_TiDbl, txt));
else if (combo == m_ui->coTiAct1 || combo == m_ui->coTiAct2 || combo == m_ui->coTiAct3) } else if (combo == m_ui->coTiAct1 || combo == m_ui->coTiAct2 || combo == m_ui->coTiAct3) {
combo->setCurrentIndex(tbl_txt_lookup(tbl_TiAc, txt)); combo->setCurrentIndex(tbl_txt_lookup(tbl_TiAc, txt));
else if (combo == m_ui->coTiInAct1 || combo == m_ui->coTiInAct2 || combo == m_ui->coTiInAct3) } else if (combo == m_ui->coTiInAct1 || combo == m_ui->coTiInAct2 || combo == m_ui->coTiInAct3) {
combo->setCurrentIndex(tbl_txt_lookup(tbl_TiInAc, txt)); combo->setCurrentIndex(tbl_txt_lookup(tbl_TiInAc, txt));
else if (combo == m_ui->coTiAct4) } else if (combo == m_ui->coTiAct4) {
combo->setCurrentIndex(tbl_txt_lookup(tbl_TiWAc, txt)); combo->setCurrentIndex(tbl_txt_lookup(tbl_TiWAc, txt));
else if (combo == m_ui->leftClickMaximizeButton || } else if (combo == m_ui->leftClickMaximizeButton ||
combo == m_ui->middleClickMaximizeButton || combo == m_ui->middleClickMaximizeButton ||
combo == m_ui->rightClickMaximizeButton) { combo == m_ui->rightClickMaximizeButton) {
combo->setCurrentIndex(tbl_txt_lookup(tbl_Max, txt)); combo->setCurrentIndex(tbl_txt_lookup(tbl_Max, txt));
} else } else {
abort(); kFatal() << "Something strange happened";
}
} }
const char* KTitleBarActionsConfig::functionTiDbl(int i) const char* KTitleBarActionsConfig::functionTiDbl(int i)
@ -427,18 +429,19 @@ KWindowActionsConfig::~KWindowActionsConfig()
void KWindowActionsConfig::setComboText(KComboBox* combo, const char*txt) void KWindowActionsConfig::setComboText(KComboBox* combo, const char*txt)
{ {
if (combo == m_ui->coWin1 || combo == m_ui->coWin2 || combo == m_ui->coWin3) if (combo == m_ui->coWin1 || combo == m_ui->coWin2 || combo == m_ui->coWin3) {
combo->setCurrentIndex(tbl_txt_lookup(tbl_Win, txt)); combo->setCurrentIndex(tbl_txt_lookup(tbl_Win, txt));
else if (combo == m_ui->coWinWheel) } else if (combo == m_ui->coWinWheel) {
combo->setCurrentIndex(tbl_txt_lookup(tbl_WinWheel, txt)); combo->setCurrentIndex(tbl_txt_lookup(tbl_WinWheel, txt));
else if (combo == m_ui->coAllKey) } else if (combo == m_ui->coAllKey) {
combo->setCurrentIndex(tbl_txt_lookup(tbl_AllKey, txt)); combo->setCurrentIndex(tbl_txt_lookup(tbl_AllKey, txt));
else if (combo == m_ui->coAll1 || combo == m_ui->coAll2 || combo == m_ui->coAll3) } else if (combo == m_ui->coAll1 || combo == m_ui->coAll2 || combo == m_ui->coAll3) {
combo->setCurrentIndex(tbl_txt_lookup(tbl_All, txt)); combo->setCurrentIndex(tbl_txt_lookup(tbl_All, txt));
else if (combo == m_ui->coAllW) } else if (combo == m_ui->coAllW) {
combo->setCurrentIndex(tbl_txt_lookup(tbl_AllW, txt)); combo->setCurrentIndex(tbl_txt_lookup(tbl_AllW, txt));
else } else {
abort(); kFatal() << "Something strange happened";
}
} }
const char* KWindowActionsConfig::functionWin(int i) const char* KWindowActionsConfig::functionWin(int i)

View file

@ -167,7 +167,7 @@ int Monitor::selectedEdgeItem(int edge) const
if (act->isChecked()) if (act->isChecked())
return popup_actions[ edge ].indexOf(act); return popup_actions[ edge ].indexOf(act);
} }
abort(); kFatal() << "Something strange happened";
} }
void Monitor::popup(Corner* c, QPoint pos) void Monitor::popup(Corner* c, QPoint pos)
@ -187,7 +187,7 @@ void Monitor::popup(Corner* c, QPoint pos)
return; return;
} }
} }
abort(); kFatal() << "Something strange happened";
} }
void Monitor::flip(Corner* c, QPoint pos) void Monitor::flip(Corner* c, QPoint pos)
@ -203,7 +203,7 @@ void Monitor::flip(Corner* c, QPoint pos)
return; return;
} }
} }
abort(); kFatal() << "Something strange happened";
} }
Monitor::Corner::Corner(Monitor* m) Monitor::Corner::Corner(Monitor* m)

View file

@ -1223,7 +1223,7 @@ bool PaintClipper::Iterator::isDone()
if (effects->compositingType() == XRenderCompositing) if (effects->compositingType() == XRenderCompositing)
return data->index == 1; // run once return data->index == 1; // run once
#endif #endif
abort(); kFatal() << "Something strange happened";
} }
void PaintClipper::Iterator::next() void PaintClipper::Iterator::next()
@ -1239,7 +1239,7 @@ QRect PaintClipper::Iterator::boundingRect() const
if (effects->compositingType() == XRenderCompositing) if (effects->compositingType() == XRenderCompositing)
return paintArea().boundingRect(); return paintArea().boundingRect();
#endif #endif
abort(); kFatal() << "Something strange happened";
return infiniteRegion(); return infiniteRegion();
} }
@ -1429,8 +1429,11 @@ 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()) if (it == m_managedWindows.end()) {
abort(); // Notify the effect author that they did something wrong // Notify the effect author that they did something wrong
kFatal() << "Something strange happened";
return;
}
WindowMotion *motion = &it.value(); WindowMotion *motion = &it.value();

View file

@ -265,10 +265,6 @@ bool Application::setup()
// initting = false; // TODO // initting = false; // TODO
// This tries to detect compositing options and can use GLX. GLX problems
// (X errors) shouldn't cause kwin to abort, so this is out of the
// critical startup section where x errors cause kwin to abort.
// create workspace. // create workspace.
(void) new Workspace(isSessionRestored()); (void) new Workspace(isSessionRestored());

View file

@ -193,8 +193,9 @@ void UserActionsMenu::helperDialog(const QString& message, const QWeakPointer<Cl
"activated using the %1 keyboard shortcut.", "activated using the %1 keyboard shortcut.",
shortcut); shortcut);
type = "altf3warning"; type = "altf3warning";
} else } else {
abort(); kFatal() << "Something strange happened";
}
if (!type.isEmpty()) { if (!type.isEmpty()) {
KConfig cfg("kwin_dialogsrc"); KConfig cfg("kwin_dialogsrc");
KConfigGroup cg(&cfg, "Notification Messages"); // Depends on KMessageBox KConfigGroup cg(&cfg, "Notification Messages"); // Depends on KMessageBox