Pass context object to properly disconnect when this is deleted

This commit is contained in:
Nicolas Werner 2022-07-23 13:19:24 +02:00
parent 12cae4d0ba
commit d5a6a46bc5
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -921,6 +921,7 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
}); });
connect(mediaPlayer, connect(mediaPlayer,
qOverload<const QString &, const QVariant &>(&QMediaPlayer::metaDataChanged), qOverload<const QString &, const QVariant &>(&QMediaPlayer::metaDataChanged),
this,
[this, mediaPlayer](QString t, QVariant) { [this, mediaPlayer](QString t, QVariant) {
nhlog::ui()->debug("Got metadata {}", t.toStdString()); nhlog::ui()->debug("Got metadata {}", t.toStdString());
@ -937,14 +938,15 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
} }
} }
}); });
connect(mediaPlayer, &QMediaPlayer::durationChanged, [this, mediaPlayer](qint64 duration) { connect(
if (duration > 0) { mediaPlayer, &QMediaPlayer::durationChanged, this, [this, mediaPlayer](qint64 duration) {
this->duration_ = mediaPlayer->duration(); if (duration > 0) {
if (mimeClass_ == u"audio") this->duration_ = mediaPlayer->duration();
mediaPlayer->stop(); if (mimeClass_ == u"audio")
} mediaPlayer->stop();
nhlog::ui()->debug("Duration changed {}", duration); }
}); nhlog::ui()->debug("Duration changed {}", duration);
});
auto originalFile = qobject_cast<QFile *>(source.get()); auto originalFile = qobject_cast<QFile *>(source.get());