Fix build for OS X 10.6-10.7.

Qt 5.3.2 doesn't support QTimer::singleShot(delay, lambda).
This commit is contained in:
John Preston 2017-04-11 18:44:11 +03:00
parent b736d45bc4
commit d4af14041c
5 changed files with 6 additions and 9 deletions

View File

@ -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);
}
}

View File

@ -147,6 +147,7 @@ private:
QMap<History*, mtpRequestId> _draftsSaveRequestIds;
base::Timer _draftsSaveTimer;
base::Timer _quitSavingDraftsTimer;
OrderedSet<mtpRequestId> _stickerSetDisenableRequests;
Stickers::Order _stickersOrder;

View File

@ -2466,9 +2466,6 @@ namespace {
if (auto apiwrap = api()) {
if (apiwrap->hasUnsavedDrafts()) {
apiwrap->saveDraftsToCloud();
QTimer::singleShot(SaveDraftBeforeQuitTimeout, [] {
QCoreApplication::quit();
});
return;
}
}

View File

@ -333,10 +333,6 @@ TabbedSelector::TabbedSelector(QWidget *parent, gsl::not_null<Window::Controller
connect(gifs(), SIGNAL(selected(InlineBots::Result*, UserData*)), this, SIGNAL(inlineResultSelected(InlineBots::Result*, UserData*)));
connect(gifs(), SIGNAL(cancelled()), this, SIGNAL(cancelled()));
if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
connect(App::wnd()->windowHandle(), SIGNAL(activeChanged()), this, SLOT(onWndActiveChanged()));
}
_topShadow->raise();
_bottomShadow->raise();
_tabsSlider->raise();

View File

@ -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