From 5f6ac71684056aaae13335a6b867d43c8cdb1692 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 25 Apr 2018 07:50:02 +0900 Subject: Avatar: don't allow null callbacks to be registered --- lib/avatar.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/avatar.cpp b/lib/avatar.cpp index a40b0ed6..7e6dc50b 100644 --- a/lib/avatar.cpp +++ b/lib/avatar.cpp @@ -106,6 +106,11 @@ QString Avatar::mediaId() const QImage Avatar::Private::get(Connection* connection, QSize size, get_callback_t callback) const { + if (!callback) + { + qCCritical(MAIN) << "Null callbacks are not allowed in Avatar::get"; + Q_ASSERT(false); + } // FIXME: Alternating between longer-width and longer-height requests // is a sure way to trick the below code into constantly getting another // image from the server because the existing one is alleged unsatisfactory. @@ -118,7 +123,8 @@ QImage Avatar::Private::get(Connection* connection, QSize size, _requestedSize = size; if (isJobRunning(_thumbnailRequest)) _thumbnailRequest->abandon(); - callbacks.emplace_back(move(callback)); + if (callback) + callbacks.emplace_back(move(callback)); _thumbnailRequest = connection->getThumbnail(_url, size); QObject::connect( _thumbnailRequest, &MediaThumbnailJob::success, _thumbnailRequest, [this] { -- cgit v1.2.3