Update libqmatrixclient && fix image provider crashes.

This commit is contained in:
Black Hat 2019-03-02 15:33:37 +08:00
parent b5644cb07c
commit 6eb7f21090
3 changed files with 12 additions and 11 deletions

View File

@ -14,7 +14,7 @@ Item {
id: image id: image
visible: realSource visible: realSource
source: realSource source: width < 1 ? "" : realSource
sourceSize.width: width sourceSize.width: width
sourceSize.height: width sourceSize.height: width
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop

@ -1 +1 @@
Subproject commit 23bf0e83aec1adaf81d9c50ce2385a98c20e3c93 Subproject commit b467b0816f5f6816778f90b55a9d0b5437310fd5

View File

@ -6,10 +6,10 @@
using QMatrixClient::BaseJob; using QMatrixClient::BaseJob;
ThumbnailResponse::ThumbnailResponse(QMatrixClient::Connection* c, ThumbnailResponse::ThumbnailResponse(QMatrixClient::Connection* c,
QString mediaId, const QSize& requestedSize) QString id, const QSize& size)
: c(c), : c(c),
mediaId(std::move(mediaId)), mediaId(std::move(id)),
requestedSize(requestedSize), requestedSize(size),
errorStr("Image request hasn't started") { errorStr("Image request hasn't started") {
if (requestedSize.isEmpty()) { if (requestedSize.isEmpty()) {
errorStr.clear(); errorStr.clear();
@ -40,7 +40,7 @@ void ThumbnailResponse::startRequest() {
void ThumbnailResponse::prepareResult() { void ThumbnailResponse::prepareResult() {
Q_ASSERT(QThread::currentThread() == job->thread()); Q_ASSERT(QThread::currentThread() == job->thread());
Q_ASSERT(job->error() != BaseJob::Pending); Q_ASSERT(job->error() != BaseJob::Pending);
{ {
QWriteLocker _(&lock); QWriteLocker _(&lock);
if (job->error() == BaseJob::Success) { if (job->error() == BaseJob::Success) {
@ -48,7 +48,7 @@ void ThumbnailResponse::prepareResult() {
errorStr.clear(); errorStr.clear();
} else if (job->error() == BaseJob::Abandoned) { } else if (job->error() == BaseJob::Abandoned) {
errorStr = tr("Image request has been cancelled"); errorStr = tr("Image request has been cancelled");
qDebug() << "ThumbnailResponse: cancelled for" << mediaId; qDebug() << "ThumbnailResponse: cancelled for" << mediaId;
} else { } else {
errorStr = job->errorString(); errorStr = job->errorString();
qWarning() << "ThumbnailResponse: no valid image for" << mediaId << "-" qWarning() << "ThumbnailResponse: no valid image for" << mediaId << "-"
@ -61,9 +61,10 @@ void ThumbnailResponse::prepareResult() {
void ThumbnailResponse::doCancel() { void ThumbnailResponse::doCancel() {
// Runs in the main thread, not QML thread // Runs in the main thread, not QML thread
Q_ASSERT(QThread::currentThread() == job->thread()); if (job) {
if (job) Q_ASSERT(QThread::currentThread() == job->thread());
job->abandon(); job->abandon();
}
} }
QQuickTextureFactory* ThumbnailResponse::textureFactory() const { QQuickTextureFactory* ThumbnailResponse::textureFactory() const {
@ -83,6 +84,6 @@ void ThumbnailResponse::cancel() {
QQuickImageResponse* ImageProvider::requestImageResponse( QQuickImageResponse* ImageProvider::requestImageResponse(
const QString& id, const QSize& requestedSize) { const QString& id, const QSize& requestedSize) {
qDebug() << "ImageProvider: requesting " << id; qDebug() << "ImageProvider: requesting " << id << "of size" << requestedSize;
return new ThumbnailResponse(m_connection.load(), id, requestedSize); return new ThumbnailResponse(m_connection.load(), id, requestedSize);
} }