Pass callbacks for requestLog() and requestQrCode() by ref

This commit is contained in:
Martchus 2018-10-18 23:34:29 +02:00
parent 407514289a
commit 8a77cdf516
2 changed files with 7 additions and 7 deletions

View File

@ -946,12 +946,12 @@ void SyncthingConnection::requestEvents()
*
* The specified \a callback is called on success; otherwise error() is emitted.
*/
QMetaObject::Connection SyncthingConnection::requestQrCode(const QString &text, std::function<void(const QByteArray &)> callback)
QMetaObject::Connection SyncthingConnection::requestQrCode(const QString &text, const std::function<void(const QByteArray &)> &callback)
{
QUrlQuery query;
query.addQueryItem(QStringLiteral("text"), text);
QNetworkReply *reply = requestData(QStringLiteral("/qr/"), query, false);
return QObject::connect(reply, &QNetworkReply::finished, [this, reply, callback] {
QNetworkReply *const reply = requestData(QStringLiteral("/qr/"), query, false);
return QObject::connect(reply, &QNetworkReply::finished, [this, reply, &callback] {
reply->deleteLater();
switch (reply->error()) {
case QNetworkReply::NoError:
@ -968,10 +968,10 @@ QMetaObject::Connection SyncthingConnection::requestQrCode(const QString &text,
*
* The specified \a callback is called on success; otherwise error() is emitted.
*/
QMetaObject::Connection SyncthingConnection::requestLog(std::function<void(const std::vector<SyncthingLogEntry> &)> callback)
QMetaObject::Connection SyncthingConnection::requestLog(const std::function<void(const std::vector<SyncthingLogEntry> &)> &callback)
{
QNetworkReply *const reply = requestData(QStringLiteral("system/log"), QUrlQuery());
return QObject::connect(reply, &QNetworkReply::finished, [this, reply, callback] {
return QObject::connect(reply, &QNetworkReply::finished, [this, reply, &callback] {
reply->deleteLater();
switch (reply->error()) {
case QNetworkReply::NoError: {

View File

@ -136,8 +136,8 @@ public:
ChronoUtilities::DateTime startTime() const;
ChronoUtilities::TimeSpan uptime() const;
const QString &syncthingVersion() const;
QMetaObject::Connection requestQrCode(const QString &text, std::function<void(const QByteArray &)> callback);
QMetaObject::Connection requestLog(std::function<void(const std::vector<SyncthingLogEntry> &)> callback);
QMetaObject::Connection requestQrCode(const QString &text, const std::function<void(const QByteArray &)> &callback);
QMetaObject::Connection requestLog(const std::function<void(const std::vector<SyncthingLogEntry> &)> &callback);
const QList<QSslError> &expectedSslErrors() const;
SyncthingDir *findDirInfo(const QString &dirId, int &row);
SyncthingDir *findDirInfo(QLatin1String key, const QJsonObject &object, int *row = nullptr);