Browse Source

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

v2
evgeny 3 weeks ago
parent
commit
76182d018f
  1. 10
      tools/chatgui/src/messagelist.cpp

10
tools/chatgui/src/messagelist.cpp

@ -19,6 +19,7 @@
#include <QFile> #include <QFile>
#include <QScrollBar> #include <QScrollBar>
#include <QApplication> #include <QApplication>
#include <QPointer>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QFile> #include <QFile>
@ -749,13 +750,16 @@ void MessageList::onAttachmentDownloaded(const QString& chId, int64_t msgId) {
QString fp = item->data(MsgVoiceFileRole).toString(); QString fp = item->data(MsgVoiceFileRole).toString();
QString thumbPath = fp + ".jpg"; QString thumbPath = fp + ".jpg";
if (!fp.isEmpty() && QFile::exists(fp) && !QFile::exists(thumbPath)) { 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(), int rc = video_extract_thumbnail(fp.toUtf8().constData(),
thumbPath.toUtf8().constData(), 320); thumbPath.toUtf8().constData(), 320);
DEBUG_DEBUG(DEBUG_CATEGORY_VIDEO, "MessageList: thumbnail %s rc=%d", DEBUG_DEBUG(DEBUG_CATEGORY_VIDEO, "MessageList: thumbnail %s rc=%d",
qPrintable(thumbPath), rc); qPrintable(thumbPath), rc);
QMetaObject::invokeMethod(this, [this]() { m_view->viewport()->update(); }, if (self) {
Qt::QueuedConnection); QMetaObject::invokeMethod(self, [self]() { self->m_view->viewport()->update(); },
Qt::QueuedConnection);
}
}).detach(); }).detach();
} }
} }

Loading…
Cancel
Save