mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-22 02:07:24 +00:00
Use base::weak_qptr / base::make_weak.
This commit is contained in:
parent
321c7120df
commit
b754ad5248
@ -245,7 +245,7 @@ void SendBotCallbackDataWithPassword(
|
||||
fields.customSubmitButton = tr::lng_passcode_submit();
|
||||
fields.customCheckCallback = [=](
|
||||
const Core::CloudPasswordResult &result,
|
||||
QPointer<PasscodeBox> box) {
|
||||
base::weak_qptr<PasscodeBox> box) {
|
||||
if (const auto button = getButton()) {
|
||||
if (button->requestId) {
|
||||
return;
|
||||
|
@ -57,7 +57,7 @@ void RemoveChatFilter(
|
||||
RemoveComplexChatFilter::RemoveComplexChatFilter() = default;
|
||||
|
||||
void RemoveComplexChatFilter::request(
|
||||
QPointer<Ui::RpWidget> widget,
|
||||
base::weak_qptr<Ui::RpWidget> widget,
|
||||
base::weak_ptr<Window::SessionController> weak,
|
||||
FilterId id) {
|
||||
const auto session = &weak->session();
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
RemoveComplexChatFilter();
|
||||
|
||||
void request(
|
||||
QPointer<Ui::RpWidget> widget,
|
||||
base::weak_qptr<Ui::RpWidget> widget,
|
||||
base::weak_ptr<Window::SessionController> weak,
|
||||
FilterId id);
|
||||
|
||||
|
@ -272,7 +272,7 @@ void ConfirmSubscriptionBox(
|
||||
}, balance->lifetime());
|
||||
}
|
||||
|
||||
const auto sendCredits = [=, weak = Ui::MakeWeak(box)] {
|
||||
const auto sendCredits = [=, weak = base::make_weak(box)] {
|
||||
const auto show = box->uiShow();
|
||||
const auto buttonWidth = state->saveButton
|
||||
? state->saveButton->width()
|
||||
@ -280,7 +280,7 @@ void ConfirmSubscriptionBox(
|
||||
const auto finish = [=] {
|
||||
state->api = std::nullopt;
|
||||
state->loading.force_assign(false);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -294,7 +294,7 @@ void ConfirmSubscriptionBox(
|
||||
}, [](const MTPDpayments_paymentVerificationNeeded &data) {
|
||||
});
|
||||
const auto refill = session->data().activeCreditsSubsRebuilder();
|
||||
const auto strong = weak.data();
|
||||
const auto strong = weak.get();
|
||||
if (!strong) {
|
||||
return;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void ConfirmPhone::resolve(
|
||||
sentCodeLength,
|
||||
fragmentUrl,
|
||||
timeout);
|
||||
const auto boxWeak = Ui::MakeWeak(box.data());
|
||||
const auto boxWeak = base::make_weak(box.data());
|
||||
using LoginCode = rpl::event_stream<QString>;
|
||||
const auto codeHandles = box->lifetime().make_state<LoginCode>();
|
||||
controller->session().account().setHandleLoginCode([=](
|
||||
|
@ -82,7 +82,7 @@ void HandleWithdrawalButton(
|
||||
fields.customSubmitButton = tr::lng_passcode_submit();
|
||||
fields.customCheckCallback = crl::guard(button, [=](
|
||||
const Core::CloudPasswordResult &result,
|
||||
QPointer<PasscodeBox> box) {
|
||||
base::weak_qptr<PasscodeBox> box) {
|
||||
const auto done = [=](const QString &result) {
|
||||
if (!result.isEmpty()) {
|
||||
UrlClickHandler::Open(result);
|
||||
|
@ -223,7 +223,7 @@ void ConfirmApproval(
|
||||
.confirmText = tr::lng_suggest_accept_send(),
|
||||
.title = tr::lng_suggest_accept_title(),
|
||||
});
|
||||
*callback = [=, weak = Ui::MakeWeak(box)] {
|
||||
*callback = [=, weak = base::make_weak(box)] {
|
||||
if (const auto onstack = accepted) {
|
||||
onstack();
|
||||
}
|
||||
@ -232,7 +232,7 @@ void ConfirmApproval(
|
||||
return;
|
||||
}
|
||||
SendApproval(show, item, scheduleDate);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -283,9 +283,9 @@ void RequestApprovalDate(
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
not_null<HistoryItem*> item) {
|
||||
const auto id = item->fullId();
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto close = [=] {
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -339,13 +339,13 @@ void RequestDeclineComment(
|
||||
box->setFocusCallback([=] {
|
||||
reason->setFocusFast();
|
||||
});
|
||||
*callback = [=, weak = Ui::MakeWeak(box)] {
|
||||
*callback = [=, weak = base::make_weak(box)] {
|
||||
const auto item = show->session().data().message(id);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
SendDecline(show, item, reason->getLastText().trimmed());
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -422,14 +422,14 @@ void SuggestApprovalDate(
|
||||
}
|
||||
const auto id = item->fullId();
|
||||
const auto state = std::make_shared<SendSuggestState>();
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto done = [=](TimeId result) {
|
||||
const auto item = show->session().data().message(id);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
const auto close = [=] {
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -458,14 +458,14 @@ void SuggestOfferForMessage(
|
||||
HistoryView::SuggestMode mode) {
|
||||
const auto id = item->fullId();
|
||||
const auto state = std::make_shared<SendSuggestState>();
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto done = [=](SuggestPostOptions result) {
|
||||
const auto item = show->session().data().message(id);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
const auto close = [=] {
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
|
@ -240,13 +240,13 @@ struct State {
|
||||
[[nodiscard]] rpl::producer<Peers> WhoReadIds(
|
||||
not_null<HistoryItem*> item,
|
||||
not_null<QWidget*> context) {
|
||||
auto weak = QPointer<QWidget>(context.get());
|
||||
auto weak = base::make_weak(context);
|
||||
const auto session = &item->history()->session();
|
||||
return [=](auto consumer) {
|
||||
if (!weak) {
|
||||
return rpl::lifetime();
|
||||
}
|
||||
const auto context = PreparedContextAt(weak.data(), session);
|
||||
const auto context = PreparedContextAt(weak.get(), session);
|
||||
auto &entry = context->cacheRead(item);
|
||||
if (entry.requestId) {
|
||||
} else if (const auto user = item->history()->peer->asUser()) {
|
||||
@ -325,13 +325,13 @@ struct State {
|
||||
not_null<HistoryItem*> item,
|
||||
const ReactionId &reaction,
|
||||
not_null<QWidget*> context) {
|
||||
auto weak = QPointer<QWidget>(context.get());
|
||||
auto weak = base::make_weak(context);
|
||||
const auto session = &item->history()->session();
|
||||
return [=](auto consumer) {
|
||||
if (!weak) {
|
||||
return rpl::lifetime();
|
||||
}
|
||||
const auto context = PreparedContextAt(weak.data(), session);
|
||||
const auto context = PreparedContextAt(weak.get(), session);
|
||||
auto &entry = context->cacheReacted(item, reaction);
|
||||
if (!entry.requestId) {
|
||||
using Flag = MTPmessages_GetMessageReactionsList::Flag;
|
||||
|
@ -37,11 +37,11 @@ void showBox(
|
||||
} // namespace internal
|
||||
|
||||
template <typename BoxType>
|
||||
QPointer<BoxType> show(
|
||||
base::weak_qptr<BoxType> show(
|
||||
object_ptr<BoxType> content,
|
||||
Ui::LayerOptions options = Ui::LayerOption::CloseOther,
|
||||
anim::type animated = anim::type::normal) {
|
||||
auto result = QPointer<BoxType>(content.data());
|
||||
auto result = base::weak_qptr<BoxType>(content.data());
|
||||
internal::showBox(std::move(content), options, animated);
|
||||
return result;
|
||||
}
|
||||
|
@ -194,16 +194,16 @@ void ShowAddParticipantsError(
|
||||
&& channel->canAddAdmins()) {
|
||||
const auto makeAdmin = [=](Fn<void()> close) {
|
||||
const auto user = forbidden.users.front();
|
||||
const auto weak = std::make_shared<QPointer<EditAdminBox>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<EditAdminBox>>();
|
||||
const auto done = [=](auto&&...) {
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->uiShow()->showToast(
|
||||
tr::lng_box_done(tr::now));
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
const auto fail = [=] {
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -446,7 +446,7 @@ void AddContactBox::save() {
|
||||
firstName = lastName;
|
||||
lastName = QString();
|
||||
}
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto session = _session;
|
||||
_sentName = firstName;
|
||||
_contactId = base::RandomValue<uint64>();
|
||||
@ -716,7 +716,7 @@ TimeId GroupInfoBox::ttlPeriod() const {
|
||||
}
|
||||
|
||||
void GroupInfoBox::createGroup(
|
||||
QPointer<Ui::BoxContent> selectUsersBox,
|
||||
base::weak_qptr<Ui::BoxContent> selectUsersBox,
|
||||
const QString &title,
|
||||
const std::vector<not_null<PeerData*>> &users) {
|
||||
if (_creationRequestId) {
|
||||
@ -750,8 +750,8 @@ void GroupInfoBox::createGroup(
|
||||
_creationRequestId = 0;
|
||||
const auto controller = _navigation->parentController();
|
||||
if (type == u"NO_CHAT_TITLE"_q) {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
if (const auto strong = selectUsersBox.data()) {
|
||||
const auto weak = base::make_weak(this);
|
||||
if (const auto strong = selectUsersBox.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
if (weak) {
|
||||
@ -792,10 +792,10 @@ void GroupInfoBox::submit() {
|
||||
} else if (_canAddBot) {
|
||||
createGroup(nullptr, title, { not_null<PeerData*>(_canAddBot) });
|
||||
} else {
|
||||
auto initBox = [title, weak = Ui::MakeWeak(this)](
|
||||
auto initBox = [title, weak = base::make_weak(this)](
|
||||
not_null<PeerListBox*> box) {
|
||||
auto create = [box, title, weak] {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->createGroup(
|
||||
box.get(),
|
||||
title,
|
||||
|
@ -129,7 +129,7 @@ protected:
|
||||
private:
|
||||
void createChannel(const QString &title, const QString &description);
|
||||
void createGroup(
|
||||
QPointer<Ui::BoxContent> selectUsersBox,
|
||||
base::weak_qptr<Ui::BoxContent> selectUsersBox,
|
||||
const QString &title,
|
||||
const std::vector<not_null<PeerData*>> &users);
|
||||
void submitName();
|
||||
|
@ -345,7 +345,7 @@ void BackgroundBox::resetForPeer() {
|
||||
api->applyUpdates(result);
|
||||
}).send();
|
||||
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
_forPeer->setWallPaper({});
|
||||
if (weak) {
|
||||
_controller->finishChatThemeEdit(_forPeer);
|
||||
@ -358,7 +358,7 @@ bool BackgroundBox::forChannel() const {
|
||||
|
||||
void BackgroundBox::removePaper(const Data::WallPaper &paper) {
|
||||
const auto session = &_controller->session();
|
||||
const auto remove = [=, weak = Ui::MakeWeak(this)](Fn<void()> &&close) {
|
||||
const auto remove = [=, weak = base::make_weak(this)](Fn<void()> &&close) {
|
||||
close();
|
||||
if (weak) {
|
||||
weak->_inner->removePaper(paper);
|
||||
|
@ -241,12 +241,12 @@ BackgroundPreviewBox::BackgroundPreviewBox(
|
||||
}, lifetime());
|
||||
|
||||
const auto prepare = [=](bool dark, auto pointer) {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
crl::async([=] {
|
||||
auto result = std::make_unique<style::palette>();
|
||||
Window::Theme::PreparePaletteCallback(dark, {})(*result);
|
||||
crl::on_main([=, result = std::move(result)]() mutable {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->*pointer = std::move(result);
|
||||
strong->paletteReady();
|
||||
}
|
||||
@ -685,7 +685,7 @@ void BackgroundPreviewBox::checkLevelForChannel() {
|
||||
|
||||
const auto show = _controller->uiShow();
|
||||
_forPeerLevelCheck = true;
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
CheckBoostLevel(show, _forPeer, [=](int level) {
|
||||
if (!weak) {
|
||||
return std::optional<Ui::AskBoostReason>();
|
||||
|
@ -522,10 +522,10 @@ void DeleteMessagesBox::deleteAndClear() {
|
||||
? PaidPostType::None
|
||||
: paidPostType();
|
||||
if (warnPaidType != PaidPostType::None) {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto callback = [=](Fn<void()> close) {
|
||||
close();
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->_confirmedDeletePaidSuggestedPosts = true;
|
||||
strong->deleteAndClear();
|
||||
}
|
||||
@ -559,11 +559,11 @@ void DeleteMessagesBox::deleteAndClear() {
|
||||
const auto invokeCallbackAndClose = [&] {
|
||||
// deleteMessages can initiate closing of the current section,
|
||||
// which will cause this box to be destroyed.
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
if (const auto callback = _deleteConfirmedCallback) {
|
||||
callback();
|
||||
}
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
|
@ -282,7 +282,7 @@ auto AddButtonWithLoader(
|
||||
) | rpl::start_with_next([=](bool toggled) {
|
||||
const auto &state = buttonState->current();
|
||||
if (toggled && (v::is<Available>(state) || v::is<Failed>(state))) {
|
||||
const auto weak = Ui::MakeWeak(button);
|
||||
const auto weak = base::make_weak(button);
|
||||
setLocalLoader(base::make_unique_q<Loader>(
|
||||
QCoreApplication::instance(),
|
||||
session,
|
||||
|
@ -1075,7 +1075,7 @@ void EditCaptionBox::save() {
|
||||
}
|
||||
|
||||
void EditCaptionBox::closeAfterSave() {
|
||||
const auto weak = MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
if (_saved) {
|
||||
_saved();
|
||||
}
|
||||
|
@ -1313,9 +1313,9 @@ void EditDirectMessagesPriceBox(
|
||||
}, box->lifetime());
|
||||
|
||||
box->addButton(tr::lng_settings_save(), [=] {
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
callback(toggle->toggled() ? *result : std::optional<int>());
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
});
|
||||
|
@ -582,7 +582,7 @@ void LinkController::addLinkBlock(not_null<Ui::VerticalLayout*> container) {
|
||||
using namespace Settings;
|
||||
|
||||
const auto link = _data.url;
|
||||
const auto weak = Ui::MakeWeak(container);
|
||||
const auto weak = base::make_weak(container);
|
||||
const auto copyLink = crl::guard(weak, [=] {
|
||||
CopyInviteLink(delegate()->peerListUiShow(), link);
|
||||
});
|
||||
|
@ -49,7 +49,7 @@ void SetCloudPassword(
|
||||
session->api().cloudPassword().state(
|
||||
) | rpl::start_with_next([=] {
|
||||
using namespace Settings;
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
if (CheckEditCloudPassword(session)) {
|
||||
box->getDelegate()->show(
|
||||
EditCloudPasswordBox(session));
|
||||
@ -103,11 +103,11 @@ void StartPendingReset(
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Ui::BoxContent*> context,
|
||||
Fn<void()> close) {
|
||||
const auto weak = Ui::MakeWeak(context.get());
|
||||
const auto weak = base::make_weak(context.get());
|
||||
auto lifetime = std::make_shared<rpl::lifetime>();
|
||||
|
||||
auto finish = [=](const QString &message) mutable {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
if (!message.isEmpty()) {
|
||||
strong->getDelegate()->show(Ui::MakeInformBox(message));
|
||||
}
|
||||
@ -136,7 +136,7 @@ void StartPendingReset(
|
||||
: hours
|
||||
? tr::lng_hours(tr::now, lt_count, hours)
|
||||
: tr::lng_minutes(tr::now, lt_count, minutes);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->getDelegate()->show(Ui::MakeInformBox(
|
||||
tr::lng_cloud_password_reset_later(
|
||||
tr::now,
|
||||
@ -447,7 +447,7 @@ void PasscodeBox::recoverPasswordDone(
|
||||
_replacedBy->closeBox();
|
||||
}
|
||||
_setRequest = 0;
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
_newAuthorization.fire_copy(result);
|
||||
if (weak) {
|
||||
_newPasswordSet.fire_copy(newPasswordBytes);
|
||||
@ -466,7 +466,7 @@ void PasscodeBox::setPasswordDone(const QByteArray &newPasswordBytes) {
|
||||
_replacedBy->closeBox();
|
||||
}
|
||||
_setRequest = 0;
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
_newPasswordSet.fire_copy(newPasswordBytes);
|
||||
if (weak) {
|
||||
auto text = _reenterPasscode->isHidden()
|
||||
@ -567,9 +567,9 @@ void PasscodeBox::validateEmail(
|
||||
} else if (error.type() == u"CODE_INVALID"_q) {
|
||||
errors->fire(tr::lng_signin_wrong_code(tr::now));
|
||||
} else if (error.type() == u"EMAIL_HASH_EXPIRED"_q) {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
_clearUnconfirmedPassword.fire({});
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->getDelegate()->show(
|
||||
Ui::MakeInformBox(
|
||||
Lang::Hard::EmailConfirmationExpired()),
|
||||
@ -607,7 +607,7 @@ void PasscodeBox::validateEmail(
|
||||
box->boxClosing(
|
||||
) | rpl::filter([=] {
|
||||
return !*set;
|
||||
}) | start_with_next([=, weak = Ui::MakeWeak(this)] {
|
||||
}) | start_with_next([=, weak = base::make_weak(this)] {
|
||||
if (weak) {
|
||||
weak->_clearUnconfirmedPassword.fire({});
|
||||
}
|
||||
@ -710,7 +710,7 @@ void PasscodeBox::save(bool force) {
|
||||
}
|
||||
} else {
|
||||
closeReplacedBy();
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
cSetPasscodeBadTries(0);
|
||||
_session->domain().local().setPasscode(pwd.toUtf8());
|
||||
Core::App().localPasscodeChanged();
|
||||
@ -742,7 +742,7 @@ void PasscodeBox::submitOnlyCheckCloudPassword(const QString &oldPassword) {
|
||||
void PasscodeBox::sendOnlyCheckCloudPassword(const QString &oldPassword) {
|
||||
checkPassword(oldPassword, [=](const Core::CloudPasswordResult &check) {
|
||||
if (const auto onstack = _cloudFields.customCheckCallback) {
|
||||
onstack(check, Ui::MakeWeak(this));
|
||||
onstack(check, base::make_weak(this));
|
||||
} else {
|
||||
Assert(_cloudFields.turningOff);
|
||||
sendClearCloudPassword(check);
|
||||
@ -1105,7 +1105,7 @@ void PasscodeBox::recover() {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto box = getDelegate()->show(Box<RecoverBox>(
|
||||
&_api.instance(),
|
||||
_session,
|
||||
@ -1343,7 +1343,7 @@ void RecoverBox::proceedToChange(const QString &code) {
|
||||
|
||||
box->boxClosing(
|
||||
) | rpl::start_with_next([=] {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
if (const auto onstack = _closeParent) {
|
||||
onstack();
|
||||
}
|
||||
@ -1399,7 +1399,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail(
|
||||
const auto errors = std::make_shared<rpl::event_stream<QString>>();
|
||||
const auto resent = std::make_shared<rpl::event_stream<QString>>();
|
||||
const auto requestId = std::make_shared<mtpRequestId>(0);
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto reloads = std::make_shared<rpl::event_stream<>>();
|
||||
const auto cancels = std::make_shared<rpl::event_stream<>>();
|
||||
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
// Check cloud password for some action.
|
||||
using CustomCheck = Fn<void(
|
||||
const Core::CloudPasswordResult &,
|
||||
QPointer<PasscodeBox>)>;
|
||||
base::weak_qptr<PasscodeBox>)>;
|
||||
CustomCheck customCheckCallback;
|
||||
rpl::producer<QString> customTitle;
|
||||
std::optional<QString> customDescription;
|
||||
@ -158,7 +158,7 @@ private:
|
||||
|
||||
QString _pattern;
|
||||
|
||||
QPointer<Ui::BoxContent> _replacedBy;
|
||||
base::weak_qptr<Ui::BoxContent> _replacedBy;
|
||||
bool _turningOff = false;
|
||||
bool _cloudPwd = false;
|
||||
CloudFields _cloudFields;
|
||||
|
@ -831,7 +831,7 @@ void ChooseRecipientBoxController::rowClicked(not_null<PeerListRow*> row) {
|
||||
auto guard = base::make_weak(this);
|
||||
const auto peer = row->peer();
|
||||
if (const auto forum = peer->forum()) {
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
auto callback = [=](not_null<Data::ForumTopic*> topic) {
|
||||
const auto exists = guard.get();
|
||||
if (!exists) {
|
||||
@ -870,7 +870,7 @@ void ChooseRecipientBoxController::rowClicked(not_null<PeerListRow*> row) {
|
||||
delegate()->peerListUiShow()->showBox(std::move(owned));
|
||||
return;
|
||||
} else if (const auto monoforum = peer->monoforum()) {
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
auto callback = [=](not_null<Data::SavedSublist*> sublist) {
|
||||
const auto exists = guard.get();
|
||||
if (!exists) {
|
||||
|
@ -898,9 +898,9 @@ bool AddParticipantsBoxController::needsInviteLinkButton() {
|
||||
return _peer->asChat()->canHaveInviteLink();
|
||||
}
|
||||
|
||||
QPointer<Ui::BoxContent> AddParticipantsBoxController::showBox(
|
||||
base::weak_qptr<Ui::BoxContent> AddParticipantsBoxController::showBox(
|
||||
object_ptr<Ui::BoxContent> box) const {
|
||||
const auto weak = Ui::MakeWeak(box.data());
|
||||
const auto weak = base::make_weak(box.data());
|
||||
delegate()->peerListUiShow()->showBox(std::move(box));
|
||||
return weak;
|
||||
}
|
||||
@ -976,7 +976,7 @@ void AddParticipantsBoxController::inviteSelectedUsers(
|
||||
tr::lng_participant_invite_history(),
|
||||
true,
|
||||
st::defaultBoxCheckbox);
|
||||
const auto weak = Ui::MakeWeak(checkbox.data());
|
||||
const auto weak = base::make_weak(checkbox.data());
|
||||
|
||||
auto text = (users.size() == 1)
|
||||
? tr::lng_participant_invite_sure(
|
||||
@ -1205,9 +1205,9 @@ void AddSpecialBoxController::migrate(
|
||||
_additional.migrate(chat, channel);
|
||||
}
|
||||
|
||||
QPointer<Ui::BoxContent> AddSpecialBoxController::showBox(
|
||||
base::weak_qptr<Ui::BoxContent> AddSpecialBoxController::showBox(
|
||||
object_ptr<Ui::BoxContent> box) const {
|
||||
const auto weak = Ui::MakeWeak(box.data());
|
||||
const auto weak = base::make_weak(box.data());
|
||||
delegate()->peerListUiShow()->showBox(std::move(box));
|
||||
return weak;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
base::flat_set<not_null<UserData*>> &&alreadyIn,
|
||||
bool justCreated);
|
||||
|
||||
QPointer<Ui::BoxContent> showBox(object_ptr<Ui::BoxContent> box) const;
|
||||
base::weak_qptr<Ui::BoxContent> showBox(object_ptr<Ui::BoxContent> box) const;
|
||||
|
||||
void addInviteLinkButton();
|
||||
void inviteSelectedUsers(
|
||||
@ -147,7 +147,7 @@ private:
|
||||
void subscribeToMigration();
|
||||
void migrate(not_null<ChatData*> chat, not_null<ChannelData*> channel);
|
||||
|
||||
QPointer<Ui::BoxContent> showBox(object_ptr<Ui::BoxContent> box) const;
|
||||
base::weak_qptr<Ui::BoxContent> showBox(object_ptr<Ui::BoxContent> box) const;
|
||||
|
||||
not_null<PeerData*> _peer;
|
||||
MTP::Sender _api;
|
||||
@ -158,7 +158,7 @@ private:
|
||||
ParticipantsAdditionalData _additional;
|
||||
std::unique_ptr<ParticipantsOnlineSorter> _onlineSorter;
|
||||
Ui::BoxPointer _editBox;
|
||||
QPointer<Ui::BoxContent> _editParticipantBox;
|
||||
base::weak_qptr<Ui::BoxContent> _editParticipantBox;
|
||||
AdminDoneCallback _adminDoneCallback;
|
||||
BannedDoneCallback _bannedDoneCallback;
|
||||
|
||||
|
@ -246,10 +246,10 @@ object_ptr<Ui::BoxContent> CreatePeerByQueryBox(
|
||||
not_null<UserData*> bot,
|
||||
RequestPeerQuery query,
|
||||
Fn<void(std::vector<not_null<PeerData*>>)> done) {
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
auto callback = [=](not_null<PeerData*> peer) {
|
||||
done({ peer });
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -506,11 +506,11 @@ void ShowChoosePeerBox(
|
||||
});
|
||||
return;
|
||||
}
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
auto callback = [=, done = std::move(chosen)](
|
||||
std::vector<not_null<PeerData*>> peers) {
|
||||
done(std::move(peers));
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
|
@ -37,7 +37,7 @@ QString UserPhone(not_null<UserData*> user) {
|
||||
}
|
||||
|
||||
void SendRequest(
|
||||
QPointer<Ui::GenericBox> box,
|
||||
base::weak_qptr<Ui::GenericBox> box,
|
||||
not_null<UserData*> user,
|
||||
bool sharePhone,
|
||||
const QString &first,
|
||||
@ -219,7 +219,7 @@ void Controller::initNameFields(
|
||||
}
|
||||
};
|
||||
SendRequest(
|
||||
Ui::MakeWeak(_box),
|
||||
base::make_weak(_box),
|
||||
user,
|
||||
_sharePhone && _sharePhone->checked(),
|
||||
firstValue,
|
||||
|
@ -554,7 +554,7 @@ void EditForumTopicBox(
|
||||
} else {
|
||||
using Flag = MTPchannels_EditForumTopic::Flag;
|
||||
const auto api = &forum->session().api();
|
||||
const auto weak = Ui::MakeWeak(box.get());
|
||||
const auto weak = base::make_weak(box);
|
||||
state->requestId = api->request(MTPchannels_EditForumTopic(
|
||||
MTP_flags(Flag::f_title
|
||||
| (topic->isGeneral() ? Flag() : Flag::f_icon_emoji_id)),
|
||||
@ -566,11 +566,11 @@ void EditForumTopicBox(
|
||||
MTPBool() // hidden
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
api->applyUpdates(result);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
if (error.type() == u"TOPIC_NOT_MODIFIED") {
|
||||
strong->closeBox();
|
||||
} else {
|
||||
|
@ -450,9 +450,9 @@ void EditAdminBox::prepare() {
|
||||
if (!_saveCallback) {
|
||||
return;
|
||||
} else if (_addAsAdmin && !_addAsAdmin->checked()) {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
AddBotToGroup(show, user(), peer(), _addingBot->token);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
return;
|
||||
@ -661,7 +661,7 @@ void EditAdminBox::requestTransferPassword(not_null<ChannelData*> channel) {
|
||||
fields.customSubmitButton = tr::lng_passcode_submit();
|
||||
fields.customCheckCallback = crl::guard(this, [=](
|
||||
const Core::CloudPasswordResult &result,
|
||||
QPointer<PasscodeBox> box) {
|
||||
base::weak_qptr<PasscodeBox> box) {
|
||||
sendTransferRequestFrom(box, channel, result);
|
||||
});
|
||||
getDelegate()->show(Box<PasscodeBox>(&channel->session(), fields));
|
||||
@ -669,13 +669,13 @@ void EditAdminBox::requestTransferPassword(not_null<ChannelData*> channel) {
|
||||
}
|
||||
|
||||
void EditAdminBox::sendTransferRequestFrom(
|
||||
QPointer<PasscodeBox> box,
|
||||
base::weak_qptr<PasscodeBox> box,
|
||||
not_null<ChannelData*> channel,
|
||||
const Core::CloudPasswordResult &result) {
|
||||
if (_transferRequestId) {
|
||||
return;
|
||||
}
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto user = this->user();
|
||||
const auto api = &channel->session().api();
|
||||
_transferRequestId = api->request(MTPchannels_EditCreator(
|
||||
@ -726,7 +726,7 @@ void EditAdminBox::sendTransferRequestFrom(
|
||||
|| type.startsWith(u"PASSWORD_TOO_FRESH_"_q)
|
||||
|| type.startsWith(u"SESSION_TOO_FRESH_"_q);
|
||||
}();
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
getDelegate()->show(Ui::MakeInformBox(problem));
|
||||
if (box) {
|
||||
box->closeBox();
|
||||
|
@ -104,7 +104,7 @@ private:
|
||||
bool handleTransferPasswordError(const QString &error);
|
||||
void requestTransferPassword(not_null<ChannelData*> channel);
|
||||
void sendTransferRequestFrom(
|
||||
QPointer<PasscodeBox> box,
|
||||
base::weak_qptr<PasscodeBox> box,
|
||||
not_null<ChannelData*> channel,
|
||||
const Core::CloudPasswordResult &result);
|
||||
bool canSave() const {
|
||||
@ -124,7 +124,7 @@ private:
|
||||
ChatAdminRightsInfo,
|
||||
const QString &rank)> _saveCallback;
|
||||
|
||||
QPointer<Ui::BoxContent> _confirmBox;
|
||||
base::weak_qptr<Ui::BoxContent> _confirmBox;
|
||||
Ui::Checkbox *_addAsAdmin = nullptr;
|
||||
Ui::SlideWrap<Ui::VerticalLayout> *_adminControlsWrap = nullptr;
|
||||
Ui::InputField *_rank = nullptr;
|
||||
|
@ -1324,9 +1324,9 @@ void ParticipantsBoxController::rebuild() {
|
||||
refreshRows();
|
||||
}
|
||||
|
||||
QPointer<Ui::BoxContent> ParticipantsBoxController::showBox(
|
||||
base::weak_qptr<Ui::BoxContent> ParticipantsBoxController::showBox(
|
||||
object_ptr<Ui::BoxContent> box) const {
|
||||
const auto weak = Ui::MakeWeak(box.data());
|
||||
const auto weak = base::make_weak(box.data());
|
||||
delegate()->peerListUiShow()->showBox(std::move(box));
|
||||
return weak;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ private:
|
||||
Role role,
|
||||
not_null<ParticipantsAdditionalData*> additional);
|
||||
|
||||
QPointer<Ui::BoxContent> showBox(object_ptr<Ui::BoxContent> box) const;
|
||||
base::weak_qptr<Ui::BoxContent> showBox(object_ptr<Ui::BoxContent> box) const;
|
||||
|
||||
void prepareChatRows(not_null<ChatData*> chat);
|
||||
void rebuildChatRows(not_null<ChatData*> chat);
|
||||
@ -304,7 +304,7 @@ private:
|
||||
rpl::variable<int> _fullCountValue;
|
||||
Ui::BoxPointer _editBox;
|
||||
Ui::BoxPointer _addBox;
|
||||
QPointer<Ui::BoxContent> _editParticipantBox;
|
||||
base::weak_qptr<Ui::BoxContent> _editParticipantBox;
|
||||
|
||||
std::unique_ptr<PeerListStories> _stories;
|
||||
|
||||
|
@ -906,7 +906,7 @@ void Controller::showEditDiscussionLinkBox() {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto box = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto channel = _peer->asChannel();
|
||||
const auto callback = [=](ChannelData *result) {
|
||||
if (*box) {
|
||||
@ -1252,12 +1252,12 @@ void Controller::fillAutoTranslateButton() {
|
||||
_autotranslateSavedValue = value;
|
||||
} else if (value) {
|
||||
state->toggled.fire(false);
|
||||
auto weak = Ui::MakeWeak(autotranslate);
|
||||
auto weak = base::make_weak(autotranslate);
|
||||
CheckBoostLevel(
|
||||
_navigation->uiShow(),
|
||||
_peer,
|
||||
[=](int level) {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
state->isLocked = (level < requiredLevel);
|
||||
}
|
||||
return (level < requiredLevel)
|
||||
|
@ -424,7 +424,7 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
|
||||
const auto revoked = current.revoked;
|
||||
const auto link = current.link;
|
||||
const auto admin = current.admin;
|
||||
const auto weak = Ui::MakeWeak(container);
|
||||
const auto weak = base::make_weak(container);
|
||||
const auto copyLink = crl::guard(weak, [=] {
|
||||
CopyInviteLink(delegate()->peerListUiShow(), link);
|
||||
});
|
||||
@ -1290,7 +1290,7 @@ void AddPermanentLinkBlock(
|
||||
return LinkData{ link.link, link.usage };
|
||||
});
|
||||
}
|
||||
const auto weak = Ui::MakeWeak(container);
|
||||
const auto weak = base::make_weak(container);
|
||||
const auto copyLink = crl::guard(weak, [=] {
|
||||
if (const auto current = value->current(); !current.link.isEmpty()) {
|
||||
CopyInviteLink(show, current.link);
|
||||
@ -1471,7 +1471,7 @@ object_ptr<Ui::BoxContent> ShareInviteLinkBox(
|
||||
const QString &link,
|
||||
const QString &copied) {
|
||||
const auto sending = std::make_shared<bool>();
|
||||
const auto box = std::make_shared<QPointer<ShareBox>>();
|
||||
const auto box = std::make_shared<base::weak_qptr<ShareBox>>();
|
||||
|
||||
const auto showToast = [=](const QString &text) {
|
||||
if (*box) {
|
||||
@ -1551,7 +1551,7 @@ object_ptr<Ui::BoxContent> ShareInviteLinkBox(
|
||||
.filterCallback = std::move(filterCallback),
|
||||
.moneyRestrictionError = ShareMessageMoneyRestrictionError(),
|
||||
});
|
||||
*box = Ui::MakeWeak(object.data());
|
||||
*box = base::make_weak(object.data());
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -1573,7 +1573,7 @@ object_ptr<Ui::BoxContent> EditLinkBox(
|
||||
constexpr auto kPeriod = 3600 * 24 * 30;
|
||||
constexpr auto kTestModePeriod = 300;
|
||||
const auto creating = data.link.isEmpty();
|
||||
const auto box = std::make_shared<QPointer<Ui::GenericBox>>();
|
||||
const auto box = std::make_shared<base::weak_qptr<Ui::GenericBox>>();
|
||||
using Fields = Ui::InviteLinkFields;
|
||||
const auto done = [=](Fields result) {
|
||||
const auto finish = [=](Api::InviteLink finished) {
|
||||
@ -1645,7 +1645,7 @@ object_ptr<Ui::BoxContent> EditLinkBox(
|
||||
done);
|
||||
}
|
||||
});
|
||||
*box = Ui::MakeWeak(object.data());
|
||||
*box = base::make_weak(object.data());
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -127,11 +127,11 @@ void Controller::confirmAdd(not_null<PeerData*> peer) {
|
||||
return;
|
||||
}
|
||||
state->sent = true;
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
const auto description = modify ? state->description : QString();
|
||||
Setup(bot, peer, description, [=](QString error) {
|
||||
if (error.isEmpty()) {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
show->showToast({
|
||||
@ -204,10 +204,10 @@ void Controller::confirmRemove(not_null<PeerData*> peer) {
|
||||
return;
|
||||
}
|
||||
*sent = true;
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
Remove(bot, peer, [=](QString error) {
|
||||
if (error.isEmpty()) {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
show->showToast(tr::lng_bot_verify_remove_done(tr::now));
|
||||
|
@ -49,7 +49,7 @@ Locale: ") + ::Platform::SystemLanguage();
|
||||
void ShowPhoneBannedError(
|
||||
not_null<Window::Controller*> controller,
|
||||
const QString &phone) {
|
||||
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto box = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto close = [=] {
|
||||
if (*box) {
|
||||
(*box)->closeBox();
|
||||
|
@ -50,8 +50,8 @@ void PinMessageBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<HistoryItem*> item) {
|
||||
struct State {
|
||||
QPointer<Ui::Checkbox> pinForPeer;
|
||||
QPointer<Ui::Checkbox> notify;
|
||||
base::weak_qptr<Ui::Checkbox> pinForPeer;
|
||||
base::weak_qptr<Ui::Checkbox> notify;
|
||||
mtpRequestId requestId = 0;
|
||||
};
|
||||
|
||||
@ -81,7 +81,7 @@ void PinMessageBox(
|
||||
false,
|
||||
st::urlAuthCheckbox);
|
||||
object->setAllowTextLines();
|
||||
state->pinForPeer = Ui::MakeWeak(object.data());
|
||||
state->pinForPeer = base::make_weak(object.data());
|
||||
return object;
|
||||
} else if (!pinningOld
|
||||
&& (peer->isChat() || peer->isMegagroup())
|
||||
@ -92,7 +92,7 @@ void PinMessageBox(
|
||||
true,
|
||||
st::urlAuthCheckbox);
|
||||
object->setAllowTextLines();
|
||||
state->notify = Ui::MakeWeak(object.data());
|
||||
state->notify = base::make_weak(object.data());
|
||||
return object;
|
||||
}
|
||||
return { nullptr };
|
||||
|
@ -56,7 +56,7 @@ void AddDeleteAccount(
|
||||
fields.customSubmitButton = tr::lng_theme_delete();
|
||||
fields.customCheckCallback = [=](
|
||||
const Core::CloudPasswordResult &result,
|
||||
QPointer<PasscodeBox> box) {
|
||||
base::weak_qptr<PasscodeBox> box) {
|
||||
session->api().request(MTPaccount_DeleteAccount(
|
||||
MTP_flags(MTPaccount_DeleteAccount::Flag::f_password),
|
||||
MTP_string("Manual"),
|
||||
|
@ -397,7 +397,7 @@ void SendCreditsBox(
|
||||
return;
|
||||
}
|
||||
const auto show = box->uiShow();
|
||||
const auto weak = MakeWeak(box.get());
|
||||
const auto weak = base::make_weak(box.get());
|
||||
state->confirmButtonBusy = true;
|
||||
session->api().request(
|
||||
MTPpayments_SendStarsForm(
|
||||
@ -422,7 +422,7 @@ void SendCreditsBox(
|
||||
auto error = ::Ui::MakeInformBox(
|
||||
tr::lng_payments_precheckout_stars_failed(tr::now));
|
||||
error->boxClosing() | rpl::start_with_next([=] {
|
||||
if (const auto paybox = weak.data()) {
|
||||
if (const auto paybox = weak.get()) {
|
||||
paybox->closeBox();
|
||||
}
|
||||
}, error->lifetime());
|
||||
|
@ -175,9 +175,9 @@ void EditPriceBox(
|
||||
field->showError();
|
||||
return;
|
||||
}
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
apply(now);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -597,7 +597,7 @@ void SendFilesBox::enqueueNextPrepare() {
|
||||
}
|
||||
auto file = std::move(_list.filesToProcess.front());
|
||||
_list.filesToProcess.pop_front();
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
_preparing = true;
|
||||
const auto sideLimit = PhotoSideLimit(); // Get on main thread.
|
||||
crl::async([weak, sideLimit, file = std::move(file)]() mutable {
|
||||
@ -803,7 +803,7 @@ void SendFilesBox::toggleSpoilers(bool enabled) {
|
||||
}
|
||||
|
||||
void SendFilesBox::changePrice() {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto session = &_show->session();
|
||||
const auto now = _price.current();
|
||||
_show->show(Box(EditPriceBox, session, now, [=](uint64 price) {
|
||||
|
@ -677,7 +677,7 @@ void ShareBox::submit(Api::SendOptions options) {
|
||||
_submitLifetime.destroy();
|
||||
|
||||
auto threads = _inner->selected();
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto field = _comment->entity();
|
||||
auto comment = field->getTextWithAppliedMarkdown();
|
||||
const auto checkPaid = [=] {
|
||||
@ -1371,8 +1371,8 @@ void ShareBox::Inner::changeCheckState(Chat *chat) {
|
||||
}
|
||||
|
||||
void ShareBox::Inner::chooseForumTopic(not_null<Data::Forum*> forum) {
|
||||
const auto guard = Ui::MakeWeak(this);
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto guard = base::make_weak(this);
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
auto chosen = [=](not_null<Data::ForumTopic*> topic) {
|
||||
if (const auto strong = *weak) {
|
||||
strong->closeBox();
|
||||
@ -1419,8 +1419,8 @@ void ShareBox::Inner::chooseForumTopic(not_null<Data::Forum*> forum) {
|
||||
|
||||
void ShareBox::Inner::chooseMonoforumSublist(
|
||||
not_null<Data::SavedMessages*> monoforum) {
|
||||
const auto guard = Ui::MakeWeak(this);
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto guard = base::make_weak(this);
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
auto chosen = [=](not_null<Data::SavedSublist*> sublist) {
|
||||
if (const auto strong = *weak) {
|
||||
strong->closeBox();
|
||||
@ -1953,7 +1953,7 @@ void FastShareLink(
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
const QString &url,
|
||||
ShareBoxStyleOverrides st) {
|
||||
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto box = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto sending = std::make_shared<bool>();
|
||||
auto copyCallback = [=] {
|
||||
QGuiApplication::clipboard()->setText(url);
|
||||
|
@ -2516,7 +2516,7 @@ void SendGiftBox(
|
||||
if (!state->messageAllowed.current()) {
|
||||
details.text = {};
|
||||
}
|
||||
const auto weak = MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
const auto done = [=](Payments::CheckoutResult result) {
|
||||
if (result == Payments::CheckoutResult::Paid) {
|
||||
if (details.byStars
|
||||
@ -2527,7 +2527,7 @@ void SendGiftBox(
|
||||
window->showPeerHistory(peer);
|
||||
ShowSentToast(window, details.descriptor, details);
|
||||
}
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -4337,12 +4337,12 @@ void ShowUniqueGiftWearBox(
|
||||
return;
|
||||
}
|
||||
*checking = true;
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
CheckBoostLevel(show, peer, [=](int level) {
|
||||
const auto limits = Data::LevelLimits(&peer->session());
|
||||
const auto wanted = limits.channelEmojiStatusLevelMin();
|
||||
if (level >= wanted) {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
emojiStatuses->set(peer, id);
|
||||
@ -4835,13 +4835,13 @@ void UpgradeBox(
|
||||
}
|
||||
state->sent = true;
|
||||
const auto keepDetails = state->preserveDetails;
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
const auto done = [=](Payments::CheckoutResult result) {
|
||||
if (result != Payments::CheckoutResult::Paid) {
|
||||
state->sent = false;
|
||||
} else {
|
||||
controller->showPeerHistory(args.peer);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
}
|
||||
|
@ -494,7 +494,7 @@ StickerSetBox::StickerSetBox(
|
||||
: StickerSetBox(parent, std::move(show), set->identifier(), set->type()) {
|
||||
}
|
||||
|
||||
QPointer<Ui::BoxContent> StickerSetBox::Show(
|
||||
base::weak_qptr<Ui::BoxContent> StickerSetBox::Show(
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
not_null<DocumentData*> document) {
|
||||
if (const auto sticker = document->sticker()) {
|
||||
@ -503,7 +503,7 @@ QPointer<Ui::BoxContent> StickerSetBox::Show(
|
||||
show,
|
||||
sticker->set,
|
||||
sticker->setType);
|
||||
const auto result = QPointer<Ui::BoxContent>(box.data());
|
||||
const auto result = base::make_weak(box.data());
|
||||
show->showBox(std::move(box));
|
||||
return result;
|
||||
}
|
||||
@ -1485,7 +1485,7 @@ void StickerSetBox::Inner::fillDeleteStickerBox(
|
||||
int index) {
|
||||
Expects(index >= 0 || index < _pack.size());
|
||||
const auto document = _pack[index];
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto show = _show;
|
||||
|
||||
const auto container = box->verticalLayout();
|
||||
@ -1510,7 +1510,7 @@ void StickerSetBox::Inner::fillDeleteStickerBox(
|
||||
sticker->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto p = Painter(sticker);
|
||||
if ([[maybe_unused]] const auto strong = weak.data()) {
|
||||
if ([[maybe_unused]] const auto strong = weak.get()) {
|
||||
const auto paused = On(PowerSaving::kStickersPanel)
|
||||
|| show->paused(ChatHelpers::PauseReason::Layer);
|
||||
paintSticker(p, index, QPoint(), paused, crl::now());
|
||||
@ -1551,7 +1551,7 @@ void StickerSetBox::Inner::fillDeleteStickerBox(
|
||||
if (state->requestId.current()) {
|
||||
return;
|
||||
}
|
||||
const auto weakBox = Ui::MakeWeak(box);
|
||||
const auto weakBox = base::make_weak(box);
|
||||
const auto buttonWidth = state->saveButton
|
||||
? state->saveButton->width()
|
||||
: 0;
|
||||
@ -1564,14 +1564,14 @@ void StickerSetBox::Inner::fillDeleteStickerBox(
|
||||
Data::StickersType::Stickers);
|
||||
}, [](const auto &) {
|
||||
});
|
||||
if ([[maybe_unused]] const auto strong = weak.data()) {
|
||||
if ([[maybe_unused]] const auto strong = weak.get()) {
|
||||
applySet(result);
|
||||
}
|
||||
if (const auto strongBox = weakBox.data()) {
|
||||
if (const auto strongBox = weakBox.get()) {
|
||||
strongBox->closeBox();
|
||||
}
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
if (const auto strongBox = weakBox.data()) {
|
||||
if (const auto strongBox = weakBox.get()) {
|
||||
strongBox->uiShow()->showToast(error.type());
|
||||
}
|
||||
}).send();
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
not_null<Data::StickersSet*> set);
|
||||
|
||||
static QPointer<Ui::BoxContent> Show(
|
||||
static base::weak_qptr<Ui::BoxContent> Show(
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
not_null<DocumentData*> document);
|
||||
|
||||
|
@ -2058,7 +2058,7 @@ void StickersBox::Inner::checkGroupLevel(Fn<void()> done) {
|
||||
}
|
||||
_checkingGroupLevel = true;
|
||||
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
CheckBoostLevel(_show, peer, [=](int level) {
|
||||
if (!weak) {
|
||||
return std::optional<Ui::AskBoostReason>();
|
||||
|
@ -90,8 +90,8 @@ void ConfirmExportBox(
|
||||
Ui::Text::WithEntities),
|
||||
st::boxLabel));
|
||||
box->addButton(tr::lng_gift_transfer_confirm_button(), [=] {
|
||||
confirmed([weak = Ui::MakeWeak(box)] {
|
||||
if (const auto strong = weak.data()) {
|
||||
confirmed([weak = base::make_weak(box)] {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
});
|
||||
@ -143,7 +143,7 @@ void ExportOnBlockchain(
|
||||
fields.customSubmitButton = tr::lng_passcode_submit();
|
||||
fields.customCheckCallback = crl::guard(parent, [=](
|
||||
const Core::CloudPasswordResult &result,
|
||||
QPointer<PasscodeBox> box) {
|
||||
base::weak_qptr<PasscodeBox> box) {
|
||||
using ExportUrl = MTPpayments_StarGiftWithdrawalUrl;
|
||||
session->api().request(
|
||||
MTPpayments_GetStarGiftWithdrawalUrl(
|
||||
@ -180,7 +180,7 @@ void ExportOnBlockchain(
|
||||
const auto state = std::make_shared<State>();
|
||||
const auto activate = [=] {
|
||||
const auto now = base::unixtime::now();
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
const auto left = (when > now) ? (when - now) : 0;
|
||||
const auto hours = left ? std::max((left + 1800) / 3600, 1) : 0;
|
||||
if (!hours) {
|
||||
@ -193,7 +193,7 @@ void ExportOnBlockchain(
|
||||
state->exporting = false;
|
||||
close();
|
||||
}, [=] {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
close();
|
||||
@ -572,11 +572,11 @@ void ShowTransferToBox(
|
||||
return;
|
||||
}
|
||||
state->sent = true;
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
const auto done = [=](Payments::CheckoutResult result) {
|
||||
if (result == Payments::CheckoutResult::Cancelled) {
|
||||
closeParentBox();
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
} else if (result != Payments::CheckoutResult::Paid) {
|
||||
@ -586,7 +586,7 @@ void ShowTransferToBox(
|
||||
controller->showPeerHistory(peer);
|
||||
}
|
||||
closeParentBox();
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
}
|
||||
@ -674,7 +674,7 @@ void ShowBuyResaleGiftBox(
|
||||
return;
|
||||
}
|
||||
state->sent = true;
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
const auto done = [=](Payments::CheckoutResult result) {
|
||||
if (result == Payments::CheckoutResult::Cancelled) {
|
||||
closeParentBox();
|
||||
|
@ -307,7 +307,7 @@ object_ptr<BoxContent> EditSkipTranslationLanguages() {
|
||||
auto title = tr::lng_translate_settings_choose();
|
||||
const auto selected = std::make_shared<std::vector<LanguageId>>(
|
||||
Core::App().settings().skipTranslationLanguages());
|
||||
const auto weak = std::make_shared<QPointer<BoxContent>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<BoxContent>>();
|
||||
const auto check = [=](LanguageId id) {
|
||||
const auto already = ranges::contains(*selected, id);
|
||||
if (already) {
|
||||
@ -316,7 +316,7 @@ object_ptr<BoxContent> EditSkipTranslationLanguages() {
|
||||
selected->push_back(id);
|
||||
}
|
||||
if (already && selected->empty()) {
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->showToast(
|
||||
tr::lng_translate_settings_one(tr::now),
|
||||
kSkipAtLeastOneDuration);
|
||||
|
@ -134,7 +134,7 @@ void UrlAuthBox::Request(
|
||||
const auto bot = request.is_request_write_access()
|
||||
? session->data().processUser(request.vbot()).get()
|
||||
: nullptr;
|
||||
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto box = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto finishWithUrl = [=](const QString &url) {
|
||||
if (*box) {
|
||||
(*box)->closeBox();
|
||||
@ -185,7 +185,7 @@ void UrlAuthBox::Request(
|
||||
const auto bot = request.is_request_write_access()
|
||||
? session->data().processUser(request.vbot()).get()
|
||||
: nullptr;
|
||||
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto box = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto finishWithUrl = [=](const QString &url) {
|
||||
if (*box) {
|
||||
(*box)->closeBox();
|
||||
|
@ -711,7 +711,7 @@ std::unique_ptr<PeerListRow> BoxController::createRow(
|
||||
void ClearCallsBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<::Window::SessionController*> window) {
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
@ -754,7 +754,7 @@ void ClearCallsBox(
|
||||
self(revoke, self);
|
||||
} else {
|
||||
api->session().data().destroyAllCallItems();
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
}
|
||||
|
@ -604,9 +604,9 @@ void SetupFingerprintTooltip(not_null<Ui::RpWidget*> widget) {
|
||||
st::confcallFingerprintTooltipLabel),
|
||||
st::confcallFingerprintTooltip);
|
||||
const auto raw = state->tooltip.get();
|
||||
const auto weak = QPointer<QWidget>(raw);
|
||||
const auto weak = base::make_weak(raw);
|
||||
const auto destroy = [=] {
|
||||
delete weak.data();
|
||||
delete weak.get();
|
||||
};
|
||||
raw->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
raw->setHiddenCallback(destroy);
|
||||
|
@ -393,7 +393,7 @@ void ChooseJoinAsProcess::finish(JoinInfo info) {
|
||||
const auto box = _request->box;
|
||||
_request = nullptr;
|
||||
done(std::move(info));
|
||||
if (const auto strong = box.data()) {
|
||||
if (const auto strong = box.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ private:
|
||||
std::shared_ptr<Ui::Show> show;
|
||||
Fn<void(JoinInfo)> done;
|
||||
base::has_weak_ptr guard;
|
||||
QPointer<Ui::BoxContent> box;
|
||||
base::weak_qptr<Ui::BoxContent> box;
|
||||
rpl::lifetime lifetime;
|
||||
Context context = Context();
|
||||
mtpRequestId id = 0;
|
||||
|
@ -213,8 +213,8 @@ void ConferenceCallJoinConfirm(
|
||||
)->setTryMakeSimilarLines(true);
|
||||
}
|
||||
const auto joinAndClose = [=] {
|
||||
join([weak = Ui::MakeWeak(box)] {
|
||||
if (const auto strong = weak.data()) {
|
||||
join([weak = base::make_weak(box)] {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
});
|
||||
@ -275,7 +275,7 @@ void ShowConferenceCallLinkBox(
|
||||
}
|
||||
state->resetting = true;
|
||||
using Flag = MTPphone_ToggleGroupCallSettings::Flag;
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
call->session().api().request(
|
||||
MTPphone_ToggleGroupCallSettings(
|
||||
MTP_flags(Flag::f_reset_invite_hash),
|
||||
@ -284,7 +284,7 @@ void ShowConferenceCallLinkBox(
|
||||
).done([=](const MTPUpdates &result) {
|
||||
call->session().api().applyUpdates(result);
|
||||
ShowConferenceCallLinkBox(show, call, args);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
show->showToast({
|
||||
|
@ -943,7 +943,7 @@ object_ptr<Ui::BoxContent> PrepareInviteBox(
|
||||
: (nonMembers.size() < users.size())
|
||||
? tr::lng_group_call_add_to_group_some(tr::now, lt_group, name)
|
||||
: tr::lng_group_call_add_to_group_all(tr::now, lt_group, name);
|
||||
const auto shared = std::make_shared<QPointer<Ui::GenericBox>>();
|
||||
const auto shared = std::make_shared<base::weak_qptr<Ui::GenericBox>>();
|
||||
const auto finishWithConfirm = [=] {
|
||||
if (*shared) {
|
||||
(*shared)->closeBox();
|
||||
@ -983,7 +983,7 @@ object_ptr<Ui::BoxContent> PrepareInviteBox(
|
||||
return !controller->hasRowFor(user);
|
||||
}) | ranges::to_vector;
|
||||
|
||||
const auto finish = [box = Ui::MakeWeak(box)]() {
|
||||
const auto finish = [box = base::make_weak(box)]() {
|
||||
if (box) {
|
||||
box->closeBox();
|
||||
}
|
||||
@ -1098,14 +1098,14 @@ object_ptr<Ui::BoxContent> PrepareInviteToEmptyBox(
|
||||
}, box->lifetime());
|
||||
|
||||
const auto join = [=] {
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
auto selected = raw->requests(box->collectSelectedRows());
|
||||
Core::App().calls().startOrJoinConferenceCall({
|
||||
.call = call,
|
||||
.joinMessageId = inviteMsgId,
|
||||
.invite = std::move(selected),
|
||||
});
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
|
@ -1346,16 +1346,16 @@ base::unique_qptr<Ui::PopupMenu> Members::Controller::createRowContextMenu(
|
||||
: addVolumeItem
|
||||
? st::groupCallPopupMenuWithVolume
|
||||
: st::groupCallPopupMenu));
|
||||
const auto weakMenu = Ui::MakeWeak(result.get());
|
||||
const auto weakMenu = base::make_weak(result.get());
|
||||
const auto withActiveWindow = [=](auto callback) {
|
||||
if (const auto window = Core::App().activePrimaryWindow()) {
|
||||
if (const auto menu = weakMenu.data()) {
|
||||
if (const auto menu = weakMenu.get()) {
|
||||
menu->discardParentReActivate();
|
||||
|
||||
// We must hide PopupMenu before we activate the MainWindow,
|
||||
// otherwise we set focus in field inside MainWindow and then
|
||||
// PopupMenu::hide activates back the group call panel :(
|
||||
delete weakMenu;
|
||||
delete weakMenu.get();
|
||||
}
|
||||
window->invokeForSessionController(
|
||||
account,
|
||||
|
@ -407,7 +407,7 @@ void Panel::startScheduledNow() {
|
||||
} else if (now + kStartNoConfirmation >= date) {
|
||||
_call->startScheduledNow();
|
||||
} else {
|
||||
const auto box = std::make_shared<QPointer<Ui::GenericBox>>();
|
||||
const auto box = std::make_shared<base::weak_qptr<Ui::GenericBox>>();
|
||||
const auto done = [=] {
|
||||
if (*box) {
|
||||
(*box)->closeBox();
|
||||
@ -1377,7 +1377,7 @@ void Panel::chooseShareScreenSource() {
|
||||
tr::now,
|
||||
lt_user,
|
||||
screencastFromPeer->shortName());
|
||||
const auto shared = std::make_shared<QPointer<Ui::GenericBox>>();
|
||||
const auto shared = std::make_shared<base::weak_qptr<Ui::GenericBox>>();
|
||||
const auto done = [=] {
|
||||
if (*shared) {
|
||||
base::take(*shared)->closeBox();
|
||||
@ -2072,9 +2072,9 @@ void Panel::showNiceTooltip(
|
||||
? st::groupCallStickedTooltip
|
||||
: st::groupCallNiceTooltip));
|
||||
const auto tooltip = _niceTooltip.data();
|
||||
const auto weak = QPointer<QWidget>(tooltip);
|
||||
const auto weak = base::make_weak(tooltip);
|
||||
const auto destroy = [=] {
|
||||
delete weak.data();
|
||||
delete weak.get();
|
||||
};
|
||||
if (type != NiceTooltipType::Sticked) {
|
||||
tooltip->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
@ -2098,9 +2098,9 @@ void Panel::updateTooltipGeometry() {
|
||||
return;
|
||||
}
|
||||
const auto geometry = _niceTooltipControl->geometry();
|
||||
const auto weak = QPointer<QWidget>(_niceTooltip);
|
||||
const auto weak = base::make_weak(_niceTooltip);
|
||||
const auto countPosition = [=](QSize size) {
|
||||
const auto strong = weak.data();
|
||||
const auto strong = weak.get();
|
||||
const auto wide = (_mode.current() == PanelMode::Wide);
|
||||
const auto top = geometry.y()
|
||||
- (wide ? st::groupCallNiceTooltipTop : 0)
|
||||
|
@ -133,7 +133,7 @@ void StartRtmpProcess::start(
|
||||
void StartRtmpProcess::close() {
|
||||
if (_request) {
|
||||
_request->peer->session().api().request(_request->id).cancel();
|
||||
if (const auto strong = _request->box.data()) {
|
||||
if (const auto strong = _request->box.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
_request = nullptr;
|
||||
@ -199,7 +199,7 @@ void StartRtmpProcess::createBox() {
|
||||
) | rpl::start_with_next([=] {
|
||||
_request = nullptr;
|
||||
}, _request->lifetime);
|
||||
_request->box = Ui::MakeWeak(object.data());
|
||||
_request->box = base::make_weak(object.data());
|
||||
_request->show->showBox(std::move(object));
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ private:
|
||||
std::shared_ptr<Ui::Show> show;
|
||||
Fn<void(JoinInfo)> done;
|
||||
base::has_weak_ptr guard;
|
||||
QPointer<Ui::BoxContent> box;
|
||||
base::weak_qptr<Ui::BoxContent> box;
|
||||
rpl::lifetime lifetime;
|
||||
mtpRequestId id = 0;
|
||||
};
|
||||
|
@ -110,7 +110,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
|
||||
const QString &linkListener,
|
||||
std::shared_ptr<Ui::Show> show) {
|
||||
const auto sending = std::make_shared<bool>();
|
||||
const auto box = std::make_shared<QPointer<ShareBox>>();
|
||||
const auto box = std::make_shared<base::weak_qptr<ShareBox>>();
|
||||
|
||||
auto bottom = linkSpeaker.isEmpty()
|
||||
? nullptr
|
||||
@ -220,7 +220,7 @@ void SettingsBox(
|
||||
using namespace Settings;
|
||||
|
||||
const auto weakCall = base::make_weak(call);
|
||||
const auto weakBox = Ui::MakeWeak(box);
|
||||
const auto weakBox = base::make_weak(box);
|
||||
|
||||
struct State {
|
||||
std::unique_ptr<Webrtc::DeviceResolver> deviceId;
|
||||
|
@ -351,18 +351,18 @@ void ChooseSourceProcess::setupPanel() {
|
||||
if (_selectedId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
const auto weak = MakeWeak(_window.get());
|
||||
const auto weak = base::make_weak(_window.get());
|
||||
_delegate->chooseSourceAccepted(
|
||||
_selectedId,
|
||||
!_withAudio->isHidden() && _withAudio->checked());
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->close();
|
||||
}
|
||||
});
|
||||
_finish->setClickedCallback([=] {
|
||||
const auto weak = MakeWeak(_window.get());
|
||||
const auto weak = base::make_weak(_window.get());
|
||||
_delegate->chooseSourceStop();
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->close();
|
||||
}
|
||||
});
|
||||
|
@ -173,7 +173,7 @@ Loader::Loader(
|
||||
|
||||
void Loader::unpack(const QString &path) {
|
||||
const auto folder = internal::SetDataPath(id());
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
crl::async([=] {
|
||||
if (UnpackSet(path, folder)) {
|
||||
QFile(path).remove();
|
||||
|
@ -984,7 +984,7 @@ void SuggestionsController::replaceCurrent(
|
||||
const auto position = cursor.position();
|
||||
const auto suggestion = getEmojiQuery();
|
||||
if (v::is<EmojiPtr>(suggestion)) {
|
||||
const auto weak = Ui::MakeWeak(_container.get());
|
||||
const auto weak = base::make_weak(_container.get());
|
||||
const auto count = std::max(_emojiQueryLength, 1);
|
||||
for (auto i = 0; i != count; ++i) {
|
||||
const auto start = position - count + i;
|
||||
|
@ -202,7 +202,7 @@ void EditLinkBox(
|
||||
url->showError();
|
||||
return;
|
||||
}
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
callback(linkText, linkUrl);
|
||||
if (weak) {
|
||||
box->closeBox();
|
||||
@ -304,9 +304,9 @@ void EditCodeLanguageBox(
|
||||
const auto name = field->getLastText().trimmed();
|
||||
const auto check = QRegularExpression("^[a-zA-Z0-9\\+\\-]*$");
|
||||
if (check.match(name).hasMatch()) {
|
||||
auto weak = Ui::MakeWeak(box);
|
||||
auto weak = base::make_weak(box);
|
||||
save(name);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
} else {
|
||||
@ -401,7 +401,7 @@ Fn<bool(
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
not_null<Ui::InputField*> field,
|
||||
const style::InputField *fieldStyle) {
|
||||
const auto weak = Ui::MakeWeak(field);
|
||||
const auto weak = base::make_weak(field);
|
||||
return [=](
|
||||
EditLinkSelection selection,
|
||||
TextWithTags text,
|
||||
@ -412,7 +412,7 @@ Fn<bool(
|
||||
&& !TextUtilities::IsMentionLink(link);
|
||||
}
|
||||
auto callback = [=](const TextWithTags &text, const QString &link) {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->commitMarkdownLinkEdit(selection, text, link);
|
||||
}
|
||||
};
|
||||
@ -484,7 +484,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
|
||||
EditLinkAction action)> FactcheckEditLinkCallback(
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
not_null<Ui::InputField*> field) {
|
||||
const auto weak = Ui::MakeWeak(field);
|
||||
const auto weak = base::make_weak(field);
|
||||
return [=](
|
||||
EditLinkSelection selection,
|
||||
TextWithTags text,
|
||||
@ -503,7 +503,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
|
||||
return IsGoodFactcheckUrl(link);
|
||||
}
|
||||
auto callback = [=](const TextWithTags &text, const QString &link) {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->commitMarkdownLinkEdit(selection, text, link);
|
||||
}
|
||||
};
|
||||
@ -696,9 +696,9 @@ void InitMessageFieldFade(
|
||||
bottomFade->move(
|
||||
0,
|
||||
size.height() - st::historyComposeFieldFadeHeight);
|
||||
}, [t = Ui::MakeWeak(topFade), b = Ui::MakeWeak(bottomFade)] {
|
||||
Ui::DestroyChild(t.data());
|
||||
Ui::DestroyChild(b.data());
|
||||
}, [t = base::make_weak(topFade), b = base::make_weak(bottomFade)] {
|
||||
Ui::DestroyChild(t.get());
|
||||
Ui::DestroyChild(b.get());
|
||||
}, topFade->lifetime());
|
||||
|
||||
const auto descent = field->st().style.font->descent;
|
||||
|
@ -1736,8 +1736,8 @@ void StickersListWidget::showStickerSetBox(
|
||||
base::timer_once(kTimeout),
|
||||
document->owner().stickers().updated(
|
||||
Data::StickersType::Stickers)
|
||||
) | rpl::start_with_next([=, weak = Ui::MakeWeak(this)] {
|
||||
if (weak.data()) {
|
||||
) | rpl::start_with_next([=, weak = base::make_weak(this)] {
|
||||
if (weak.get()) {
|
||||
showStickerSetBox(document, setId);
|
||||
}
|
||||
lifetime->destroy();
|
||||
|
@ -1471,13 +1471,13 @@ void TabbedSelector::Inner::disableScroll(bool disabled) {
|
||||
|
||||
void TabbedSelector::Inner::checkHideWithBox(
|
||||
object_ptr<Ui::BoxContent> box) {
|
||||
const auto raw = QPointer<Ui::BoxContent>(box.data());
|
||||
const auto raw = base::make_weak(box.data());
|
||||
_show->showBox(std::move(box));
|
||||
if (!raw) {
|
||||
return;
|
||||
}
|
||||
_preventHideWithBox = true;
|
||||
connect(raw, &QObject::destroyed, this, [=] {
|
||||
connect(raw.get(), &QObject::destroyed, this, [=] {
|
||||
_preventHideWithBox = false;
|
||||
_checkForHide.fire({});
|
||||
});
|
||||
|
@ -902,7 +902,7 @@ void Application::forceLogOut(
|
||||
box->setCloseByEscape(false);
|
||||
box->setCloseByOutsideClick(false);
|
||||
const auto weak = base::make_weak(account);
|
||||
connect(box, &QObject::destroyed, [=] {
|
||||
connect(box.get(), &QObject::destroyed, [=] {
|
||||
crl::on_main(weak, [=] {
|
||||
account->forcedLogOut();
|
||||
});
|
||||
@ -1669,7 +1669,7 @@ void Application::registerLeaveSubscription(not_null<QWidget*> widget) {
|
||||
if (e->type() == QEvent::Leave) {
|
||||
if (const auto taken = _leaveFilters.take(window)) {
|
||||
for (const auto &weak : taken->registered) {
|
||||
if (const auto widget = weak.data()) {
|
||||
if (const auto widget = weak.get()) {
|
||||
QEvent ev(QEvent::Leave);
|
||||
QCoreApplication::sendEvent(widget, &ev);
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ private:
|
||||
const std::unique_ptr<Lang::CloudManager> _langCloudManager;
|
||||
const std::unique_ptr<ChatHelpers::EmojiKeywords> _emojiKeywords;
|
||||
std::unique_ptr<Lang::Translator> _translator;
|
||||
QPointer<Ui::BoxContent> _badProxyDisableBox;
|
||||
base::weak_qptr<Ui::BoxContent> _badProxyDisableBox;
|
||||
|
||||
const std::unique_ptr<Tray> _tray;
|
||||
|
||||
|
@ -340,7 +340,7 @@ void PhoneClickHandler::onClick(ClickContext context) const {
|
||||
if (Trim(phone) != Trim(controller->session().user()->phone())) {
|
||||
menu->addAction(
|
||||
tr::lng_info_add_as_contact(tr::now),
|
||||
[=, raw = Ui::MakeWeak(resolvePhoneAction.get())] {
|
||||
[=, raw = base::make_weak(resolvePhoneAction.get())] {
|
||||
controller->show(
|
||||
Box<AddContactBox>(
|
||||
&controller->session(),
|
||||
|
@ -57,7 +57,7 @@ void ConfirmDontWarnBox(
|
||||
std::move(check),
|
||||
false,
|
||||
st::defaultBoxCheckbox);
|
||||
const auto weak = Ui::MakeWeak(checkbox.data());
|
||||
const auto weak = base::make_weak(checkbox.data());
|
||||
auto confirmed = crl::guard(weak, [=, callback = std::move(callback)] {
|
||||
const auto checked = weak->checked();
|
||||
box->closeBox();
|
||||
|
@ -1008,7 +1008,7 @@ private:
|
||||
Storage::DatabasePointer _bigFileCache;
|
||||
|
||||
TimeId _exportAvailableAt = 0;
|
||||
QPointer<Ui::BoxContent> _exportSuggestion;
|
||||
base::weak_qptr<Ui::BoxContent> _exportSuggestion;
|
||||
|
||||
rpl::variable<bool> _contactsLoaded = false;
|
||||
rpl::variable<int> _groupFreeTranscribeLevel;
|
||||
|
@ -1966,9 +1966,9 @@ void InnerWidget::mousePressEvent(QMouseEvent *e) {
|
||||
});
|
||||
} else if (_pressed) {
|
||||
auto row = _pressed;
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto updateCallback = [weak, row] {
|
||||
const auto strong = weak.data();
|
||||
const auto strong = weak.get();
|
||||
if (!strong || !strong->_pinnedShiftAnimation.animating()) {
|
||||
row->entry()->updateChatListEntry();
|
||||
}
|
||||
|
@ -1010,7 +1010,7 @@ void Widget::setGeometryWithTopMoved(
|
||||
_topDelta = topDelta;
|
||||
bool willBeResized = (size() != newGeometry.size());
|
||||
if (geometry() != newGeometry) {
|
||||
auto weak = Ui::MakeWeak(this);
|
||||
auto weak = base::make_weak(this);
|
||||
setGeometry(newGeometry);
|
||||
if (!weak) {
|
||||
return;
|
||||
|
@ -1452,7 +1452,7 @@ void Suggestions::setupChats() {
|
||||
|
||||
_topPeers->showMenuRequests(
|
||||
) | rpl::start_with_next([=](const ShowTopPeerMenuRequest &request) {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto owner = &_controller->session().data();
|
||||
const auto peer = owner->peer(PeerId(request.id));
|
||||
const auto removeOne = [=] {
|
||||
|
@ -157,12 +157,12 @@ void LayerWidget::checkCacheBackground() {
|
||||
|
||||
void LayerWidget::cacheBackground() {
|
||||
_backgroundCaching = true;
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto night = IsNightMode();
|
||||
crl::async([weak, night, image = renderBackground()]() mutable {
|
||||
auto result = ProcessBackground(image, night);
|
||||
crl::on_main([weak, night, result = std::move(result)]() mutable {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->backgroundReady(std::move(result), night);
|
||||
}
|
||||
});
|
||||
|
@ -228,12 +228,12 @@ void InitEditorLayer(
|
||||
layer->closeLayer();
|
||||
}, editor->lifetime());
|
||||
|
||||
const auto weak = Ui::MakeWeak(layer.get());
|
||||
const auto weak = base::make_weak(layer.get());
|
||||
editor->doneRequests(
|
||||
) | rpl::start_with_next([=, done = std::move(doneCallback)](
|
||||
const PhotoModifications &mods) {
|
||||
done(mods);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeLayer();
|
||||
}
|
||||
}, editor->lifetime());
|
||||
|
@ -404,7 +404,9 @@ auto ApiWrap::fileRequest(const Data::FileLocation &location, int64 offset) {
|
||||
}).toDC(MTP::ShiftDcId(location.dcId, MTP::kExportMediaDcShift)));
|
||||
}
|
||||
|
||||
ApiWrap::ApiWrap(QPointer<MTP::Instance> weak, Fn<void(FnMut<void()>)> runner)
|
||||
ApiWrap::ApiWrap(
|
||||
base::weak_qptr<MTP::Instance> weak,
|
||||
Fn<void(FnMut<void()>)> runner)
|
||||
: _mtp(weak, std::move(runner))
|
||||
, _fileCache(std::make_unique<LoadedFileCache>(kLocationCacheSize)) {
|
||||
}
|
||||
|
@ -40,7 +40,9 @@ struct Settings;
|
||||
|
||||
class ApiWrap {
|
||||
public:
|
||||
ApiWrap(QPointer<MTP::Instance> weak, Fn<void(FnMut<void()>)> runner);
|
||||
ApiWrap(
|
||||
base::weak_qptr<MTP::Instance> weak,
|
||||
Fn<void(FnMut<void()>)> runner);
|
||||
|
||||
rpl::producer<MTP::Error> errors() const;
|
||||
rpl::producer<Output::Result> ioErrors() const;
|
||||
|
@ -96,11 +96,11 @@ Environment PrepareEnvironment(not_null<Main::Session*> session) {
|
||||
return result;
|
||||
}
|
||||
|
||||
QPointer<Ui::BoxContent> SuggestStart(not_null<Main::Session*> session) {
|
||||
base::weak_qptr<Ui::BoxContent> SuggestStart(not_null<Main::Session*> session) {
|
||||
ClearSuggestStart(session);
|
||||
return Ui::show(
|
||||
Box<SuggestBox>(session),
|
||||
Ui::LayerOption::KeepOther).data();
|
||||
Ui::LayerOption::KeepOther).get();
|
||||
}
|
||||
|
||||
void ClearSuggestStart(not_null<Main::Session*> session) {
|
||||
@ -277,7 +277,7 @@ void PanelController::showCriticalError(const QString &text) {
|
||||
|
||||
void PanelController::showError(const QString &text) {
|
||||
auto box = Ui::MakeInformBox(text);
|
||||
const auto weak = Ui::MakeWeak(box.data());
|
||||
const auto weak = base::make_weak(box.data());
|
||||
const auto hidden = _panel->isHidden();
|
||||
_panel->showBox(
|
||||
std::move(box),
|
||||
|
@ -24,7 +24,7 @@ class Session;
|
||||
namespace Export {
|
||||
namespace View {
|
||||
|
||||
QPointer<Ui::BoxContent> SuggestStart(not_null<Main::Session*> session);
|
||||
base::weak_qptr<Ui::BoxContent> SuggestStart(not_null<Main::Session*> session);
|
||||
void ClearSuggestStart(not_null<Main::Session*> session);
|
||||
bool IsDefaultPath(not_null<Main::Session*> session, const QString &path);
|
||||
void ResolveSettings(not_null<Main::Session*> session, Settings &settings);
|
||||
@ -79,7 +79,7 @@ private:
|
||||
base::unique_qptr<Ui::SeparatePanel> _panel;
|
||||
|
||||
State _state;
|
||||
QPointer<Ui::BoxContent> _confirmStopBox;
|
||||
base::weak_qptr<Ui::BoxContent> _confirmStopBox;
|
||||
rpl::event_stream<rpl::producer<>> _panelCloseEvents;
|
||||
bool _stopRequested = false;
|
||||
rpl::lifetime _lifetime;
|
||||
|
@ -51,8 +51,8 @@ private:
|
||||
void hideCurrentInstance();
|
||||
void setInstanceProgress(Instance &instance, float64 progress);
|
||||
void toggleInstance(Instance &data, bool shown);
|
||||
void instanceOpacityCallback(QPointer<Ui::FlatLabel> label);
|
||||
void removeOldInstance(QPointer<Ui::FlatLabel> label);
|
||||
void instanceOpacityCallback(base::weak_qptr<Ui::FlatLabel> label);
|
||||
void removeOldInstance(base::weak_qptr<Ui::FlatLabel> label);
|
||||
void paintInstance(QPainter &p, const Instance &data);
|
||||
|
||||
void updateControlsGeometry(int newWidth);
|
||||
@ -146,7 +146,7 @@ void ProgressWidget::Row::toggleInstance(Instance &instance, bool shown) {
|
||||
if (instance.hiding != shown) {
|
||||
return;
|
||||
}
|
||||
const auto label = Ui::MakeWeak(instance.label->entity());
|
||||
const auto label = base::make_weak(instance.label->entity());
|
||||
instance.opacity.start(
|
||||
[=] { instanceOpacityCallback(label); },
|
||||
shown ? 0. : 1.,
|
||||
@ -158,10 +158,10 @@ void ProgressWidget::Row::toggleInstance(Instance &instance, bool shown) {
|
||||
}
|
||||
|
||||
void ProgressWidget::Row::instanceOpacityCallback(
|
||||
QPointer<Ui::FlatLabel> label) {
|
||||
base::weak_qptr<Ui::FlatLabel> label) {
|
||||
update();
|
||||
const auto i = ranges::find(_old, label, [](const Instance &instance) {
|
||||
return Ui::MakeWeak(instance.label->entity());
|
||||
return base::make_weak(instance.label->entity());
|
||||
});
|
||||
if (i != end(_old) && i->hiding && !i->opacity.animating()) {
|
||||
crl::on_main(this, [=] {
|
||||
@ -170,9 +170,10 @@ void ProgressWidget::Row::instanceOpacityCallback(
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressWidget::Row::removeOldInstance(QPointer<Ui::FlatLabel> label) {
|
||||
void ProgressWidget::Row::removeOldInstance(
|
||||
base::weak_qptr<Ui::FlatLabel> label) {
|
||||
const auto i = ranges::find(_old, label, [](const Instance &instance) {
|
||||
return Ui::MakeWeak(instance.label->entity());
|
||||
return base::make_weak(instance.label->entity());
|
||||
});
|
||||
if (i != end(_old)) {
|
||||
_old.erase(i);
|
||||
|
@ -320,20 +320,20 @@ void SettingsWidget::addLocationLabel(
|
||||
}
|
||||
|
||||
void SettingsWidget::chooseFormat() {
|
||||
const auto shared = std::make_shared<QPointer<Ui::GenericBox>>();
|
||||
const auto shared = std::make_shared<base::weak_qptr<Ui::GenericBox>>();
|
||||
const auto callback = [=](Format format) {
|
||||
changeData([&](Settings &data) {
|
||||
data.format = format;
|
||||
});
|
||||
if (const auto weak = shared->data()) {
|
||||
weak->closeBox();
|
||||
if (const auto strong = shared->get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
auto box = Box(
|
||||
ChooseFormatBox,
|
||||
readData().format,
|
||||
callback);
|
||||
*shared = Ui::MakeWeak(box.data());
|
||||
*shared = base::make_weak(box.data());
|
||||
_showBoxCallback(std::move(box));
|
||||
}
|
||||
|
||||
@ -602,18 +602,18 @@ void SettingsWidget::editDateLimit(
|
||||
? base::unixtime::parse(min).date()
|
||||
: QDate::currentDate();
|
||||
const auto month = highlighted;
|
||||
const auto shared = std::make_shared<QPointer<Ui::CalendarBox>>();
|
||||
const auto shared = std::make_shared<base::weak_qptr<Ui::CalendarBox>>();
|
||||
const auto finalize = [=](not_null<Ui::CalendarBox*> box) {
|
||||
box->addLeftButton(std::move(resetLabel), crl::guard(this, [=] {
|
||||
done(0);
|
||||
if (const auto weak = shared->data()) {
|
||||
if (const auto weak = shared->get()) {
|
||||
weak->closeBox();
|
||||
}
|
||||
}));
|
||||
};
|
||||
const auto callback = crl::guard(this, [=](const QDate &date) {
|
||||
done(base::unixtime::serialize(date.startOfDay()));
|
||||
if (const auto weak = shared->data()) {
|
||||
if (const auto weak = shared->get()) {
|
||||
weak->closeBox();
|
||||
}
|
||||
});
|
||||
@ -630,7 +630,7 @@ void SettingsWidget::editDateLimit(
|
||||
? base::unixtime::parse(max).date()
|
||||
: QDate::currentDate()),
|
||||
});
|
||||
*shared = Ui::MakeWeak(box.data());
|
||||
*shared = base::make_weak(box.data());
|
||||
_showBoxCallback(std::move(box));
|
||||
}
|
||||
|
||||
|
@ -1530,7 +1530,7 @@ void InnerWidget::suggestRestrictParticipant(
|
||||
UserData *by,
|
||||
TimeId since) {
|
||||
auto weak = QPointer<InnerWidget>(this);
|
||||
auto weakBox = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
auto weakBox = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
auto box = Box<EditRestrictedBox>(
|
||||
_channel,
|
||||
user,
|
||||
@ -1560,7 +1560,7 @@ void InnerWidget::suggestRestrictParticipant(
|
||||
tr::now,
|
||||
lt_user,
|
||||
participant->name());
|
||||
auto weakBox = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
auto weakBox = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto sure = crl::guard(this, [=] {
|
||||
restrictParticipant(
|
||||
participant,
|
||||
@ -1810,10 +1810,8 @@ void InnerWidget::mouseActionFinish(const QPoint &screenPos, Qt::MouseButton but
|
||||
ActivateClickHandler(window(), activated, {
|
||||
button,
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.elementDelegate = [weak = Ui::MakeWeak(this)] {
|
||||
return weak
|
||||
? (ElementDelegate*)weak
|
||||
: nullptr;
|
||||
.elementDelegate = [weak = base::make_weak(this)] {
|
||||
return (ElementDelegate*)weak.get();
|
||||
},
|
||||
.sessionWindow = base::make_weak(_controller),
|
||||
})
|
||||
|
@ -1671,7 +1671,7 @@ void HistoryInner::touchEvent(QTouchEvent *e) {
|
||||
_touchInProgress = false;
|
||||
const auto notMoved = (_touchPos - _touchStart).manhattanLength()
|
||||
< QApplication::startDragDistance();
|
||||
auto weak = Ui::MakeWeak(this);
|
||||
auto weak = base::make_weak(this);
|
||||
if (_touchSelect) {
|
||||
if (notMoved || _touchMaybeSelecting.current()) {
|
||||
mouseActionFinish(_touchPos, Qt::RightButton);
|
||||
|
@ -356,7 +356,7 @@ void ShowSendPaidConfirm(
|
||||
const auto messages = details.messages;
|
||||
const auto stars = details.stars;
|
||||
show->showBox(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
const auto trust = std::make_shared<QPointer<Ui::Checkbox>>();
|
||||
const auto trust = std::make_shared<base::weak_qptr<Ui::Checkbox>>();
|
||||
const auto proceed = [=](Fn<void()> close) {
|
||||
if (singlePeer && (*trust)->checked()) {
|
||||
const auto session = &singlePeer->session();
|
||||
|
@ -1024,7 +1024,7 @@ void HistoryWidget::setGeometryWithTopMoved(
|
||||
_topDelta = topDelta;
|
||||
bool willBeResized = (size() != newGeometry.size());
|
||||
if (geometry() != newGeometry) {
|
||||
auto weak = Ui::MakeWeak(this);
|
||||
auto weak = base::make_weak(this);
|
||||
setGeometry(newGeometry);
|
||||
if (!weak) {
|
||||
return;
|
||||
@ -4494,7 +4494,7 @@ void HistoryWidget::saveEditMessage(Api::SendOptions options) {
|
||||
}
|
||||
}
|
||||
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto history = _history;
|
||||
|
||||
const auto done = [=](mtpRequestId requestId) {
|
||||
@ -5603,7 +5603,7 @@ bool HistoryWidget::searchInChatEmbedded(
|
||||
if (!peer || Window::SeparateId(peer) != controller()->windowId()) {
|
||||
return false;
|
||||
} else if (_peer != peer) {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
controller()->showPeerHistory(peer);
|
||||
if (!weak) {
|
||||
return false;
|
||||
@ -9054,9 +9054,9 @@ void HistoryWidget::forwardSelected() {
|
||||
if (!_list) {
|
||||
return;
|
||||
}
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
Window::ShowForwardMessagesBox(controller(), getSelectedItems(), [=] {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->clearSelected();
|
||||
}
|
||||
});
|
||||
|
@ -256,9 +256,9 @@ List CreateList(
|
||||
}, list.container->lifetime());
|
||||
|
||||
list.container->paintRequest(
|
||||
) | rpl::start_with_next([weak = Ui::MakeWeak(list.container.get())](
|
||||
) | rpl::start_with_next([weak = base::make_weak(list.container.get())](
|
||||
const QRect &r) {
|
||||
auto p = QPainter(weak);
|
||||
auto p = QPainter(weak.get());
|
||||
p.fillRect(r, st::dialogsBg);
|
||||
}, list.container->lifetime());
|
||||
|
||||
@ -937,7 +937,7 @@ ComposeSearch::Inner::Inner(
|
||||
_apiSearch.newFounds(
|
||||
) | rpl::start_with_next([=] {
|
||||
const auto &apiData = _apiSearch.messages();
|
||||
const auto weak = Ui::MakeWeak(_bottomBar.get());
|
||||
const auto weak = base::make_weak(_bottomBar.get());
|
||||
_bottomBar->setTotal(apiData.total);
|
||||
if (weak) {
|
||||
// Activating the first search result may switch the chat.
|
||||
@ -970,7 +970,7 @@ ComposeSearch::Inner::Inner(
|
||||
_pendingJump.data = {};
|
||||
const auto item = _history->owner().message(messages[index]);
|
||||
if (item) {
|
||||
const auto weak = Ui::MakeWeak(_topBar.get());
|
||||
const auto weak = base::make_weak(_topBar.get());
|
||||
_activations.fire_copy({ item, _apiSearch.request().query });
|
||||
if (weak) {
|
||||
hideList();
|
||||
|
@ -819,7 +819,7 @@ void DraftOptionsBox(
|
||||
FullReplyTo result,
|
||||
Data::WebPageDraft webpage,
|
||||
std::optional<Data::ForwardOptions> options) {
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
auto forward = Data::ForwardDraft();
|
||||
if (options) {
|
||||
forward.options = *options;
|
||||
@ -828,7 +828,7 @@ void DraftOptionsBox(
|
||||
}
|
||||
}
|
||||
done(std::move(result), std::move(webpage), std::move(forward));
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -847,7 +847,7 @@ void DraftOptionsBox(
|
||||
});
|
||||
}
|
||||
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
Settings::AddButtonWithIcon(
|
||||
bottom,
|
||||
tr::lng_reply_show_in_chat(),
|
||||
@ -855,7 +855,7 @@ void DraftOptionsBox(
|
||||
{ &st::menuIconShowInChat }
|
||||
)->setClickedCallback([=] {
|
||||
highlight(resolveReply());
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
});
|
||||
@ -1402,10 +1402,10 @@ void ShowReplyToChatBox(
|
||||
};
|
||||
auto callback = [=, chosen = std::move(chosen)](
|
||||
Controller::Chosen thread) mutable {
|
||||
const auto weak = Ui::MakeWeak(state->box);
|
||||
const auto weak = base::make_weak(state->box);
|
||||
if (!chosen(thread)) {
|
||||
return;
|
||||
} else if (const auto strong = weak.data()) {
|
||||
} else if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
|
@ -434,11 +434,11 @@ void EditWebPageOptions(
|
||||
});
|
||||
|
||||
box->addButton(tr::lng_settings_save(), [=] {
|
||||
const auto weak = Ui::MakeWeak(box.get());
|
||||
const auto weak = base::make_weak(box.get());
|
||||
auto result = state->result.current();
|
||||
result.manual = true;
|
||||
done(result);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
});
|
||||
|
@ -484,13 +484,13 @@ void ChooseSuggestPriceBox(
|
||||
st::settingsButtonNoIcon);
|
||||
|
||||
time->setClickedCallback([=] {
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto parentWeak = Ui::MakeWeak(box);
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto parentWeak = base::make_weak(box);
|
||||
const auto done = [=](TimeId result) {
|
||||
if (parentWeak) {
|
||||
state->date = result;
|
||||
}
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -793,12 +793,12 @@ void SuggestOptions::paintLines(QPainter &p, int x, int y, int outerWidth) {
|
||||
}
|
||||
|
||||
void SuggestOptions::edit() {
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
|
||||
const auto apply = [=](SuggestPostOptions values) {
|
||||
_values = values;
|
||||
updateTexts();
|
||||
_updates.fire({});
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
|
@ -2082,7 +2082,7 @@ void VoiceRecordBar::stopRecording(StopType type, bool ttlBeforeHide) {
|
||||
}
|
||||
} else if (type == StopType::Send) {
|
||||
if (_videoRecorder) {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
_videoRecorder->hide([=](Ui::RoundVideoResult data) {
|
||||
crl::on_main([=, data = std::move(data)]() mutable {
|
||||
if (weak) {
|
||||
|
@ -941,9 +941,9 @@ ChatPreview MakeChatPreview(
|
||||
result.actions = action->actions();
|
||||
menu->addAction(std::move(action));
|
||||
if (const auto topic = thread->asTopic()) {
|
||||
const auto weak = Ui::MakeWeak(menu);
|
||||
const auto weak = base::make_weak(menu);
|
||||
topic->destroyed() | rpl::start_with_next([weak] {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
LOG(("Preview hidden for a destroyed topic."));
|
||||
strong->hideMenu(true);
|
||||
}
|
||||
|
@ -2315,9 +2315,9 @@ bool ChatWidget::preventsClose(Fn<void()> &&continueCallback) const {
|
||||
} else if (!_newTopicDiscarded
|
||||
&& _topic
|
||||
&& _topic->creating()) {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
auto sure = [=](Fn<void()> &&close) {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->_newTopicDiscarded = true;
|
||||
}
|
||||
close();
|
||||
@ -2602,7 +2602,7 @@ void ChatWidget::subscribeToSublist() {
|
||||
void ChatWidget::unreadCountUpdated() {
|
||||
if (_sublist && _sublist->unreadMark()) {
|
||||
crl::on_main(this, [=] {
|
||||
const auto guard = Ui::MakeWeak(this);
|
||||
const auto guard = base::make_weak(this);
|
||||
controller()->showPeerHistory(_sublist->owningHistory());
|
||||
if (guard) {
|
||||
closeCurrent();
|
||||
|
@ -947,8 +947,8 @@ void BusinessBotStatus::Bar::showMenu() {
|
||||
this,
|
||||
st::popupMenuExpandedSeparator);
|
||||
_menu->setDestroyedCallback([
|
||||
weak = Ui::MakeWeak(this),
|
||||
weakButton = Ui::MakeWeak(_settings.data()),
|
||||
weak = base::make_weak(this),
|
||||
weakButton = base::make_weak(_settings.data()),
|
||||
menu = _menu.get()] {
|
||||
if (weak && weak->_menu == menu) {
|
||||
if (weakButton) {
|
||||
|
@ -287,9 +287,9 @@ void AddDocumentActions(
|
||||
item->history()->peer,
|
||||
document);
|
||||
if (notAutoplayedGif) {
|
||||
const auto weak = Ui::MakeWeak(list.get());
|
||||
const auto weak = base::make_weak(list.get());
|
||||
menu->addAction(tr::lng_context_open_gif(tr::now), [=] {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
OpenGif(strong, contextId);
|
||||
}
|
||||
}, &st::menuIconShowInChat);
|
||||
@ -390,9 +390,9 @@ bool AddForwardSelectedAction(
|
||||
}
|
||||
|
||||
menu->addAction(tr::lng_context_forward_selected(tr::now), [=] {
|
||||
const auto weak = Ui::MakeWeak(list);
|
||||
const auto weak = base::make_weak(list);
|
||||
const auto callback = [=] {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->cancelSelection();
|
||||
}
|
||||
};
|
||||
@ -471,7 +471,7 @@ bool AddSendNowSelectedAction(
|
||||
const auto history = *histories.begin();
|
||||
|
||||
menu->addAction(tr::lng_context_send_now_selected(tr::now), [=] {
|
||||
const auto weak = Ui::MakeWeak(list);
|
||||
const auto weak = base::make_weak(list);
|
||||
const auto callback = [=] {
|
||||
request.navigation->showBackFromStack();
|
||||
};
|
||||
@ -1149,9 +1149,9 @@ void EditTagBox(
|
||||
field->showError();
|
||||
return;
|
||||
}
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
const auto weak = base::make_weak(box);
|
||||
controller->session().data().reactions().renameTag(id, text);
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
@ -1629,10 +1629,10 @@ void AddWhoReactedAction(
|
||||
not_null<HistoryItem*> item,
|
||||
not_null<Window::SessionController*> controller) {
|
||||
const auto whoReadIds = std::make_shared<Api::WhoReadList>();
|
||||
const auto weak = Ui::MakeWeak(menu.get());
|
||||
const auto weak = base::make_weak(menu.get());
|
||||
const auto user = item->history()->peer;
|
||||
const auto showOrPremium = [=] {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->hideMenu();
|
||||
}
|
||||
const auto type = Ui::ShowOrPremium::ReadTime;
|
||||
@ -1647,14 +1647,14 @@ void AddWhoReactedAction(
|
||||
};
|
||||
const auto itemId = item->fullId();
|
||||
const auto participantChosen = [=](Ui::WhoReadParticipant who) {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->hideMenu();
|
||||
}
|
||||
ShowWhoReadInfo(controller, itemId, who);
|
||||
};
|
||||
const auto showAllChosen = [=, itemId = item->fullId()]{
|
||||
// Pressing on an item that has a submenu doesn't hide it :(
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->hideMenu();
|
||||
}
|
||||
if (const auto item = controller->session().data().message(itemId)) {
|
||||
|
@ -3123,7 +3123,7 @@ void ListWidget::touchEvent(QTouchEvent *e) {
|
||||
return;
|
||||
}
|
||||
_touchInProgress = false;
|
||||
auto weak = Ui::MakeWeak(this);
|
||||
auto weak = base::make_weak(this);
|
||||
const auto notMoved = (_touchPos - _touchStart).manhattanLength()
|
||||
< QApplication::startDragDistance();
|
||||
if (_touchSelect) {
|
||||
@ -3625,10 +3625,8 @@ void ListWidget::mouseActionFinish(
|
||||
ClickHandlerContext ListWidget::prepareClickHandlerContext(FullMsgId id) {
|
||||
return {
|
||||
.itemId = id,
|
||||
.elementDelegate = [weak = Ui::MakeWeak(this)] {
|
||||
return weak
|
||||
? (ElementDelegate*)weak
|
||||
: nullptr;
|
||||
.elementDelegate = [weak = base::make_weak(this)] {
|
||||
return (ElementDelegate*)weak.get();
|
||||
},
|
||||
.sessionWindow = base::make_weak(controller()),
|
||||
};
|
||||
@ -4347,9 +4345,9 @@ void ConfirmForwardSelectedItems(not_null<ListWidget*> widget) {
|
||||
}
|
||||
}
|
||||
auto ids = widget->getSelectedIds();
|
||||
const auto weak = Ui::MakeWeak(widget);
|
||||
const auto weak = base::make_weak(widget);
|
||||
Window::ShowForwardMessagesBox(widget->controller(), std::move(ids), [=] {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->cancelSelection();
|
||||
}
|
||||
});
|
||||
@ -4378,8 +4376,8 @@ void ConfirmSendNowSelectedItems(not_null<ListWidget*> widget) {
|
||||
if (!history) {
|
||||
return;
|
||||
}
|
||||
const auto clearSelection = [weak = Ui::MakeWeak(widget)] {
|
||||
if (const auto strong = weak.data()) {
|
||||
const auto clearSelection = [weak = base::make_weak(widget)] {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->cancelSelection();
|
||||
}
|
||||
};
|
||||
|
@ -1340,9 +1340,9 @@ void ScheduledWidget::showProcessingVideoTooltip() {
|
||||
st::defaultImportantTooltipLabel),
|
||||
st::defaultImportantTooltip);
|
||||
const auto tooltip = _processingVideoTooltip.get();
|
||||
const auto weak = QPointer<QWidget>(tooltip);
|
||||
const auto weak = base::make_weak(tooltip);
|
||||
const auto destroy = [=] {
|
||||
delete weak.data();
|
||||
delete weak.get();
|
||||
};
|
||||
tooltip->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
tooltip->setHiddenCallback([=] {
|
||||
|
@ -336,8 +336,8 @@ bool TopBarWidget::createMenu(not_null<Ui::IconButton*> button) {
|
||||
this,
|
||||
st::popupMenuExpandedSeparator);
|
||||
_menu->setDestroyedCallback([
|
||||
weak = Ui::MakeWeak(this),
|
||||
weakButton = Ui::MakeWeak(button),
|
||||
weak = base::make_weak(this),
|
||||
weakButton = base::make_weak(button),
|
||||
menu = _menu.get()] {
|
||||
if (weak && weak->_menu == menu) {
|
||||
if (weakButton) {
|
||||
|
@ -409,8 +409,8 @@ base::unique_qptr<Ui::PopupMenu> TranslateBar::createMenu(
|
||||
st::popupMenuExpandedSeparator);
|
||||
result->setDestroyedCallback([
|
||||
this,
|
||||
weak = Ui::MakeWeak(&_wrap),
|
||||
weakButton = Ui::MakeWeak(button),
|
||||
weak = base::make_weak(&_wrap),
|
||||
weakButton = base::make_weak(button),
|
||||
menu = result.get()
|
||||
] {
|
||||
if (weak && _menu == menu) {
|
||||
@ -430,7 +430,7 @@ void TranslateBar::showMenu(base::unique_qptr<Ui::PopupMenu> menu) {
|
||||
_menu = std::move(menu);
|
||||
_menu->setForcedOrigin(Ui::PanelAnimation::Origin::TopRight);
|
||||
|
||||
const auto guard = Ui::MakeWeak(&_wrap);
|
||||
const auto guard = base::make_weak(&_wrap);
|
||||
const auto now = _history->translatedTo();
|
||||
const auto to = now ? now : Ui::ChooseTranslateTo(_history);
|
||||
const auto weak = base::make_weak(_controller);
|
||||
|
@ -549,7 +549,7 @@ object_ptr<Ui::BoxContent> JoinStarRefBox(
|
||||
|
||||
struct State {
|
||||
rpl::variable<not_null<PeerData*>> recipient;
|
||||
QPointer<Ui::GenericBox> weak;
|
||||
base::weak_qptr<Ui::GenericBox> weak;
|
||||
bool sent = false;
|
||||
};
|
||||
const auto state = std::make_shared<State>(State{
|
||||
@ -709,7 +709,7 @@ object_ptr<Ui::BoxContent> JoinStarRefBox(
|
||||
}
|
||||
}
|
||||
show->show(StarRefLinkBox(info, recipient));
|
||||
if (const auto strong = state->weak.data()) {
|
||||
if (const auto strong = state->weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
}, [=](const QString &error) {
|
||||
|
@ -1105,7 +1105,7 @@ std::shared_ptr<Info::Memento> Make(not_null<PeerData*> peer) {
|
||||
object_ptr<Ui::BoxContent> ProgramsListBox(
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<PeerData*> peer) {
|
||||
const auto weak = std::make_shared<QPointer<PeerListBox>>();
|
||||
const auto weak = std::make_shared<base::weak_qptr<PeerListBox>>();
|
||||
const auto initBox = [=](not_null<PeerListBox*> box) {
|
||||
*weak = box;
|
||||
box->addButton(tr::lng_close(), [=] {
|
||||
@ -1118,7 +1118,7 @@ object_ptr<Ui::BoxContent> ProgramsListBox(
|
||||
peer,
|
||||
JoinType::Existing);
|
||||
controller->addForBotRequests() | rpl::start_with_next([=] {
|
||||
if (const auto strong = weak->data()) {
|
||||
if (const auto strong = weak->get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
}, controller->lifetime());
|
||||
|
@ -738,7 +738,7 @@ void InnerWidget::setupEnd() {
|
||||
tr::lng_star_ref_end(),
|
||||
st::settingsAttentionButton));
|
||||
end->setClickedCallback([=] {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto window = _controller->parentController();
|
||||
const auto sent = std::make_shared<bool>();
|
||||
window->show(ConfirmEndBox([=] {
|
||||
@ -751,7 +751,7 @@ void InnerWidget::setupEnd() {
|
||||
*sent = false;
|
||||
if (!success) {
|
||||
return;
|
||||
} else if ([[maybe_unused]] const auto strong = weak.data()) {
|
||||
} else if ([[maybe_unused]] const auto strong = weak.get()) {
|
||||
_controller->showBackFromStack();
|
||||
window->showToast({
|
||||
.title = tr::lng_star_ref_ended_title(tr::now),
|
||||
@ -1013,7 +1013,7 @@ std::unique_ptr<Ui::RpWidget> Widget::setupBottom() {
|
||||
st::boxDividerLabel),
|
||||
QMargins(margins.left(), 0, margins.right(), 0));
|
||||
save->setClickedCallback([=] {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto user = _state->user;
|
||||
const auto program = _state->program;
|
||||
const auto show = controller()->uiShow();
|
||||
|
@ -1459,11 +1459,11 @@ void CreateGiveawayBox(
|
||||
}
|
||||
state->confirmButtonBusy = true;
|
||||
const auto show = box->uiShow();
|
||||
const auto weak = Ui::MakeWeak(box.get());
|
||||
const auto weak = base::make_weak(box.get());
|
||||
const auto done = [=](Payments::CheckoutResult result) {
|
||||
const auto isPaid = result == Payments::CheckoutResult::Paid;
|
||||
if (result == Payments::CheckoutResult::Pending || isPaid) {
|
||||
if (const auto strong = weak.data()) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->window()->setFocus();
|
||||
strong->closeBox();
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user