blob: 1614e0789e4319da0edecd3d8768c5314e17074d (
about) (
plain) (
blame)
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
56
57
58
59
|
From: Weng Xuetian <wengxt@gmail.com>
Date: Thu, 17 Dec 2015 16:19:36 +0000
Subject: Fix possible crash upon application exits (e.g. kmail)
X-Git-Url: http://quickgit.kde.org/?p=kdepimlibs.git&a=commitdiff&h=c6bf33a9018587e96a350bfd0b2bffde1859db27
---
Fix possible crash upon application exits (e.g. kmail)
Qt lambda connection will not automatically disconnect if no context
qobject is provided. Since SessionPrivate is not a qobject, disconnect
the connection in the destructor to prevent accessing deleted object.
REVIEW: 126395
---
--- a/akonadi/src/core/session.cpp
+++ b/akonadi/src/core/session.cpp
@@ -301,15 +301,16 @@
// Shutdown the thread before QApplication event loop quits - the
// thread()->wait() mechanism in ConnectionThread dtor crashes sometimes
// when called from QApplication destructor
- QObject::connect(qApp, &QCoreApplication::aboutToQuit,
- [this]() {
- delete connThread;
- connThread = Q_NULLPTR;
- });
+ connThreadCleanUp = QObject::connect(qApp, &QCoreApplication::aboutToQuit,
+ [this]() {
+ delete connThread;
+ connThread = Q_NULLPTR;
+ });
}
SessionPrivate::~SessionPrivate()
{
+ QObject::disconnect(connThreadCleanUp);
delete connThread;
}
--- a/akonadi/src/core/session_p.h
+++ b/akonadi/src/core/session_p.h
@@ -29,6 +29,7 @@
#include <QtCore/QQueue>
#include <QtCore/QThreadStorage>
+#include <QtCore/QMetaObject>
#include <QFile>
class QIODevice;
@@ -125,6 +126,7 @@
Session *mParent;
QThread *thread;
ConnectionThread *connThread;
+ QMetaObject::Connection connThreadCleanUp;
QByteArray sessionId;
bool connected;
qint64 theNextTag;
|