@@ -15,6 +15,7 @@ For license and copyright information please follow this link:
1515#include " data/data_download_manager.h"
1616#include " base/battery_saving.h"
1717#include " base/event_filter.h"
18+ #include " base/invoke_queued.h"
1819#include " base/concurrent_timer.h"
1920#include " base/options.h"
2021#include " base/qt_signal_producer.h"
@@ -103,7 +104,6 @@ namespace {
103104constexpr auto kQuitPreventTimeoutMs = crl::time(1500 );
104105constexpr auto kAutoLockTimeoutLateMs = crl::time(3000 );
105106constexpr auto kClearEmojiImageSourceTimeout = 10 * crl::time (1000 );
106- constexpr auto kFileOpenTimeoutMs = crl::time(1000 );
107107
108108LaunchState GlobalLaunchState/* = LaunchState::Running*/ ;
109109
@@ -168,8 +168,7 @@ Application::Application()
168168, _langCloudManager(std::make_unique<Lang::CloudManager>(langpack()))
169169, _emojiKeywords(std::make_unique<ChatHelpers::EmojiKeywords>())
170170, _tray(std::make_unique<Tray>())
171- , _autoLockTimer([=] { checkAutoLock (); })
172- , _fileOpenTimer([=] { checkFileOpen (); }) {
171+ , _autoLockTimer([=] { checkAutoLock (); }) {
173172 Ui::Integration::Set (&_private->uiIntegration );
174173
175174 _platformIntegration->init ();
@@ -693,9 +692,18 @@ bool Application::eventFilter(QObject *object, QEvent *e) {
693692 case QEvent::FileOpen: {
694693 if (object == QCoreApplication::instance ()) {
695694 const auto event = static_cast <QFileOpenEvent*>(e);
695+ const auto flushQueued = [=] {
696+ if (_filesToOpen.isEmpty ()) {
697+ InvokeQueued ([=] {
698+ cSetSendPaths (_filesToOpen);
699+ _filesToOpen.clear ();
700+ checkSendPaths ();
701+ });
702+ }
703+ };
696704 if (const auto file = event->file (); !file.isEmpty ()) {
705+ flushQueued ();
697706 _filesToOpen.append (file);
698- _fileOpenTimer.callOnce (kFileOpenTimeoutMs );
699707 } else if (event->url ().scheme () == u" tg" _q
700708 || event->url ().scheme () == u" tonsite" _q) {
701709 const auto url = QString::fromUtf8 (
@@ -707,8 +715,8 @@ bool Application::eventFilter(QObject *object, QEvent *e) {
707715 _lastActivePrimaryWindow->activate ();
708716 }
709717 } else if (event->url ().scheme () == u" interpret" _q) {
718+ flushQueued ();
710719 _filesToOpen.append (event->url ().toString ());
711- _fileOpenTimer.callOnce (kFileOpenTimeoutMs );
712720 }
713721 }
714722 } break ;
@@ -1081,12 +1089,6 @@ bool Application::canApplyLangPackWithoutRestart() const {
10811089 return true ;
10821090}
10831091
1084- void Application::checkFileOpen () {
1085- cSetSendPaths (_filesToOpen);
1086- _filesToOpen.clear ();
1087- checkSendPaths ();
1088- }
1089-
10901092void Application::checkSendPaths () {
10911093 if (!cSendPaths ().isEmpty ()
10921094 && _lastActivePrimaryWindow
0 commit comments