diff --git a/tools/chatgui/src/messagelist.cpp b/tools/chatgui/src/messagelist.cpp index 18d00093..46506a1a 100644 --- a/tools/chatgui/src/messagelist.cpp +++ b/tools/chatgui/src/messagelist.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -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 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(); } }