summaryrefslogtreecommitdiff
path: root/kde-frameworks/knewstuff/files/knewstuff-5.102.0-fix-crash-in-QQuickQuestionListener.patch
blob: 00bafeb28b938d97d563297bd84fcf88c5062355 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From c8e5b36e190f8b71ac14e3afd403debdbe3cf9a8 Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Sun, 29 Jan 2023 13:33:09 +0000
Subject: [PATCH] Fix crash in QQuickQuestionListener

The code path is:
 - we create a Question object
 - we show a prompt
 - we start a nested event loop to get this into a syncronous API
 - we return the result to the question object

The lifespan of the question object is not controlled by the listener,
during the nested event loop anything could have happened including
deletion.

BUG: 464624


(cherry picked from commit e9e0e3faa986757ba096dbe599468f395b3461d3)
---
 src/qtquick/quickquestionlistener.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qtquick/quickquestionlistener.cpp b/src/qtquick/quickquestionlistener.cpp
index 81123b33..f760ef39 100644
--- a/src/qtquick/quickquestionlistener.cpp
+++ b/src/qtquick/quickquestionlistener.cpp
@@ -10,6 +10,7 @@
 #include "core/question.h"
 
 #include <QCoreApplication>
+#include <QPointer>
 
 using namespace KNewStuffQuick;
 
@@ -35,7 +36,7 @@ public:
     Private()
     {
     }
-    KNSCore::Question *question = nullptr;
+    QPointer<KNSCore::Question> question;
 };
 
 QuickQuestionListener *QuickQuestionListener::instance()
@@ -117,6 +118,6 @@ void KNewStuffQuick::QuickQuestionListener::passResponse(bool responseIsContinue
                 break;
             }
         }
-        d->question = nullptr;
+        d->question.clear();
     }
 }
-- 
GitLab