Remove this and connection from lambda expression

Clang in Xcode 11 is more aggressive about its warnings. This resolves
one of the issue Clang noticed in order to support building w/Xcode 11.

I first attempted to remove `this` completes, but VS complained that
`QObject::disconnect` was being called without `this`. This change
satisfies both Clang and VS.

A second attempt added this back and then called `disconnect` directly.
This also generated a Clang warning.

This version resolves the issue by removing the error handler. This also
resolves a memory leak caused by the error handler.
This commit is contained in:
Matt Hardcastle 2019-11-05 09:23:36 -08:00
parent 69e586cc54
commit 8dc91d640b

View file

@ -232,12 +232,6 @@ void AvatarBookmarks::loadBookmark(const QString& bookmarkName) {
emit bookmarkLoaded(bookmarkName);
});
std::shared_ptr<QMetaObject::Connection> connection2 = std::make_shared<QMetaObject::Connection>();
*connection2 = connect(myAvatar.get(), &MyAvatar::onLoadFailed, [this, bookmarkName, connection2]() {
qCDebug(interfaceapp) << "Failed to load avatar bookmark" << bookmarkName;
QObject::disconnect(*connection2);
});
qCDebug(interfaceapp) << "Start loading avatar bookmark" << bookmarkName;
const QString& avatarUrl = bookmark.value(ENTRY_AVATAR_URL, "").toString();