NB Broken! New lambda approaches Xcode compilation fixed.

This commit is contained in:
John Preston 2016-09-26 21:17:36 +03:00
parent c91bdf3fef
commit 18f3e45657
4 changed files with 20 additions and 14 deletions

View File

@ -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_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); 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 = new ConfirmBox(text, lang(lng_channels_too_much_public_revoke));
weakRevokeConfirmBox->setConfirmedCallback([this, weak_this = weakThis(), pressed]() { struct Data {
if (!weak_this) return; Data(QPointer<TWidget> &&weakThis, PeerData *pressed) : weakThis(std_::move(weakThis)), pressed(pressed) {
}
QPointer<TWidget> weakThis;
PeerData *pressed;
};
weakRevokeConfirmBox->setConfirmedCallback([this, data = std_::make_unique<Data>(weakThis(), pressed)]() {
if (!data->weakThis) return;
if (_revokeRequestId) 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); Ui::showLayer(weakRevokeConfirmBox, KeepOtherLayers);
} }

View File

@ -34,7 +34,7 @@ public:
void updateLink(); void updateLink();
// You can use this instead of connecting to "confirmed()" signal. // You can use this instead of connecting to "confirmed()" signal.
void setConfirmedCallback(base::lambda_wrap<void()> &&callback) { void setConfirmedCallback(base::lambda_unique<void()> &&callback) {
_confirmedCallback = std_::move(callback); _confirmedCallback = std_::move(callback);
} }

View File

@ -507,20 +507,20 @@ public:
++_eventsCount; ++_eventsCount;
callHandlers(); callHandlers();
} else { } else {
if (!_callHandlers) { if (!this->_callHandlers) {
_callHandlers = [this]() { this->_callHandlers = [this]() {
callHandlers(); callHandlers();
}; };
} }
if (!_eventsCount) { if (!_eventsCount) {
RegisterPendingObservable(&_callHandlers); RegisterPendingObservable(&this->_callHandlers);
} }
++_eventsCount; ++_eventsCount;
} }
} }
~ObservableData() { ~ObservableData() {
UnregisterObservable(&_callHandlers); UnregisterObservable(&this->_callHandlers);
} }
private: private:
@ -528,12 +528,12 @@ private:
_handling = true; _handling = true;
auto eventsCount = createAndSwap(_eventsCount); auto eventsCount = createAndSwap(_eventsCount);
for (int i = 0; i != eventsCount; ++i) { for (int i = 0; i != eventsCount; ++i) {
notifyEnumerate([this]() { this->notifyEnumerate([this]() {
_current->handler(); this->_current->handler();
}); });
} }
_handling = false; _handling = false;
UnregisterActiveObservable(&_callHandlers); UnregisterActiveObservable(&this->_callHandlers);
} }
int _eventsCount = 0; int _eventsCount = 0;
@ -547,8 +547,8 @@ template <typename Handler>
class Observable<void, Handler> : public internal::CommonObservable<void, Handler> { class Observable<void, Handler> : public internal::CommonObservable<void, Handler> {
public: public:
void notify(bool sync = false) { void notify(bool sync = false) {
if (_data) { if (this->_data) {
_data->notify(sync); this->_data->notify(sync);
} }
} }

View File

@ -233,7 +233,7 @@ void CoverWidget::dropEvent(QDropEvent *e) {
if (mimeData->hasImage()) { if (mimeData->hasImage()) {
img = qvariant_cast<QImage>(mimeData->imageData()); img = qvariant_cast<QImage>(mimeData->imageData());
} else { } else {
auto &urls = mimeData->urls(); auto urls = mimeData->urls();
if (urls.size() == 1) { if (urls.size() == 1) {
auto &url = urls.at(0); auto &url = urls.at(0);
if (url.isLocalFile()) { if (url.isLocalFile()) {