[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [akonadi] autotests/server: FakeAkonadiServer: fix FakeConnection deletion
From:       Dan_Vrátil <dvratil () kde ! org>
Date:       2015-12-17 22:26:57
Message-ID: E1a9h0j-0001XV-Aj () scm ! kde ! org
[Download RAW message or body]

Git commit c2523dad2ce0ad79fcb347c0180053e1438409c3 by Dan Vrátil.
Committed on 17/12/2015 at 22:26.
Pushed by dvratil into branch 'master'.

FakeAkonadiServer: fix FakeConnection deletion

Make sure we delete FakeConnection from the main thread, otherwise
the thread will try to wait on itself and the test will crash.

Also fixes a memory leak of mNotificationSpy.

M  +4    -4    autotests/server/fakeakonadiserver.cpp

http://commits.kde.org/akonadi/c2523dad2ce0ad79fcb347c0180053e1438409c3

diff --git a/autotests/server/fakeakonadiserver.cpp b/autotests/server/fakeakonadiserver.cpp
index b2493c9..b3f5375 100644
--- a/autotests/server/fakeakonadiserver.cpp
+++ b/autotests/server/fakeakonadiserver.cpp
@@ -118,6 +118,8 @@ FakeAkonadiServer::FakeAkonadiServer()
 FakeAkonadiServer::~FakeAkonadiServer()
 {
     delete mClient;
+    delete mConnection;
+    delete mNotificationSpy;
 }
 
 QString FakeAkonadiServer::basePath()
@@ -275,13 +277,11 @@ void FakeAkonadiServer::setScenarios(const TestScenario::List &scenarios)
 
 void FakeAkonadiServer::incomingConnection(quintptr socketDescriptor)
 {
-    FakeConnection *connection = new FakeConnection(socketDescriptor);
-    connect(connection, &FakeConnection::disconnected,
-            connection, &QObject::deleteLater);
+    mConnection = new FakeConnection(socketDescriptor);
     NotificationCollector *ntfCollector = Q_NULLPTR;
     // Connection is it's own thread, so we have to make sure we get collector
     // from DataStore of the Connection's thread, not ours
-    QMetaObject::invokeMethod(connection, "notificationCollector", Qt::BlockingQueuedConnection,
+    QMetaObject::invokeMethod(mConnection, "notificationCollector", Qt::BlockingQueuedConnection,
                               Q_RETURN_ARG(Akonadi::Server::NotificationCollector*, ntfCollector));
     Q_ASSERT(ntfCollector);
     mNotificationSpy = new QSignalSpy(ntfCollector,
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic