Gentoo Archives: gentoo-commits

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: kde-plasma/khotkeys/, kde-plasma/khotkeys/files/
Date: Tue, 23 Nov 2021 14:59:41
Message-Id: 1637679552.df89d8fb9749a7eedcb07c39c964d6a3c42af74a.asturm@gentoo
1 commit: df89d8fb9749a7eedcb07c39c964d6a3c42af74a
2 Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
3 AuthorDate: Tue Nov 23 10:22:29 2021 +0000
4 Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 23 14:59:12 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=df89d8fb
7
8 kde-plasma/khotkeys: Fix systemsettings crash in hotkeys handling
9
10 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=443656
11 Upstream commit a4137ac8f7b18824568fbee0f3e2dce7551841b7
12
13 Package-Manager: Portage-3.0.28, Repoman-3.0.3
14 Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>
15
16 .../khotkeys-5.23.3-delete-widgets-w-entry.patch | 118 +++++++++++++++++++++
17 kde-plasma/khotkeys/khotkeys-5.23.3-r1.ebuild | 52 +++++++++
18 2 files changed, 170 insertions(+)
19
20 diff --git a/kde-plasma/khotkeys/files/khotkeys-5.23.3-delete-widgets-w-entry.patch b/kde-plasma/khotkeys/files/khotkeys-5.23.3-delete-widgets-w-entry.patch
21 new file mode 100644
22 index 000000000000..9e8ae22f2d53
23 --- /dev/null
24 +++ b/kde-plasma/khotkeys/files/khotkeys-5.23.3-delete-widgets-w-entry.patch
25 @@ -0,0 +1,118 @@
26 +From a4137ac8f7b18824568fbee0f3e2dce7551841b7 Mon Sep 17 00:00:00 2001
27 +From: Harald Sitter <sitter@×××.org>
28 +Date: Wed, 13 Oct 2021 13:52:15 +0200
29 +Subject: [PATCH] when deleting an entry, also delete the widgets
30 +
31 +previously what would happen is that KCMHotkeys::currentChanged would
32 +run, find the new index (-1,-1) now invalid and show the global settings
33 +instead. this however left the simple_action's underlying widgets still
34 +sitting around referring to the previous index AND holding a dangling
35 +trigger point that would eventually crash when the simple_action would
36 +be poked by anything
37 +
38 +instead force unset the internal state of the simple_action when showing
39 +the global settings.
40 +
41 +FIXED-IN: 5.23.5
42 +BUG: 443656
43 +
44 +
45 +(cherry picked from commit 97f9339fd96d97e012347f8f7fca987bbe4fca0d)
46 +---
47 + kcm_hotkeys/kcm_hotkeys.cpp | 3 +++
48 + kcm_hotkeys/simple_action_data_widget.cpp | 18 +++++++++++-------
49 + kcm_hotkeys/simple_action_data_widget.h | 3 +++
50 + kcm_hotkeys/triggers/trigger_widget_base.cpp | 8 ++++++++
51 + 4 files changed, 25 insertions(+), 7 deletions(-)
52 +
53 +diff --git a/kcm_hotkeys/kcm_hotkeys.cpp b/kcm_hotkeys/kcm_hotkeys.cpp
54 +index d3ed315..4dc4664 100644
55 +--- a/kcm_hotkeys/kcm_hotkeys.cpp
56 ++++ b/kcm_hotkeys/kcm_hotkeys.cpp
57 +@@ -120,6 +120,9 @@ void KCMHotkeys::currentChanged(const QModelIndex &pCurrent, const QModelIndex &
58 + }
59 +
60 + if (!current.isValid()) {
61 ++ if (previous.isValid()) { // throw away old widget and stuff lest we have dangling pointers https://bugs.kde.org/show_bug.cgi?id=443656
62 ++ d->simple_action->unsetActionData();
63 ++ }
64 + return showGlobalSettings();
65 + }
66 +
67 +diff --git a/kcm_hotkeys/simple_action_data_widget.cpp b/kcm_hotkeys/simple_action_data_widget.cpp
68 +index e20ccaa..eb8c4c1 100644
69 +--- a/kcm_hotkeys/simple_action_data_widget.cpp
70 ++++ b/kcm_hotkeys/simple_action_data_widget.cpp
71 +@@ -60,14 +60,22 @@ void SimpleActionDataWidget::doCopyToObject()
72 + }
73 + }
74 +
75 +-void SimpleActionDataWidget::setActionData(KHotKeys::SimpleActionData *pData)
76 ++void SimpleActionDataWidget::unsetActionData()
77 + {
78 +- _data = pData;
79 ++ _data = nullptr;
80 +
81 +- // Now go and work on the trigger
82 + delete currentTrigger;
83 + currentTrigger = nullptr;
84 +
85 ++ delete currentAction;
86 ++ currentAction = nullptr;
87 ++}
88 ++
89 ++void SimpleActionDataWidget::setActionData(KHotKeys::SimpleActionData *pData)
90 ++{
91 ++ unsetActionData();
92 ++ _data = pData;
93 ++
94 + if (KHotKeys::Trigger *trg = data()->trigger()) {
95 + switch (trg->type()) {
96 + case KHotKeys::Trigger::ShortcutTriggerType:
97 +@@ -95,10 +103,6 @@ void SimpleActionDataWidget::setActionData(KHotKeys::SimpleActionData *pData)
98 + extend(currentTrigger, i18n("Trigger"));
99 + }
100 +
101 +- // Now go and work on the action
102 +- delete currentAction;
103 +- currentAction = nullptr;
104 +-
105 + if (KHotKeys::Action *act = data()->action()) {
106 + switch (act->type()) {
107 + case KHotKeys::Action::MenuEntryActionType:
108 +diff --git a/kcm_hotkeys/simple_action_data_widget.h b/kcm_hotkeys/simple_action_data_widget.h
109 +index bc203b1..7c347c5 100644
110 +--- a/kcm_hotkeys/simple_action_data_widget.h
111 ++++ b/kcm_hotkeys/simple_action_data_widget.h
112 +@@ -32,6 +32,9 @@ public:
113 + */
114 + void setActionData(KHotKeys::SimpleActionData *action);
115 +
116 ++ /// Throws away the held widgets and state.
117 ++ void unsetActionData();
118 ++
119 + KHotKeys::SimpleActionData *data()
120 + {
121 + return static_cast<KHotKeys::SimpleActionData *>(_data);
122 +diff --git a/kcm_hotkeys/triggers/trigger_widget_base.cpp b/kcm_hotkeys/triggers/trigger_widget_base.cpp
123 +index 67f4f3e..3bfa39b 100644
124 +--- a/kcm_hotkeys/triggers/trigger_widget_base.cpp
125 ++++ b/kcm_hotkeys/triggers/trigger_widget_base.cpp
126 +@@ -10,6 +10,14 @@ TriggerWidgetBase::TriggerWidgetBase(KHotKeys::Trigger *trigger, QWidget *parent
127 + : HotkeysWidgetIFace(parent)
128 + , _trigger(trigger)
129 + {
130 ++ // Safety net to catch use-after-free. The triggers are not held or managed by us nor our parent.
131 ++ // Makes them easier to spot, unlike https://bugs.kde.org/show_bug.cgi?id=443656
132 ++ auto qObject = dynamic_cast<QObject *>(trigger);
133 ++ if (qObject) {
134 ++ connect(qObject, &QObject::destroyed, this, [this] {
135 ++ _trigger = nullptr;
136 ++ });
137 ++ }
138 + }
139 +
140 + TriggerWidgetBase::~TriggerWidgetBase()
141 +--
142 +GitLab
143 +
144
145 diff --git a/kde-plasma/khotkeys/khotkeys-5.23.3-r1.ebuild b/kde-plasma/khotkeys/khotkeys-5.23.3-r1.ebuild
146 new file mode 100644
147 index 000000000000..19b406f848a4
148 --- /dev/null
149 +++ b/kde-plasma/khotkeys/khotkeys-5.23.3-r1.ebuild
150 @@ -0,0 +1,52 @@
151 +# Copyright 1999-2021 Gentoo Authors
152 +# Distributed under the terms of the GNU General Public License v2
153 +
154 +EAPI=8
155 +
156 +ECM_HANDBOOK="forceoptional" # not optional until !kdelibs4support
157 +KFMIN=5.86.0
158 +PVCUT=$(ver_cut 1-3)
159 +QTMIN=5.15.2
160 +inherit ecm kde.org
161 +
162 +DESCRIPTION="KDE Plasma workspace hotkey module"
163 +
164 +LICENSE="GPL-2" # TODO: CHECK
165 +SLOT="5"
166 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
167 +IUSE=""
168 +
169 +COMMON_DEPEND="
170 + >=dev-qt/qtdbus-${QTMIN}:5
171 + >=dev-qt/qtgui-${QTMIN}:5
172 + >=dev-qt/qtwidgets-${QTMIN}:5
173 + >=dev-qt/qtx11extras-${QTMIN}:5
174 + >=kde-frameworks/kcompletion-${KFMIN}:5
175 + >=kde-frameworks/kconfig-${KFMIN}:5
176 + >=kde-frameworks/kconfigwidgets-${KFMIN}:5
177 + >=kde-frameworks/kcoreaddons-${KFMIN}:5
178 + >=kde-frameworks/kdbusaddons-${KFMIN}:5
179 + >=kde-frameworks/kdelibs4support-${KFMIN}:5[X]
180 + >=kde-frameworks/kglobalaccel-${KFMIN}:5
181 + >=kde-frameworks/ki18n-${KFMIN}:5
182 + >=kde-frameworks/kio-${KFMIN}:5
183 + >=kde-frameworks/kservice-${KFMIN}:5
184 + >=kde-frameworks/ktextwidgets-${KFMIN}:5
185 + >=kde-frameworks/kwidgetsaddons-${KFMIN}:5
186 + >=kde-frameworks/kwindowsystem-${KFMIN}:5
187 + >=kde-frameworks/kxmlgui-${KFMIN}:5
188 + >=kde-plasma/libkworkspace-${PVCUT}:5
189 + x11-libs/libX11
190 + x11-libs/libXtst
191 +"
192 +DEPEND="${COMMON_DEPEND}
193 + x11-base/xorg-proto
194 + x11-libs/libxcb
195 + x11-libs/libXtst
196 +"
197 +RDEPEND="${COMMON_DEPEND}
198 + >=kde-frameworks/kded-${KFMIN}:5
199 + >=kde-plasma/kde-cli-tools-${PVCUT}:5
200 +"
201 +
202 +PATCHES=( "${FILESDIR}"/${P}-delete-widgets-w-entry.patch ) # KDE-bug 443656