From 9bbcc506d32884f0c3134ac1400dec6b16cffe39 Mon Sep 17 00:00:00 2001 From: Andrey Butirsky Date: Wed, 28 Dec 2022 15:25:38 +0400 Subject: [PATCH] fix ASAN detected stack-use-after-return error Fixes: https://invent.kde.org/plasma/kwin/-/issues/129 --- src/keyboard_input.cpp | 2 +- src/main.h | 2 ++ src/tabbox/tabboxhandler.cpp | 3 --- src/xkb.cpp | 4 ++-- src/xkb.h | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/keyboard_input.cpp b/src/keyboard_input.cpp index 47391aab28..9c69c6a9e3 100644 --- a/src/keyboard_input.cpp +++ b/src/keyboard_input.cpp @@ -41,7 +41,7 @@ namespace KWin KeyboardInputRedirection::KeyboardInputRedirection(InputRedirection *parent) : QObject(parent) , m_input(parent) - , m_xkb(new Xkb(parent)) + , m_xkb(new Xkb(parent, kwinApp()->followLocale1())) { connect(m_xkb.get(), &Xkb::ledsChanged, this, &KeyboardInputRedirection::ledsChanged); if (waylandServer()) { diff --git a/src/main.h b/src/main.h index d93b0df001..1e6489944f 100644 --- a/src/main.h +++ b/src/main.h @@ -380,6 +380,8 @@ private: inline static Application *kwinApp() { + Q_ASSERT(qobject_cast(QCoreApplication::instance())); + return static_cast(QCoreApplication::instance()); } diff --git a/src/tabbox/tabboxhandler.cpp b/src/tabbox/tabboxhandler.cpp index f9f0fe88df..648933577d 100644 --- a/src/tabbox/tabboxhandler.cpp +++ b/src/tabbox/tabboxhandler.cpp @@ -396,9 +396,6 @@ void TabBoxHandler::show() d->show(); } if (d->isHighlightWindows()) { - if (kwinApp()->x11Connection()) { - Xcb::sync(); - } // TODO this should be // QMetaObject::invokeMethod(this, "initHighlightWindows", Qt::QueuedConnection); // but we somehow need to cross > 1 event cycle (likely because of queued invocation in the effects) diff --git a/src/xkb.cpp b/src/xkb.cpp index 2ea5dd9a6e..6cdbbed679 100644 --- a/src/xkb.cpp +++ b/src/xkb.cpp @@ -70,7 +70,7 @@ static void xkbLogHandler(xkb_context *context, xkb_log_level priority, const ch } } -Xkb::Xkb(QObject *parent) +Xkb::Xkb(QObject *parent, bool followLocale1) : QObject(parent) , m_context(xkb_context_new(XKB_CONTEXT_NO_FLAGS)) , m_keymap(nullptr) @@ -88,7 +88,7 @@ Xkb::Xkb(QObject *parent) , m_consumedModifiers(Qt::NoModifier) , m_keysym(XKB_KEY_NoSymbol) , m_leds() - , m_followLocale1(kwinApp()->followLocale1()) + , m_followLocale1(followLocale1) { qRegisterMetaType(); if (!m_context) { diff --git a/src/xkb.h b/src/xkb.h index 91428da8c3..0934e19589 100644 --- a/src/xkb.h +++ b/src/xkb.h @@ -42,7 +42,7 @@ class KWIN_EXPORT Xkb : public QObject { Q_OBJECT public: - Xkb(QObject *parent = nullptr); + Xkb(QObject *parent = nullptr, bool followLocale1 = false); ~Xkb() override; void setConfig(const KSharedConfigPtr &config); void setNumLockConfig(const KSharedConfigPtr &config);