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 = 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<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;
_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);
}

View File

@ -34,7 +34,7 @@ public:
void updateLink();
// 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);
}

View File

@ -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 <typename Handler>
class Observable<void, Handler> : public internal::CommonObservable<void, Handler> {
public:
void notify(bool sync = false) {
if (_data) {
_data->notify(sync);
if (this->_data) {
this->_data->notify(sync);
}
}

View File

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