chatgui: QPointer-защита при генерации превью в фоне

This commit is contained in:
evgeny committed 2026-09-08 01:01:28 +03:00
1 parent 1f538531d1
commit a76f2e1d40
1 file changed
+7 -3
+7 -3
View File
@@ -19,6 +19,7 @@
#include <QFile>
#include <QScrollBar>
#include <QApplication>
#include <QPointer>
#include <QDebug>
#include <QFileInfo>
#include <QFile>
@@ -749,13 +750,16 @@ void MessageList::onAttachmentDownloaded(const QString& chId, int64_t msgId) {
QString fp = item->data(MsgVoiceFileRole).toString();
QString thumbPath = fp + ".jpg";
if (!fp.isEmpty() && QFile::exists(fp) && !QFile::exists(thumbPath)) {
std::thread([this, fp, thumbPath]() {
QPointer<MessageList> self(this);
std::thread([self, fp, thumbPath]() {
int rc = video_extract_thumbnail(fp.toUtf8().constData(),
thumbPath.toUtf8().constData(), 320);
DEBUG_DEBUG(DEBUG_CATEGORY_VIDEO, "MessageList: thumbnail %s rc=%d",
qPrintable(thumbPath), rc);
QMetaObject::invokeMethod(this, [this]() { m_view->viewport()->update(); },
Qt::QueuedConnection);
if (self) {
QMetaObject::invokeMethod(self, [self]() { self->m_view->viewport()->update(); },
Qt::QueuedConnection);
}
}).detach();
}
}