From 19d5b17d2e1a763c40c55d38ffb2e413de03d858 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 16 Aug 2023 12:39:41 +0200 Subject: [PATCH] Call file dialog from InvokeQueued. Otherwise for some reason timerEvent-s stop being delivered on the background thread that processes audio data from the voice chat. Fixes #24002. --- .../data/data_file_click_handler.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/data/data_file_click_handler.cpp b/Telegram/SourceFiles/data/data_file_click_handler.cpp index 9fee965f5..ec746f566 100644 --- a/Telegram/SourceFiles/data/data_file_click_handler.cpp +++ b/Telegram/SourceFiles/data/data_file_click_handler.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_download_manager.h" #include "data/data_photo.h" +#include "main/main_session.h" FileClickHandler::FileClickHandler(FullMsgId context) : _context(context) { @@ -79,7 +80,14 @@ void DocumentSaveClickHandler::Save( } auto savename = QString(); - if (mode != Mode::ToCacheOrFile || !data->saveToCache()) { + if (mode == Mode::ToCacheOrFile && data->saveToCache()) { + data->save(origin, savename); + return; + } + InvokeQueued(qApp, crl::guard(&data->session(), [=] { + // If we call file dialog synchronously, it will stop + // background thread timers from working which would + // stop audio playback in voice chats / live streams. if (mode != Mode::ToNewFile && data->saveFromData()) { return; } @@ -92,16 +100,15 @@ void DocumentSaveClickHandler::Save( const auto filename = filepath.isEmpty() ? QString() : fileinfo.fileName(); - savename = DocumentFileNameForSave( + const auto savename = DocumentFileNameForSave( data, (mode == Mode::ToNewFile), filename, filedir); - if (savename.isEmpty()) { - return; + if (!savename.isEmpty()) { + data->save(origin, savename); } - } - data->save(origin, savename); + })); } void DocumentSaveClickHandler::SaveAndTrack(