From d4af14041cb02027b81cd7e4ff310ba935e0f0e6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 11 Apr 2017 18:44:11 +0300 Subject: [PATCH] Fix build for OS X 10.6-10.7. Qt 5.3.2 doesn't support QTimer::singleShot(delay, lambda). --- Telegram/SourceFiles/apiwrap.cpp | 6 +++++- Telegram/SourceFiles/apiwrap.h | 1 + Telegram/SourceFiles/app.cpp | 3 --- Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp | 4 ---- Telegram/SourceFiles/config.h | 1 - 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 733f369385..c197fe8579 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -38,6 +38,7 @@ namespace { constexpr auto kReloadChannelMembersTimeout = 1000; // 1 second wait before reload members in channel after adding constexpr auto kSaveCloudDraftTimeout = 1000; // save draft to the cloud with 1 sec extra delay +constexpr auto kSaveDraftBeforeQuitTimeout = 1500; // give the app 1.5 secs to save drafts to cloud when quitting constexpr auto kSmallDelayMs = 5; } // namespace @@ -45,7 +46,8 @@ constexpr auto kSmallDelayMs = 5; ApiWrap::ApiWrap() : _messageDataResolveDelayed([this] { resolveMessageDatas(); }) , _webPagesTimer([this] { resolveWebPages(); }) -, _draftsSaveTimer([this] { saveDraftsToCloud(); }) { +, _draftsSaveTimer([this] { saveDraftsToCloud(); }) +, _quitSavingDraftsTimer([] { App::allDraftsSaved(); }) { Window::Theme::Background()->start(); } @@ -1164,6 +1166,8 @@ void ApiWrap::saveDraftsToCloud() { } if (_draftsSaveRequestIds.isEmpty()) { App::allDraftsSaved(); // can quit the application + } else if (App::quitting() && !_quitSavingDraftsTimer.isActive()) { + _quitSavingDraftsTimer.callOnce(kSaveDraftBeforeQuitTimeout); } } diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 1133f472c6..355d9abfdf 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -147,6 +147,7 @@ private: QMap _draftsSaveRequestIds; base::Timer _draftsSaveTimer; + base::Timer _quitSavingDraftsTimer; OrderedSet _stickerSetDisenableRequests; Stickers::Order _stickersOrder; diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 6cd2f4e03c..c5053c32c2 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -2466,9 +2466,6 @@ namespace { if (auto apiwrap = api()) { if (apiwrap->hasUnsavedDrafts()) { apiwrap->saveDraftsToCloud(); - QTimer::singleShot(SaveDraftBeforeQuitTimeout, [] { - QCoreApplication::quit(); - }); return; } } diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index 822e4b3545..05a81ba5a2 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -333,10 +333,6 @@ TabbedSelector::TabbedSelector(QWidget *parent, gsl::not_nullwindowHandle(), SIGNAL(activeChanged()), this, SLOT(onWndActiveChanged())); - } - _topShadow->raise(); _bottomShadow->raise(); _tabsSlider->raise(); diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index 82483eca73..2dc9d2a64b 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -124,7 +124,6 @@ enum { SaveDraftTimeout = 1000, // save draft after 1 secs of not changing text SaveDraftAnywayTimeout = 5000, // or save anyway each 5 secs SaveCloudDraftIdleTimeout = 14000, // save draft to the cloud after 14 more seconds - SaveDraftBeforeQuitTimeout = 1500, // give the app 1.5 secs to save drafts to cloud when quitting SetOnlineAfterActivity = 30, // user with hidden last seen stays online for such amount of seconds in the interface