aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-12-25 19:03:10 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-12-25 19:03:10 +0900
commit155da0f2bdd831f59defd784e98fa9d4e7cea97e (patch)
treeb8dcdd8c74099fd1b1f612fba04430858576f897
parentb1014408917dd900f029924802433321f1eb5ac4 (diff)
downloadlibquotient-155da0f2bdd831f59defd784e98fa9d4e7cea97e.tar.gz
libquotient-155da0f2bdd831f59defd784e98fa9d4e7cea97e.zip
Connection: Be more accurate with lambda captures
-rw-r--r--connection.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/connection.cpp b/connection.cpp
index b6239762..3083eeba 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -125,7 +125,7 @@ void Connection::resolveServer(const QString& mxidOrDomain)
dns->setType(QDnsLookup::SRV);
dns->setName("_matrix._tcp." + domain);
- connect(dns, &QDnsLookup::finished, [this,dns,maybeBaseUrl]() {
+ connect(dns, &QDnsLookup::finished, [this,dns,&maybeBaseUrl]() {
QUrl baseUrl { maybeBaseUrl };
if (dns->error() == QDnsLookup::NoError &&
dns->serviceRecords().isEmpty())
@@ -151,7 +151,7 @@ void Connection::connectToServer(const QString& user, const QString& password,
const QString& deviceId)
{
checkAndConnect(user,
- [=] {
+ [&] {
doConnectToServer(user, password, initialDeviceName, deviceId);
});
}
@@ -163,12 +163,12 @@ void Connection::doConnectToServer(const QString& user, const QString& password,
user, /*medium*/ "", /*address*/ "", password, /*token*/ "",
deviceId, initialDeviceName);
connect(loginJob, &BaseJob::success, this,
- [=] {
+ [this, loginJob] {
d->connectWithToken(loginJob->userId(), loginJob->accessToken(),
loginJob->deviceId());
});
connect(loginJob, &BaseJob::failure, this,
- [=] {
+ [this, loginJob] {
emit loginError(loginJob->errorString());
});
}
@@ -178,7 +178,7 @@ void Connection::connectWithToken(const QString& userId,
const QString& deviceId)
{
checkAndConnect(userId,
- [=] { d->connectWithToken(userId, accessToken, deviceId); });
+ [&] { d->connectWithToken(userId, accessToken, deviceId); });
}
void Connection::Private::connectWithToken(const QString& user,
@@ -223,7 +223,7 @@ void Connection::checkAndConnect(const QString& userId,
void Connection::logout()
{
auto job = callApi<LogoutJob>();
- connect( job, &LogoutJob::success, this, [=] {
+ connect( job, &LogoutJob::success, this, [this] {
stopSync();
emit loggedOut();
});
@@ -238,13 +238,13 @@ void Connection::sync(int timeout)
const QString filter { R"({"room": { "timeline": { "limit": 100 } } })" };
auto job = d->syncJob =
callApi<SyncJob>(d->data->lastEvent(), filter, timeout);
- connect( job, &SyncJob::success, [=] () {
+ connect( job, &SyncJob::success, [this, job] {
onSyncSuccess(job->takeData());
d->syncJob = nullptr;
emit syncDone();
});
connect( job, &SyncJob::retryScheduled, this, &Connection::networkError);
- connect( job, &SyncJob::failure, [=] () {
+ connect( job, &SyncJob::failure, [this, job] {
d->syncJob = nullptr;
if (job->error() == BaseJob::ContentAccessError)
emit loginError(job->errorString());
@@ -286,7 +286,7 @@ JoinRoomJob* Connection::joinRoom(const QString& roomAlias)
{
auto job = callApi<JoinRoomJob>(roomAlias);
connect(job, &JoinRoomJob::success,
- this, [=] { provideRoom(job->roomId(), JoinState::Join); });
+ this, [this, job] { provideRoom(job->roomId(), JoinState::Join); });
return job;
}
@@ -326,13 +326,12 @@ ForgetRoomJob* Connection::forgetRoom(const QString& id)
{
auto leaveJob = joinedRoom->leaveRoom();
connect(leaveJob, &BaseJob::success,
- this, [=] { forgetJob->start(connectionData()); });
- connect(leaveJob, &BaseJob::failure,
- this, [=] { forgetJob->abandon(); });
+ this, [this, forgetJob] { forgetJob->start(connectionData()); });
+ connect(leaveJob, &BaseJob::failure, forgetJob, &BaseJob::abandon);
}
else
forgetJob->start(connectionData());
- connect(forgetJob, &BaseJob::success, this, [=]
+ connect(forgetJob, &BaseJob::success, this, [this, &id]
{
// If the room happens to be in the map (possible in both forms),
// delete the found object(s).