From 18f3e4565758464858149fcdb76a53989387c61d Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 26 Sep 2016 21:17:36 +0300 Subject: [PATCH] NB Broken! New lambda approaches Xcode compilation fixed. --- Telegram/SourceFiles/boxes/addcontactbox.cpp | 12 +++++++++--- Telegram/SourceFiles/boxes/confirmbox.h | 2 +- Telegram/SourceFiles/core/observer.h | 18 +++++++++--------- .../SourceFiles/settings/settings_cover.cpp | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index 4dc8f29c88..af35aa794f 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -1410,10 +1410,16 @@ void RevokePublicLinkBox::mouseReleaseEvent(QMouseEvent *e) { auto text_method = pressed->isMegagroup() ? lng_channels_too_much_public_revoke_confirm_group : lng_channels_too_much_public_revoke_confirm_channel; auto text = text_method(lt_link, qsl("telegram.me/") + pressed->userName(), lt_group, pressed->name); weakRevokeConfirmBox = new ConfirmBox(text, lang(lng_channels_too_much_public_revoke)); - weakRevokeConfirmBox->setConfirmedCallback([this, weak_this = weakThis(), pressed]() { - if (!weak_this) return; + struct Data { + Data(QPointer &&weakThis, PeerData *pressed) : weakThis(std_::move(weakThis)), pressed(pressed) { + } + QPointer weakThis; + PeerData *pressed; + }; + weakRevokeConfirmBox->setConfirmedCallback([this, data = std_::make_unique(weakThis(), pressed)]() { + if (!data->weakThis) return; if (_revokeRequestId) return; - _revokeRequestId = MTP::send(MTPchannels_UpdateUsername(pressed->asChannel()->inputChannel, MTP_string("")), rpcDone(&RevokePublicLinkBox::revokeLinkDone), rpcFail(&RevokePublicLinkBox::revokeLinkFail)); + _revokeRequestId = MTP::send(MTPchannels_UpdateUsername(data->pressed->asChannel()->inputChannel, MTP_string("")), rpcDone(&RevokePublicLinkBox::revokeLinkDone), rpcFail(&RevokePublicLinkBox::revokeLinkFail)); }); Ui::showLayer(weakRevokeConfirmBox, KeepOtherLayers); } diff --git a/Telegram/SourceFiles/boxes/confirmbox.h b/Telegram/SourceFiles/boxes/confirmbox.h index 2f7ab53bd1..ecd8525d37 100644 --- a/Telegram/SourceFiles/boxes/confirmbox.h +++ b/Telegram/SourceFiles/boxes/confirmbox.h @@ -34,7 +34,7 @@ public: void updateLink(); // You can use this instead of connecting to "confirmed()" signal. - void setConfirmedCallback(base::lambda_wrap &&callback) { + void setConfirmedCallback(base::lambda_unique &&callback) { _confirmedCallback = std_::move(callback); } diff --git a/Telegram/SourceFiles/core/observer.h b/Telegram/SourceFiles/core/observer.h index 3272d94665..91dd28d24b 100644 --- a/Telegram/SourceFiles/core/observer.h +++ b/Telegram/SourceFiles/core/observer.h @@ -507,20 +507,20 @@ public: ++_eventsCount; callHandlers(); } else { - if (!_callHandlers) { - _callHandlers = [this]() { + if (!this->_callHandlers) { + this->_callHandlers = [this]() { callHandlers(); }; } if (!_eventsCount) { - RegisterPendingObservable(&_callHandlers); + RegisterPendingObservable(&this->_callHandlers); } ++_eventsCount; } } ~ObservableData() { - UnregisterObservable(&_callHandlers); + UnregisterObservable(&this->_callHandlers); } private: @@ -528,12 +528,12 @@ private: _handling = true; auto eventsCount = createAndSwap(_eventsCount); for (int i = 0; i != eventsCount; ++i) { - notifyEnumerate([this]() { - _current->handler(); + this->notifyEnumerate([this]() { + this->_current->handler(); }); } _handling = false; - UnregisterActiveObservable(&_callHandlers); + UnregisterActiveObservable(&this->_callHandlers); } int _eventsCount = 0; @@ -547,8 +547,8 @@ template class Observable : public internal::CommonObservable { public: void notify(bool sync = false) { - if (_data) { - _data->notify(sync); + if (this->_data) { + this->_data->notify(sync); } } diff --git a/Telegram/SourceFiles/settings/settings_cover.cpp b/Telegram/SourceFiles/settings/settings_cover.cpp index a6f7f112d4..2f63bd4b4b 100644 --- a/Telegram/SourceFiles/settings/settings_cover.cpp +++ b/Telegram/SourceFiles/settings/settings_cover.cpp @@ -233,7 +233,7 @@ void CoverWidget::dropEvent(QDropEvent *e) { if (mimeData->hasImage()) { img = qvariant_cast(mimeData->imageData()); } else { - auto &urls = mimeData->urls(); + auto urls = mimeData->urls(); if (urls.size() == 1) { auto &url = urls.at(0); if (url.isLocalFile()) {