diff --git a/Telegram/SourceFiles/api/api_bot.cpp b/Telegram/SourceFiles/api/api_bot.cpp index b86ce1a70c..05c0d46928 100644 --- a/Telegram/SourceFiles/api/api_bot.cpp +++ b/Telegram/SourceFiles/api/api_bot.cpp @@ -245,7 +245,7 @@ void SendBotCallbackDataWithPassword( fields.customSubmitButton = tr::lng_passcode_submit(); fields.customCheckCallback = [=]( const Core::CloudPasswordResult &result, - QPointer box) { + base::weak_qptr box) { if (const auto button = getButton()) { if (button->requestId) { return; diff --git a/Telegram/SourceFiles/api/api_chat_filters_remove_manager.cpp b/Telegram/SourceFiles/api/api_chat_filters_remove_manager.cpp index fe96accd61..ffd3fb0f79 100644 --- a/Telegram/SourceFiles/api/api_chat_filters_remove_manager.cpp +++ b/Telegram/SourceFiles/api/api_chat_filters_remove_manager.cpp @@ -57,7 +57,7 @@ void RemoveChatFilter( RemoveComplexChatFilter::RemoveComplexChatFilter() = default; void RemoveComplexChatFilter::request( - QPointer widget, + base::weak_qptr widget, base::weak_ptr weak, FilterId id) { const auto session = &weak->session(); diff --git a/Telegram/SourceFiles/api/api_chat_filters_remove_manager.h b/Telegram/SourceFiles/api/api_chat_filters_remove_manager.h index ce92b2df3c..6bd6ce7fa3 100644 --- a/Telegram/SourceFiles/api/api_chat_filters_remove_manager.h +++ b/Telegram/SourceFiles/api/api_chat_filters_remove_manager.h @@ -22,7 +22,7 @@ public: RemoveComplexChatFilter(); void request( - QPointer widget, + base::weak_qptr widget, base::weak_ptr weak, FilterId id); diff --git a/Telegram/SourceFiles/api/api_chat_invite.cpp b/Telegram/SourceFiles/api/api_chat_invite.cpp index b67e148677..0d5880fcb5 100644 --- a/Telegram/SourceFiles/api/api_chat_invite.cpp +++ b/Telegram/SourceFiles/api/api_chat_invite.cpp @@ -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; } diff --git a/Telegram/SourceFiles/api/api_confirm_phone.cpp b/Telegram/SourceFiles/api/api_confirm_phone.cpp index a3b41fefc9..7379681138 100644 --- a/Telegram/SourceFiles/api/api_confirm_phone.cpp +++ b/Telegram/SourceFiles/api/api_confirm_phone.cpp @@ -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; const auto codeHandles = box->lifetime().make_state(); controller->session().account().setHandleLoginCode([=]( diff --git a/Telegram/SourceFiles/api/api_earn.cpp b/Telegram/SourceFiles/api/api_earn.cpp index 9df407aad2..3b8272fc4e 100644 --- a/Telegram/SourceFiles/api/api_earn.cpp +++ b/Telegram/SourceFiles/api/api_earn.cpp @@ -82,7 +82,7 @@ void HandleWithdrawalButton( fields.customSubmitButton = tr::lng_passcode_submit(); fields.customCheckCallback = crl::guard(button, [=]( const Core::CloudPasswordResult &result, - QPointer box) { + base::weak_qptr box) { const auto done = [=](const QString &result) { if (!result.isEmpty()) { UrlClickHandler::Open(result); diff --git a/Telegram/SourceFiles/api/api_suggest_post.cpp b/Telegram/SourceFiles/api/api_suggest_post.cpp index 7af4fbc84d..05d0304452 100644 --- a/Telegram/SourceFiles/api/api_suggest_post.cpp +++ b/Telegram/SourceFiles/api/api_suggest_post.cpp @@ -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 show, not_null item) { const auto id = item->fullId(); - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); 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(); - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); 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(); - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); 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(); } }; diff --git a/Telegram/SourceFiles/api/api_who_reacted.cpp b/Telegram/SourceFiles/api/api_who_reacted.cpp index 84ab9b0c2c..b3070fba0d 100644 --- a/Telegram/SourceFiles/api/api_who_reacted.cpp +++ b/Telegram/SourceFiles/api/api_who_reacted.cpp @@ -240,13 +240,13 @@ struct State { [[nodiscard]] rpl::producer WhoReadIds( not_null item, not_null context) { - auto weak = QPointer(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 item, const ReactionId &reaction, not_null context) { - auto weak = QPointer(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; diff --git a/Telegram/SourceFiles/boxes/abstract_box.h b/Telegram/SourceFiles/boxes/abstract_box.h index d48e93108f..119875a293 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.h +++ b/Telegram/SourceFiles/boxes/abstract_box.h @@ -37,11 +37,11 @@ void showBox( } // namespace internal template -QPointer show( +base::weak_qptr show( object_ptr content, Ui::LayerOptions options = Ui::LayerOption::CloseOther, anim::type animated = anim::type::normal) { - auto result = QPointer(content.data()); + auto result = base::weak_qptr(content.data()); internal::showBox(std::move(content), options, animated); return result; } diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index 792eff79b4..6e9bc23955 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -194,16 +194,16 @@ void ShowAddParticipantsError( && channel->canAddAdmins()) { const auto makeAdmin = [=](Fn close) { const auto user = forbidden.users.front(); - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); 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(); @@ -716,7 +716,7 @@ TimeId GroupInfoBox::ttlPeriod() const { } void GroupInfoBox::createGroup( - QPointer selectUsersBox, + base::weak_qptr selectUsersBox, const QString &title, const std::vector> &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(_canAddBot) }); } else { - auto initBox = [title, weak = Ui::MakeWeak(this)]( + auto initBox = [title, weak = base::make_weak(this)]( not_null box) { auto create = [box, title, weak] { - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->createGroup( box.get(), title, diff --git a/Telegram/SourceFiles/boxes/add_contact_box.h b/Telegram/SourceFiles/boxes/add_contact_box.h index 9bc7de6520..4032653564 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.h +++ b/Telegram/SourceFiles/boxes/add_contact_box.h @@ -129,7 +129,7 @@ protected: private: void createChannel(const QString &title, const QString &description); void createGroup( - QPointer selectUsersBox, + base::weak_qptr selectUsersBox, const QString &title, const std::vector> &users); void submitName(); diff --git a/Telegram/SourceFiles/boxes/background_box.cpp b/Telegram/SourceFiles/boxes/background_box.cpp index 59729b7fed..f2e2f647b3 100644 --- a/Telegram/SourceFiles/boxes/background_box.cpp +++ b/Telegram/SourceFiles/boxes/background_box.cpp @@ -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 &&close) { + const auto remove = [=, weak = base::make_weak(this)](Fn &&close) { close(); if (weak) { weak->_inner->removePaper(paper); diff --git a/Telegram/SourceFiles/boxes/background_preview_box.cpp b/Telegram/SourceFiles/boxes/background_preview_box.cpp index 0faa677720..0fc02e2efc 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/background_preview_box.cpp @@ -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(); 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(); diff --git a/Telegram/SourceFiles/boxes/delete_messages_box.cpp b/Telegram/SourceFiles/boxes/delete_messages_box.cpp index 5c4b266cd4..503720fc27 100644 --- a/Telegram/SourceFiles/boxes/delete_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/delete_messages_box.cpp @@ -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 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(); } }; diff --git a/Telegram/SourceFiles/boxes/dictionaries_manager.cpp b/Telegram/SourceFiles/boxes/dictionaries_manager.cpp index 72cfd29c0d..8881449fcb 100644 --- a/Telegram/SourceFiles/boxes/dictionaries_manager.cpp +++ b/Telegram/SourceFiles/boxes/dictionaries_manager.cpp @@ -282,7 +282,7 @@ auto AddButtonWithLoader( ) | rpl::start_with_next([=](bool toggled) { const auto &state = buttonState->current(); if (toggled && (v::is(state) || v::is(state))) { - const auto weak = Ui::MakeWeak(button); + const auto weak = base::make_weak(button); setLocalLoader(base::make_unique_q( QCoreApplication::instance(), session, diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index cb27997d66..3e48724b7f 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -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(); } diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index 86816ba15b..2d6f1e2448 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -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()); - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->closeBox(); } }); diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_links.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_links.cpp index 90dd083bd1..acd6da5641 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_links.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_links.cpp @@ -582,7 +582,7 @@ void LinkController::addLinkBlock(not_null 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); }); diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index 96d5f2d332..a235dc2d7a 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -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 session, not_null context, Fn close) { - const auto weak = Ui::MakeWeak(context.get()); + const auto weak = base::make_weak(context.get()); auto lifetime = std::make_shared(); 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( &_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>(); const auto resent = std::make_shared>(); const auto requestId = std::make_shared(0); - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); const auto reloads = std::make_shared>(); const auto cancels = std::make_shared>(); diff --git a/Telegram/SourceFiles/boxes/passcode_box.h b/Telegram/SourceFiles/boxes/passcode_box.h index 09f3335617..5ab6413fc2 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.h +++ b/Telegram/SourceFiles/boxes/passcode_box.h @@ -53,7 +53,7 @@ public: // Check cloud password for some action. using CustomCheck = Fn)>; + base::weak_qptr)>; CustomCheck customCheckCallback; rpl::producer customTitle; std::optional customDescription; @@ -158,7 +158,7 @@ private: QString _pattern; - QPointer _replacedBy; + base::weak_qptr _replacedBy; bool _turningOff = false; bool _cloudPwd = false; CloudFields _cloudFields; diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index 37ab361a8f..0f0a8e0da3 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -831,7 +831,7 @@ void ChooseRecipientBoxController::rowClicked(not_null row) { auto guard = base::make_weak(this); const auto peer = row->peer(); if (const auto forum = peer->forum()) { - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); auto callback = [=](not_null topic) { const auto exists = guard.get(); if (!exists) { @@ -870,7 +870,7 @@ void ChooseRecipientBoxController::rowClicked(not_null row) { delegate()->peerListUiShow()->showBox(std::move(owned)); return; } else if (const auto monoforum = peer->monoforum()) { - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); auto callback = [=](not_null sublist) { const auto exists = guard.get(); if (!exists) { diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index ab05d9bccb..75ccf927d9 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -898,9 +898,9 @@ bool AddParticipantsBoxController::needsInviteLinkButton() { return _peer->asChat()->canHaveInviteLink(); } -QPointer AddParticipantsBoxController::showBox( +base::weak_qptr AddParticipantsBoxController::showBox( object_ptr 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 AddSpecialBoxController::showBox( +base::weak_qptr AddSpecialBoxController::showBox( object_ptr 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; } diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.h b/Telegram/SourceFiles/boxes/peers/add_participants_box.h index 24d5e1031d..dc06e8040f 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.h @@ -56,7 +56,7 @@ private: base::flat_set> &&alreadyIn, bool justCreated); - QPointer showBox(object_ptr box) const; + base::weak_qptr showBox(object_ptr box) const; void addInviteLinkButton(); void inviteSelectedUsers( @@ -147,7 +147,7 @@ private: void subscribeToMigration(); void migrate(not_null chat, not_null channel); - QPointer showBox(object_ptr box) const; + base::weak_qptr showBox(object_ptr box) const; not_null _peer; MTP::Sender _api; @@ -158,7 +158,7 @@ private: ParticipantsAdditionalData _additional; std::unique_ptr _onlineSorter; Ui::BoxPointer _editBox; - QPointer _editParticipantBox; + base::weak_qptr _editParticipantBox; AdminDoneCallback _adminDoneCallback; BannedDoneCallback _bannedDoneCallback; diff --git a/Telegram/SourceFiles/boxes/peers/choose_peer_box.cpp b/Telegram/SourceFiles/boxes/peers/choose_peer_box.cpp index 7257a3c3f8..ca10840712 100644 --- a/Telegram/SourceFiles/boxes/peers/choose_peer_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/choose_peer_box.cpp @@ -246,10 +246,10 @@ object_ptr CreatePeerByQueryBox( not_null bot, RequestPeerQuery query, Fn>)> done) { - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); auto callback = [=](not_null 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>(); + const auto weak = std::make_shared>(); auto callback = [=, done = std::move(chosen)]( std::vector> peers) { done(std::move(peers)); - if (const auto strong = weak->data()) { + if (const auto strong = weak->get()) { strong->closeBox(); } }; diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp index 4bc2848c78..cc378e6095 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp @@ -37,7 +37,7 @@ QString UserPhone(not_null user) { } void SendRequest( - QPointer box, + base::weak_qptr box, not_null 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, diff --git a/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp index 45ad6b1931..f1de1444ad 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp @@ -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 { diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index 50c3254a37..84c47cd928 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -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 channel) { fields.customSubmitButton = tr::lng_passcode_submit(); fields.customCheckCallback = crl::guard(this, [=]( const Core::CloudPasswordResult &result, - QPointer box) { + base::weak_qptr box) { sendTransferRequestFrom(box, channel, result); }); getDelegate()->show(Box(&channel->session(), fields)); @@ -669,13 +669,13 @@ void EditAdminBox::requestTransferPassword(not_null channel) { } void EditAdminBox::sendTransferRequestFrom( - QPointer box, + base::weak_qptr box, not_null 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(); diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h index 1e5c9fd8ae..b67efcd140 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h @@ -104,7 +104,7 @@ private: bool handleTransferPasswordError(const QString &error); void requestTransferPassword(not_null channel); void sendTransferRequestFrom( - QPointer box, + base::weak_qptr box, not_null channel, const Core::CloudPasswordResult &result); bool canSave() const { @@ -124,7 +124,7 @@ private: ChatAdminRightsInfo, const QString &rank)> _saveCallback; - QPointer _confirmBox; + base::weak_qptr _confirmBox; Ui::Checkbox *_addAsAdmin = nullptr; Ui::SlideWrap *_adminControlsWrap = nullptr; Ui::InputField *_rank = nullptr; diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 03fbc87c68..15a5f1aee1 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1324,9 +1324,9 @@ void ParticipantsBoxController::rebuild() { refreshRows(); } -QPointer ParticipantsBoxController::showBox( +base::weak_qptr ParticipantsBoxController::showBox( object_ptr 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; } diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h index b993c740c5..6e14120302 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h @@ -240,7 +240,7 @@ private: Role role, not_null additional); - QPointer showBox(object_ptr box) const; + base::weak_qptr showBox(object_ptr box) const; void prepareChatRows(not_null chat); void rebuildChatRows(not_null chat); @@ -304,7 +304,7 @@ private: rpl::variable _fullCountValue; Ui::BoxPointer _editBox; Ui::BoxPointer _addBox; - QPointer _editParticipantBox; + base::weak_qptr _editParticipantBox; std::unique_ptr _stories; diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 9d01c2560a..8f5f4221dd 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -906,7 +906,7 @@ void Controller::showEditDiscussionLinkBox() { return; } - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); 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) diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp index aba3714395..17fb1537fb 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp @@ -424,7 +424,7 @@ void Controller::addHeaderBlock(not_null 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 ShareInviteLinkBox( const QString &link, const QString &copied) { const auto sending = std::make_shared(); - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto showToast = [=](const QString &text) { if (*box) { @@ -1551,7 +1551,7 @@ object_ptr 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 EditLinkBox( constexpr auto kPeriod = 3600 * 24 * 30; constexpr auto kTestModePeriod = 300; const auto creating = data.link.isEmpty(); - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); using Fields = Ui::InviteLinkFields; const auto done = [=](Fields result) { const auto finish = [=](Api::InviteLink finished) { @@ -1645,7 +1645,7 @@ object_ptr EditLinkBox( done); } }); - *box = Ui::MakeWeak(object.data()); + *box = base::make_weak(object.data()); return object; } diff --git a/Telegram/SourceFiles/boxes/peers/verify_peers_box.cpp b/Telegram/SourceFiles/boxes/peers/verify_peers_box.cpp index b368f5dc39..f3e71b6f5e 100644 --- a/Telegram/SourceFiles/boxes/peers/verify_peers_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/verify_peers_box.cpp @@ -127,11 +127,11 @@ void Controller::confirmAdd(not_null 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 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)); diff --git a/Telegram/SourceFiles/boxes/phone_banned_box.cpp b/Telegram/SourceFiles/boxes/phone_banned_box.cpp index b29388e96c..c1e9fb512d 100644 --- a/Telegram/SourceFiles/boxes/phone_banned_box.cpp +++ b/Telegram/SourceFiles/boxes/phone_banned_box.cpp @@ -49,7 +49,7 @@ Locale: ") + ::Platform::SystemLanguage(); void ShowPhoneBannedError( not_null controller, const QString &phone) { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto close = [=] { if (*box) { (*box)->closeBox(); diff --git a/Telegram/SourceFiles/boxes/pin_messages_box.cpp b/Telegram/SourceFiles/boxes/pin_messages_box.cpp index 9ba027e20c..9f0a84fccb 100644 --- a/Telegram/SourceFiles/boxes/pin_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/pin_messages_box.cpp @@ -50,8 +50,8 @@ void PinMessageBox( not_null box, not_null item) { struct State { - QPointer pinForPeer; - QPointer notify; + base::weak_qptr pinForPeer; + base::weak_qptr 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 }; diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.cpp b/Telegram/SourceFiles/boxes/self_destruction_box.cpp index c4a070c16e..f65cd54b17 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.cpp +++ b/Telegram/SourceFiles/boxes/self_destruction_box.cpp @@ -56,7 +56,7 @@ void AddDeleteAccount( fields.customSubmitButton = tr::lng_theme_delete(); fields.customCheckCallback = [=]( const Core::CloudPasswordResult &result, - QPointer box) { + base::weak_qptr box) { session->api().request(MTPaccount_DeleteAccount( MTP_flags(MTPaccount_DeleteAccount::Flag::f_password), MTP_string("Manual"), diff --git a/Telegram/SourceFiles/boxes/send_credits_box.cpp b/Telegram/SourceFiles/boxes/send_credits_box.cpp index 9e33609715..8f355b1aa6 100644 --- a/Telegram/SourceFiles/boxes/send_credits_box.cpp +++ b/Telegram/SourceFiles/boxes/send_credits_box.cpp @@ -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()); diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 1ef95d7c89..b16040eeae 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -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) { diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index dac3fe5d97..5f9e018a28 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -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 forum) { - const auto guard = Ui::MakeWeak(this); - const auto weak = std::make_shared>(); + const auto guard = base::make_weak(this); + const auto weak = std::make_shared>(); auto chosen = [=](not_null topic) { if (const auto strong = *weak) { strong->closeBox(); @@ -1419,8 +1419,8 @@ void ShareBox::Inner::chooseForumTopic(not_null forum) { void ShareBox::Inner::chooseMonoforumSublist( not_null monoforum) { - const auto guard = Ui::MakeWeak(this); - const auto weak = std::make_shared>(); + const auto guard = base::make_weak(this); + const auto weak = std::make_shared>(); auto chosen = [=](not_null sublist) { if (const auto strong = *weak) { strong->closeBox(); @@ -1953,7 +1953,7 @@ void FastShareLink( std::shared_ptr show, const QString &url, ShareBoxStyleOverrides st) { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto sending = std::make_shared(); auto copyCallback = [=] { QGuiApplication::clipboard()->setText(url); diff --git a/Telegram/SourceFiles/boxes/star_gift_box.cpp b/Telegram/SourceFiles/boxes/star_gift_box.cpp index 0398ffbc91..c63319b912 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_box.cpp @@ -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(); } } diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 3c7380f914..2079fc7108 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -494,7 +494,7 @@ StickerSetBox::StickerSetBox( : StickerSetBox(parent, std::move(show), set->identifier(), set->type()) { } -QPointer StickerSetBox::Show( +base::weak_qptr StickerSetBox::Show( std::shared_ptr show, not_null document) { if (const auto sticker = document->sticker()) { @@ -503,7 +503,7 @@ QPointer StickerSetBox::Show( show, sticker->set, sticker->setType); - const auto result = QPointer(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(); diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.h b/Telegram/SourceFiles/boxes/sticker_set_box.h index 07e0168e2b..85fbc2a404 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.h +++ b/Telegram/SourceFiles/boxes/sticker_set_box.h @@ -70,7 +70,7 @@ public: std::shared_ptr show, not_null set); - static QPointer Show( + static base::weak_qptr Show( std::shared_ptr show, not_null document); diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 778db60af9..65d3c400bb 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -2058,7 +2058,7 @@ void StickersBox::Inner::checkGroupLevel(Fn 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(); diff --git a/Telegram/SourceFiles/boxes/transfer_gift_box.cpp b/Telegram/SourceFiles/boxes/transfer_gift_box.cpp index d94c9d01e7..438beff1e0 100644 --- a/Telegram/SourceFiles/boxes/transfer_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/transfer_gift_box.cpp @@ -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 box) { + base::weak_qptr box) { using ExportUrl = MTPpayments_StarGiftWithdrawalUrl; session->api().request( MTPpayments_GetStarGiftWithdrawalUrl( @@ -180,7 +180,7 @@ void ExportOnBlockchain( const auto state = std::make_shared(); 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(); diff --git a/Telegram/SourceFiles/boxes/translate_box.cpp b/Telegram/SourceFiles/boxes/translate_box.cpp index b79a417eec..8e29782b5b 100644 --- a/Telegram/SourceFiles/boxes/translate_box.cpp +++ b/Telegram/SourceFiles/boxes/translate_box.cpp @@ -307,7 +307,7 @@ object_ptr EditSkipTranslationLanguages() { auto title = tr::lng_translate_settings_choose(); const auto selected = std::make_shared>( Core::App().settings().skipTranslationLanguages()); - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); const auto check = [=](LanguageId id) { const auto already = ranges::contains(*selected, id); if (already) { @@ -316,7 +316,7 @@ object_ptr 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); diff --git a/Telegram/SourceFiles/boxes/url_auth_box.cpp b/Telegram/SourceFiles/boxes/url_auth_box.cpp index 3dc29d9222..3047bbb771 100644 --- a/Telegram/SourceFiles/boxes/url_auth_box.cpp +++ b/Telegram/SourceFiles/boxes/url_auth_box.cpp @@ -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>(); + const auto box = std::make_shared>(); 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>(); + const auto box = std::make_shared>(); const auto finishWithUrl = [=](const QString &url) { if (*box) { (*box)->closeBox(); diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index 372aa37c53..a68484c217 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -711,7 +711,7 @@ std::unique_ptr BoxController::createRow( void ClearCallsBox( not_null box, not_null<::Window::SessionController*> window) { - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); box->addRow( object_ptr( 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(); } } diff --git a/Telegram/SourceFiles/calls/calls_emoji_fingerprint.cpp b/Telegram/SourceFiles/calls/calls_emoji_fingerprint.cpp index 164f754c3d..7432c4a6b3 100644 --- a/Telegram/SourceFiles/calls/calls_emoji_fingerprint.cpp +++ b/Telegram/SourceFiles/calls/calls_emoji_fingerprint.cpp @@ -604,9 +604,9 @@ void SetupFingerprintTooltip(not_null widget) { st::confcallFingerprintTooltipLabel), st::confcallFingerprintTooltip); const auto raw = state->tooltip.get(); - const auto weak = QPointer(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); diff --git a/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp b/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp index a3f57de101..137417a9e0 100644 --- a/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp +++ b/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp @@ -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(); } } diff --git a/Telegram/SourceFiles/calls/group/calls_choose_join_as.h b/Telegram/SourceFiles/calls/group/calls_choose_join_as.h index eb899b5568..673546ffa1 100644 --- a/Telegram/SourceFiles/calls/group/calls_choose_join_as.h +++ b/Telegram/SourceFiles/calls/group/calls_choose_join_as.h @@ -51,7 +51,7 @@ private: std::shared_ptr show; Fn done; base::has_weak_ptr guard; - QPointer box; + base::weak_qptr box; rpl::lifetime lifetime; Context context = Context(); mtpRequestId id = 0; diff --git a/Telegram/SourceFiles/calls/group/calls_group_common.cpp b/Telegram/SourceFiles/calls/group/calls_group_common.cpp index fab26cc837..066d140861 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_common.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_common.cpp @@ -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({ diff --git a/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp b/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp index cd04eb32fa..6994aff627 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp @@ -943,7 +943,7 @@ object_ptr 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>(); + const auto shared = std::make_shared>(); const auto finishWithConfirm = [=] { if (*shared) { (*shared)->closeBox(); @@ -983,7 +983,7 @@ object_ptr 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 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(); } }; diff --git a/Telegram/SourceFiles/calls/group/calls_group_members.cpp b/Telegram/SourceFiles/calls/group/calls_group_members.cpp index d5ce0e5791..67a82ccb7d 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_members.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_members.cpp @@ -1346,16 +1346,16 @@ base::unique_qptr 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, diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index f3d2c524ed..ce9c69b195 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -407,7 +407,7 @@ void Panel::startScheduledNow() { } else if (now + kStartNoConfirmation >= date) { _call->startScheduledNow(); } else { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); 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>(); + const auto shared = std::make_shared>(); 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(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(_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) diff --git a/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp b/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp index db94f72cb0..9c35ed529d 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp @@ -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)); } diff --git a/Telegram/SourceFiles/calls/group/calls_group_rtmp.h b/Telegram/SourceFiles/calls/group/calls_group_rtmp.h index eb5d4b5fa6..c3cadab12d 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_rtmp.h +++ b/Telegram/SourceFiles/calls/group/calls_group_rtmp.h @@ -64,7 +64,7 @@ private: std::shared_ptr show; Fn done; base::has_weak_ptr guard; - QPointer box; + base::weak_qptr box; rpl::lifetime lifetime; mtpRequestId id = 0; }; diff --git a/Telegram/SourceFiles/calls/group/calls_group_settings.cpp b/Telegram/SourceFiles/calls/group/calls_group_settings.cpp index 0adbb8e3e9..cb70c06e6d 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_settings.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_settings.cpp @@ -110,7 +110,7 @@ object_ptr ShareInviteLinkBox( const QString &linkListener, std::shared_ptr show) { const auto sending = std::make_shared(); - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); 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 deviceId; diff --git a/Telegram/SourceFiles/calls/group/ui/desktop_capture_choose_source.cpp b/Telegram/SourceFiles/calls/group/ui/desktop_capture_choose_source.cpp index a122f09a24..40712391b8 100644 --- a/Telegram/SourceFiles/calls/group/ui/desktop_capture_choose_source.cpp +++ b/Telegram/SourceFiles/calls/group/ui/desktop_capture_choose_source.cpp @@ -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(); } }); diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp index 2f88f8202d..38b54e3518 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp @@ -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(); diff --git a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp index 87fd388861..16f3a8f73a 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp @@ -984,7 +984,7 @@ void SuggestionsController::replaceCurrent( const auto position = cursor.position(); const auto suggestion = getEmojiQuery(); if (v::is(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; diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 200ad997e8..8f5172c567 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -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 show, not_null 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 @@ FncommitMarkdownLinkEdit(selection, text, link); } }; @@ -484,7 +484,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) { EditLinkAction action)> FactcheckEditLinkCallback( std::shared_ptr show, not_null 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; diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index fed2bbd128..ecf20568ee 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -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(); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index 04d49849d2..68437e450e 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -1471,13 +1471,13 @@ void TabbedSelector::Inner::disableScroll(bool disabled) { void TabbedSelector::Inner::checkHideWithBox( object_ptr box) { - const auto raw = QPointer(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({}); }); diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 53e01dd106..51fa20fcc6 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -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 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); } diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index bfb330d351..24bec04def 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -437,7 +437,7 @@ private: const std::unique_ptr _langCloudManager; const std::unique_ptr _emojiKeywords; std::unique_ptr _translator; - QPointer _badProxyDisableBox; + base::weak_qptr _badProxyDisableBox; const std::unique_ptr _tray; diff --git a/Telegram/SourceFiles/core/phone_click_handler.cpp b/Telegram/SourceFiles/core/phone_click_handler.cpp index ec34b8f8be..167aec1653 100644 --- a/Telegram/SourceFiles/core/phone_click_handler.cpp +++ b/Telegram/SourceFiles/core/phone_click_handler.cpp @@ -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( &controller->session(), diff --git a/Telegram/SourceFiles/data/data_document_resolver.cpp b/Telegram/SourceFiles/data/data_document_resolver.cpp index 13b30f0bd2..eea69ed577 100644 --- a/Telegram/SourceFiles/data/data_document_resolver.cpp +++ b/Telegram/SourceFiles/data/data_document_resolver.cpp @@ -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(); diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index 701eaf08db..cfcf028718 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -1008,7 +1008,7 @@ private: Storage::DatabasePointer _bigFileCache; TimeId _exportAvailableAt = 0; - QPointer _exportSuggestion; + base::weak_qptr _exportSuggestion; rpl::variable _contactsLoaded = false; rpl::variable _groupFreeTranscribeLevel; diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 2cbe2d23f0..4ec8f4455c 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -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(); } diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index ffcd9dce43..c45a82a2b6 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -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; diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp index ae4a4768cd..a66fe7488b 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp @@ -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 = [=] { diff --git a/Telegram/SourceFiles/editor/editor_layer_widget.cpp b/Telegram/SourceFiles/editor/editor_layer_widget.cpp index baa149d5a1..fc2096fa37 100644 --- a/Telegram/SourceFiles/editor/editor_layer_widget.cpp +++ b/Telegram/SourceFiles/editor/editor_layer_widget.cpp @@ -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); } }); diff --git a/Telegram/SourceFiles/editor/photo_editor.cpp b/Telegram/SourceFiles/editor/photo_editor.cpp index 801e122582..0ec6de90b4 100644 --- a/Telegram/SourceFiles/editor/photo_editor.cpp +++ b/Telegram/SourceFiles/editor/photo_editor.cpp @@ -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()); diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index bbc19fb5ea..fbb5b258eb 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -404,7 +404,9 @@ auto ApiWrap::fileRequest(const Data::FileLocation &location, int64 offset) { }).toDC(MTP::ShiftDcId(location.dcId, MTP::kExportMediaDcShift))); } -ApiWrap::ApiWrap(QPointer weak, Fn)> runner) +ApiWrap::ApiWrap( + base::weak_qptr weak, + Fn)> runner) : _mtp(weak, std::move(runner)) , _fileCache(std::make_unique(kLocationCacheSize)) { } diff --git a/Telegram/SourceFiles/export/export_api_wrap.h b/Telegram/SourceFiles/export/export_api_wrap.h index 6073243152..de76417bc7 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.h +++ b/Telegram/SourceFiles/export/export_api_wrap.h @@ -40,7 +40,9 @@ struct Settings; class ApiWrap { public: - ApiWrap(QPointer weak, Fn)> runner); + ApiWrap( + base::weak_qptr weak, + Fn)> runner); rpl::producer errors() const; rpl::producer ioErrors() const; diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp index 4aef9c36e6..d65be8f077 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp @@ -96,11 +96,11 @@ Environment PrepareEnvironment(not_null session) { return result; } -QPointer SuggestStart(not_null session) { +base::weak_qptr SuggestStart(not_null session) { ClearSuggestStart(session); return Ui::show( Box(session), - Ui::LayerOption::KeepOther).data(); + Ui::LayerOption::KeepOther).get(); } void ClearSuggestStart(not_null 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), diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.h b/Telegram/SourceFiles/export/view/export_view_panel_controller.h index 70c72f8a69..b820202c3d 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.h +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.h @@ -24,7 +24,7 @@ class Session; namespace Export { namespace View { -QPointer SuggestStart(not_null session); +base::weak_qptr SuggestStart(not_null session); void ClearSuggestStart(not_null session); bool IsDefaultPath(not_null session, const QString &path); void ResolveSettings(not_null session, Settings &settings); @@ -79,7 +79,7 @@ private: base::unique_qptr _panel; State _state; - QPointer _confirmStopBox; + base::weak_qptr _confirmStopBox; rpl::event_stream> _panelCloseEvents; bool _stopRequested = false; rpl::lifetime _lifetime; diff --git a/Telegram/SourceFiles/export/view/export_view_progress.cpp b/Telegram/SourceFiles/export/view/export_view_progress.cpp index dabda8280d..c7d28c7d47 100644 --- a/Telegram/SourceFiles/export/view/export_view_progress.cpp +++ b/Telegram/SourceFiles/export/view/export_view_progress.cpp @@ -51,8 +51,8 @@ private: void hideCurrentInstance(); void setInstanceProgress(Instance &instance, float64 progress); void toggleInstance(Instance &data, bool shown); - void instanceOpacityCallback(QPointer label); - void removeOldInstance(QPointer label); + void instanceOpacityCallback(base::weak_qptr label); + void removeOldInstance(base::weak_qptr 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 label) { + base::weak_qptr 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 label) { +void ProgressWidget::Row::removeOldInstance( + base::weak_qptr 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); diff --git a/Telegram/SourceFiles/export/view/export_view_settings.cpp b/Telegram/SourceFiles/export/view/export_view_settings.cpp index bc25b60394..e610471279 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.cpp +++ b/Telegram/SourceFiles/export/view/export_view_settings.cpp @@ -320,20 +320,20 @@ void SettingsWidget::addLocationLabel( } void SettingsWidget::chooseFormat() { - const auto shared = std::make_shared>(); + const auto shared = std::make_shared>(); 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>(); + const auto shared = std::make_shared>(); const auto finalize = [=](not_null 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)); } diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 0d917654d4..c47e562fae 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -1530,7 +1530,7 @@ void InnerWidget::suggestRestrictParticipant( UserData *by, TimeId since) { auto weak = QPointer(this); - auto weakBox = std::make_shared>(); + auto weakBox = std::make_shared>(); auto box = Box( _channel, user, @@ -1560,7 +1560,7 @@ void InnerWidget::suggestRestrictParticipant( tr::now, lt_user, participant->name()); - auto weakBox = std::make_shared>(); + auto weakBox = std::make_shared>(); 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), }) diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index e897e65f26..bdfe45ca02 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -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); diff --git a/Telegram/SourceFiles/history/history_item_helpers.cpp b/Telegram/SourceFiles/history/history_item_helpers.cpp index 57bddb387e..762419f53a 100644 --- a/Telegram/SourceFiles/history/history_item_helpers.cpp +++ b/Telegram/SourceFiles/history/history_item_helpers.cpp @@ -356,7 +356,7 @@ void ShowSendPaidConfirm( const auto messages = details.messages; const auto stars = details.stars; show->showBox(Box([=](not_null box) { - const auto trust = std::make_shared>(); + const auto trust = std::make_shared>(); const auto proceed = [=](Fn close) { if (singlePeer && (*trust)->checked()) { const auto session = &singlePeer->session(); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 9ab254a5e5..7d9f5765a4 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -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(); } }); diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_search.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_search.cpp index 98064d0204..478ccdba89 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_search.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_search.cpp @@ -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(); diff --git a/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp b/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp index 15125a480b..253073f8dc 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp @@ -819,7 +819,7 @@ void DraftOptionsBox( FullReplyTo result, Data::WebPageDraft webpage, std::optional 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(); } }; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_forward_panel.cpp b/Telegram/SourceFiles/history/view/controls/history_view_forward_panel.cpp index de53aeb673..8a8b30fff8 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_forward_panel.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_forward_panel.cpp @@ -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(); } }); diff --git a/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp b/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp index f599f8a63b..0784d82782 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp @@ -484,13 +484,13 @@ void ChooseSuggestPriceBox( st::settingsButtonNoIcon); time->setClickedCallback([=] { - const auto weak = std::make_shared>(); - const auto parentWeak = Ui::MakeWeak(box); + const auto weak = std::make_shared>(); + 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>(); + const auto weak = std::make_shared>(); const auto apply = [=](SuggestPostOptions values) { _values = values; updateTexts(); _updates.fire({}); - if (const auto strong = weak->data()) { + if (const auto strong = weak->get()) { strong->closeBox(); } }; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp index 2f4cc7192c..8df2628252 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp @@ -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) { diff --git a/Telegram/SourceFiles/history/view/history_view_chat_preview.cpp b/Telegram/SourceFiles/history/view/history_view_chat_preview.cpp index 5e9d3eecdd..353a9acec4 100644 --- a/Telegram/SourceFiles/history/view/history_view_chat_preview.cpp +++ b/Telegram/SourceFiles/history/view/history_view_chat_preview.cpp @@ -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); } diff --git a/Telegram/SourceFiles/history/view/history_view_chat_section.cpp b/Telegram/SourceFiles/history/view/history_view_chat_section.cpp index 4f8595266a..fc4cf0fc3c 100644 --- a/Telegram/SourceFiles/history/view/history_view_chat_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_chat_section.cpp @@ -2315,9 +2315,9 @@ bool ChatWidget::preventsClose(Fn &&continueCallback) const { } else if (!_newTopicDiscarded && _topic && _topic->creating()) { - const auto weak = Ui::MakeWeak(this); + const auto weak = base::make_weak(this); auto sure = [=](Fn &&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(); diff --git a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp index 99c135f6f3..b0a48e1bdb 100644 --- a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp +++ b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp @@ -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) { diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 3acc55e811..84e258e2fb 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -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 item, not_null controller) { const auto whoReadIds = std::make_shared(); - 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)) { diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 6077d1a1f6..6a46231354 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -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 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 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(); } }; diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index a6ac266d36..27c8d2f975 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -1340,9 +1340,9 @@ void ScheduledWidget::showProcessingVideoTooltip() { st::defaultImportantTooltipLabel), st::defaultImportantTooltip); const auto tooltip = _processingVideoTooltip.get(); - const auto weak = QPointer(tooltip); + const auto weak = base::make_weak(tooltip); const auto destroy = [=] { - delete weak.data(); + delete weak.get(); }; tooltip->setAttribute(Qt::WA_TransparentForMouseEvents); tooltip->setHiddenCallback([=] { diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 97edfbdc52..a5ed7ee279 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -336,8 +336,8 @@ bool TopBarWidget::createMenu(not_null 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) { diff --git a/Telegram/SourceFiles/history/view/history_view_translate_bar.cpp b/Telegram/SourceFiles/history/view/history_view_translate_bar.cpp index 11e9cc8d7a..c263c5f9ee 100644 --- a/Telegram/SourceFiles/history/view/history_view_translate_bar.cpp +++ b/Telegram/SourceFiles/history/view/history_view_translate_bar.cpp @@ -409,8 +409,8 @@ base::unique_qptr 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 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); diff --git a/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp b/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp index 89dcda70a3..5e3b7d5ece 100644 --- a/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp +++ b/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.cpp @@ -549,7 +549,7 @@ object_ptr JoinStarRefBox( struct State { rpl::variable> recipient; - QPointer weak; + base::weak_qptr weak; bool sent = false; }; const auto state = std::make_shared(State{ @@ -709,7 +709,7 @@ object_ptr 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) { diff --git a/Telegram/SourceFiles/info/bot/starref/info_bot_starref_join_widget.cpp b/Telegram/SourceFiles/info/bot/starref/info_bot_starref_join_widget.cpp index 515b275923..0343af54bf 100644 --- a/Telegram/SourceFiles/info/bot/starref/info_bot_starref_join_widget.cpp +++ b/Telegram/SourceFiles/info/bot/starref/info_bot_starref_join_widget.cpp @@ -1105,7 +1105,7 @@ std::shared_ptr Make(not_null peer) { object_ptr ProgramsListBox( not_null window, not_null peer) { - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); const auto initBox = [=](not_null box) { *weak = box; box->addButton(tr::lng_close(), [=] { @@ -1118,7 +1118,7 @@ object_ptr 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()); diff --git a/Telegram/SourceFiles/info/bot/starref/info_bot_starref_setup_widget.cpp b/Telegram/SourceFiles/info/bot/starref/info_bot_starref_setup_widget.cpp index 5d1772c93a..46183eb688 100644 --- a/Telegram/SourceFiles/info/bot/starref/info_bot_starref_setup_widget.cpp +++ b/Telegram/SourceFiles/info/bot/starref/info_bot_starref_setup_widget.cpp @@ -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(); 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 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(); diff --git a/Telegram/SourceFiles/info/channel_statistics/boosts/create_giveaway_box.cpp b/Telegram/SourceFiles/info/channel_statistics/boosts/create_giveaway_box.cpp index 09f5cdeb60..cc1c092bc3 100644 --- a/Telegram/SourceFiles/info/channel_statistics/boosts/create_giveaway_box.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/boosts/create_giveaway_box.cpp @@ -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(); } diff --git a/Telegram/SourceFiles/info/channel_statistics/boosts/info_boosts_inner_widget.cpp b/Telegram/SourceFiles/info/channel_statistics/boosts/info_boosts_inner_widget.cpp index 0f35e31de0..de6862e8bc 100644 --- a/Telegram/SourceFiles/info/channel_statistics/boosts/info_boosts_inner_widget.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/boosts/info_boosts_inner_widget.cpp @@ -174,7 +174,7 @@ void FillShareLink( std::shared_ptr show, const QString &link, not_null peer) { - const auto weak = Ui::MakeWeak(content); + const auto weak = base::make_weak(content); const auto copyLink = crl::guard(weak, [=] { QGuiApplication::clipboard()->setText(link); show->showToast(tr::lng_channel_public_link_copied(tr::now)); diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp index 1563bef9dd..4e6ef02378 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp @@ -1470,10 +1470,10 @@ void InnerWidget::fill() { [] {}); } if (!isLocked) { - const auto weak = Ui::MakeWeak(this); + const auto weak = base::make_weak(this); const auto show = _controller->uiShow(); const auto failed = [=](const QString &e) { - if (weak.data()) { + if (weak.get()) { toggled->fire(false); show->showToast(e); } diff --git a/Telegram/SourceFiles/info/info_top_bar.cpp b/Telegram/SourceFiles/info/info_top_bar.cpp index a6dd089a25..8e731fc914 100644 --- a/Telegram/SourceFiles/info/info_top_bar.cpp +++ b/Telegram/SourceFiles/info/info_top_bar.cpp @@ -53,7 +53,7 @@ void TopBar::registerUpdateControlCallback( QObject *guard, Callback &&callback) { _updateControlCallbacks[guard] =[ - weak = Ui::MakeWeak(guard), + weak = base::make_weak(guard), callback = std::forward(callback) ](anim::type animated) { if (!weak) { @@ -579,8 +579,8 @@ void TopBar::setStories(rpl::producer content) { } }, _storiesLifetime); - _storiesLifetime.add([weak = QPointer(label)] { - delete weak.data(); + _storiesLifetime.add([weak = base::make_weak(label)] { + delete weak.get(); }); } else { _storiesCount = 0; diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 56bc9bf193..20a99a2c58 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -979,7 +979,7 @@ object_ptr WrapWidget::createTopBarSurrogate( Assert(_topBar != nullptr); auto result = object_ptr(parent); - result->addClickHandler([weak = Ui::MakeWeak(this)]{ + result->addClickHandler([weak = base::make_weak(this)]{ if (weak) { weak->_controller->showBackFromStack(); } diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp index d4d99d138a..f6b382b1e4 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp @@ -1224,8 +1224,8 @@ void ListWidget::forwardItems(MessageIdsList &&items) { { id.peer, StoryIdFromMsgId(id.msg) })); } } else { - auto callback = [weak = Ui::MakeWeak(this)] { - if (const auto strong = weak.data()) { + auto callback = [weak = base::make_weak(this)] { + if (const auto strong = weak.get()) { strong->clearSelected(); } }; @@ -1373,7 +1373,7 @@ void ListWidget::deleteItems(SelectedItems &&items, Fn confirmed) { : tr::lng_downloads_delete_in_cloud(tr::now)); const auto deleteSure = [=] { Ui::PostponeCall(this, [=] { - if (const auto box = _actionBoxWeak.data()) { + if (const auto box = _actionBoxWeak.get()) { box->closeBox(); } }); @@ -1433,10 +1433,10 @@ void ListWidget::deleteItems(SelectedItems &&items, Fn confirmed) { } } -void ListWidget::setActionBoxWeak(QPointer box) { +void ListWidget::setActionBoxWeak(base::weak_qptr box) { if ((_actionBoxWeak = box)) { _actionBoxWeakLifetime = _actionBoxWeak->alive( - ) | rpl::start_with_done([weak = Ui::MakeWeak(this)]{ + ) | rpl::start_with_done([weak = base::make_weak(this)]{ if (weak) { weak->_checkForHide.fire({}); } diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.h b/Telegram/SourceFiles/info/media/info_media_list_widget.h index 4f4a78e966..fa40321c47 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.h +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.h @@ -272,7 +272,7 @@ private: void checkMoveToOtherViewer(); void clearHeavyItems(); - void setActionBoxWeak(QPointer box); + void setActionBoxWeak(base::weak_qptr box); const not_null _controller; const std::unique_ptr _provider; @@ -307,7 +307,7 @@ private: base::unique_qptr _contextMenu; rpl::event_stream<> _checkForHide; - QPointer _actionBoxWeak; + base::weak_qptr _actionBoxWeak; rpl::lifetime _actionBoxWeakLifetime; QPoint _trippleClickPoint; diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp index 51c83a2f77..33e28a9227 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp @@ -1015,9 +1015,9 @@ void SelectGiftToUnpin( } Assert(index < int(pinned.size())); const auto &entry = pinned[index]; - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); chosen(::Settings::EntryToSavedStarGiftId(session, entry)); - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->closeBox(); } }); diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index e07ba2d1c2..26823bb83b 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -885,13 +885,13 @@ rpl::producer AddCurrencyAction( state->balance = balance; } { - const auto weak = Ui::MakeWeak(wrap); + const auto weak = base::make_weak(wrap); const auto currencyLoadLifetime = std::make_shared(); const auto currencyLoad = currencyLoadLifetime->make_state(user); const auto done = [=](CreditsAmount balance) { - if ([[maybe_unused]] const auto strong = weak.data()) { + if ([[maybe_unused]] const auto strong = weak.get()) { state->balance = balance; currencyLoadLifetime->destroy(); } diff --git a/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.cpp b/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.cpp index ecf24b2796..de39c8ed1b 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_emoji_status_panel.cpp @@ -269,7 +269,7 @@ void EmojiStatusPanel::create(const Descriptor &descriptor) { _panel->hideAnimated(); }, _panel->lifetime()); } else { - const auto weak = Ui::MakeWeak(_panel.get()); + const auto weak = base::make_weak(_panel.get()); const auto accept = [=](Chosen chosen) { Expects(chosen.until != Selector::kPickCustomTimeId); diff --git a/Telegram/SourceFiles/info/settings/info_settings_widget.h b/Telegram/SourceFiles/info/settings/info_settings_widget.h index e1aef6b78e..b08a4281f8 100644 --- a/Telegram/SourceFiles/info/settings/info_settings_widget.h +++ b/Telegram/SourceFiles/info/settings/info_settings_widget.h @@ -104,8 +104,8 @@ private: rpl::event_stream<> backButtonEnables; } _flexibleScroll; not_null<::Settings::AbstractSection*> _inner; - QPointer _pinnedToTop; - QPointer _pinnedToBottom; + base::weak_qptr _pinnedToTop; + base::weak_qptr _pinnedToBottom; rpl::event_stream> _removesFromStack; diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index 36e907923f..8e1af089b1 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -219,7 +219,7 @@ void ShowChooseBox( PeerTypes types, Fn)> callback, rpl::producer titleOverride = nullptr) { - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); auto done = [=](not_null thread) mutable { if (const auto strong = *weak) { strong->closeBox(); @@ -1816,8 +1816,8 @@ void WebViewInstance::botSendPreparedMessage( .viaBotId = peerToUser(bot->id), }); struct State { - QPointer preview; - QPointer choose; + base::weak_qptr preview; + base::weak_qptr choose; rpl::event_stream> recipient; Fn send; SendPaymentHelper sendPayment; @@ -1837,10 +1837,10 @@ void WebViewInstance::botSendPreparedMessage( const auto weak1 = state->preview; const auto weak2 = state->choose; const auto close = [=] { - if (const auto strong = weak1.data()) { + if (const auto strong = weak1.get()) { strong->closeBox(); } - if (const auto strong = weak2.data()) { + if (const auto strong = weak2.get()) { strong->closeBox(); } }; @@ -1850,9 +1850,9 @@ void WebViewInstance::botSendPreparedMessage( } if (success) { *failed = -1; - if (const auto strong2 = weak2.data()) { + if (const auto strong2 = weak2.get()) { strong2->showToast({ tr::lng_share_done(tr::now) }); - } else if (const auto strong1 = weak1.data()) { + } else if (const auto strong1 = weak1.get()) { strong1->showToast({ tr::lng_share_done(tr::now) }); } base::call_delayed(Ui::Toast::kDefaultDuration, close); diff --git a/Telegram/SourceFiles/intro/intro_password_check.cpp b/Telegram/SourceFiles/intro/intro_password_check.cpp index 3555c95ef8..748e304fe1 100644 --- a/Telegram/SourceFiles/intro/intro_password_check.cpp +++ b/Telegram/SourceFiles/intro/intro_password_check.cpp @@ -230,7 +230,7 @@ void PasswordCheckWidget::codeSubmitDone( fields.mtp.curRequest = {}; fields.hasPassword = false; auto box = Box(&api().instance(), nullptr, fields); - const auto boxShared = std::make_shared>(); + const auto boxShared = std::make_shared>(); box->newAuthorization( ) | rpl::start_with_next([=](const MTPauth_Authorization &result) { diff --git a/Telegram/SourceFiles/intro/intro_widget.cpp b/Telegram/SourceFiles/intro/intro_widget.cpp index ca65b02214..296991f514 100644 --- a/Telegram/SourceFiles/intro/intro_widget.cpp +++ b/Telegram/SourceFiles/intro/intro_widget.cpp @@ -403,7 +403,7 @@ void Widget::historyMove(StackAction action, Animate animate) { } void Widget::hideAndDestroy(object_ptr> widget) { - const auto weak = Ui::MakeWeak(widget.data()); + const auto weak = base::make_weak(widget.data()); widget->hide(anim::type::normal); widget->shownValue( ) | rpl::start_with_next([=](bool shown) { @@ -625,7 +625,7 @@ void Widget::showTerms(Fn callback) { if (getData()->termsLock.text.text.isEmpty()) { return; } - const auto weak = Ui::MakeWeak(this); + const auto weak = base::make_weak(this); const auto box = Ui::show(callback ? Box( getData()->termsLock, diff --git a/Telegram/SourceFiles/iv/iv_controller.cpp b/Telegram/SourceFiles/iv/iv_controller.cpp index 87befe5bfd..2b436d842c 100644 --- a/Telegram/SourceFiles/iv/iv_controller.cpp +++ b/Telegram/SourceFiles/iv/iv_controller.cpp @@ -1096,7 +1096,7 @@ void Controller::showMenu() { } _menu->setDestroyedCallback(crl::guard(_window.get(), [ this, - weakButton = Ui::MakeWeak(_menuToggle.data()), + weakButton = base::make_weak(_menuToggle.data()), menu = _menu.get()] { if (_menu == menu && weakButton) { weakButton->setForceRippled(false); diff --git a/Telegram/SourceFiles/iv/iv_instance.cpp b/Telegram/SourceFiles/iv/iv_instance.cpp index 09a7e2e383..dec3f36cf9 100644 --- a/Telegram/SourceFiles/iv/iv_instance.cpp +++ b/Telegram/SourceFiles/iv/iv_instance.cpp @@ -315,11 +315,11 @@ ShareBoxResult Shown::shareBox(ShareBoxDescriptor &&descriptor) { }; const auto state = wrap->lifetime().make_state(); - const auto weak = QPointer(wrap); + const auto weak = base::make_weak(wrap); const auto lookup = crl::guard(weak, [state] { return state->stack; }); const auto layer = Ui::CreateChild( wrap.get(), - [=] { return std::make_shared(weak.data(), lookup); }); + [=] { return std::make_shared(weak.get(), lookup); }); state->stack = layer; const auto show = layer->showFactory()(); diff --git a/Telegram/SourceFiles/iv/iv_pch.h b/Telegram/SourceFiles/iv/iv_pch.h index 4ad8da65a9..15ad9d2fe7 100644 --- a/Telegram/SourceFiles/iv/iv_pch.h +++ b/Telegram/SourceFiles/iv/iv_pch.h @@ -22,9 +22,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/flat_map.h" #include "base/flat_set.h" +#include "base/weak_qptr.h" #include "ui/qt_object_factory.h" -#include "ui/qt_weak_factory.h" #include "scheme.h" #include "logs.h" diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index e7ed0c618d..773c4fb3a6 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -259,7 +259,7 @@ void MainWindow::setupMain( const auto animated = _intro || (_passcodeLock && !Core::App().passcodeLocked()); const auto weakAnimatedLayer = (_main && _layer && !_passcodeLock) - ? Ui::MakeWeak(_layer.get()) + ? base::make_weak(_layer.get()) : nullptr; if (weakAnimatedLayer) { Assert(!animated); @@ -288,7 +288,7 @@ void MainWindow::setupMain( Core::App().checkStartUrl(); } fixOrder(); - if (const auto strong = weakAnimatedLayer.data()) { + if (const auto strong = weakAnimatedLayer.get()) { strong->hideAllAnimatedRun(); } } diff --git a/Telegram/SourceFiles/media/stories/media_stories_header.cpp b/Telegram/SourceFiles/media/stories/media_stories_header.cpp index a77c700b25..316000a4fb 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_header.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_header.cpp @@ -741,9 +741,9 @@ void Header::toggleTooltip(Tooltip type, bool show) { st::storiesInfoTooltipLabel), st::storiesInfoTooltip); const auto tooltip = _tooltip.get(); - const auto weak = QPointer(tooltip); + const auto weak = base::make_weak(tooltip); const auto destroy = [=] { - delete weak.data(); + delete weak.get(); }; tooltip->setAttribute(Qt::WA_TransparentForMouseEvents); tooltip->setHiddenCallback(destroy); diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 9333efdc91..5ff6a060a3 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -3381,7 +3381,7 @@ void OverlayWidget::refreshCaption() { : Ui::ItemTextDefaultOptions()), context); if (_caption.hasSpoilers()) { - const auto weak = Ui::MakeWeak(widget()); + const auto weak = base::make_weak(widget()); _caption.setSpoilerLinkFilter([=](const ClickContext &context) { return (weak != nullptr); }); @@ -4286,7 +4286,7 @@ void OverlayWidget::initThemePreview() { const auto weakSession = base::make_weak(&_document->session()); const auto path = _document->location().name(); const auto id = _themePreviewId = base::RandomValue(); - const auto weak = Ui::MakeWeak(_widget); + const auto weak = base::make_weak(_widget); crl::async([=, data = std::move(current)]() mutable { auto preview = GeneratePreview( bytes, @@ -6448,7 +6448,7 @@ bool OverlayWidget::handleTouchEvent(not_null e) { if (!_touchPress) { break; } - auto weak = Ui::MakeWeak(_widget); + auto weak = base::make_weak(_widget); if (!_touchMove) { const auto button = _touchRightButton ? Qt::RightButton diff --git a/Telegram/SourceFiles/media/view/media_view_pip.cpp b/Telegram/SourceFiles/media/view/media_view_pip.cpp index 7c8f958889..42600dbb3e 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp @@ -1009,7 +1009,7 @@ void Pip::handleLeave() { } void Pip::handleMouseMove(QPoint position) { - const auto weak = Ui::MakeWeak(_panel.widget()); + const auto weak = base::make_weak(_panel.widget()); const auto guard = gsl::finally([&] { if (weak) { _panel.handleMouseMove(position); @@ -1087,7 +1087,7 @@ Pip::OverState Pip::ResolveShownOver(OverState state) { } void Pip::handleMousePress(QPoint position, Qt::MouseButton button) { - const auto weak = Ui::MakeWeak(_panel.widget()); + const auto weak = base::make_weak(_panel.widget()); const auto guard = gsl::finally([&] { if (weak) { _panel.handleMousePress(position, button); @@ -1105,7 +1105,7 @@ void Pip::handleMousePress(QPoint position, Qt::MouseButton button) { } void Pip::handleMouseRelease(QPoint position, Qt::MouseButton button) { - const auto weak = Ui::MakeWeak(_panel.widget()); + const auto weak = base::make_weak(_panel.widget()); const auto guard = gsl::finally([&] { if (weak) { _panel.handleMouseRelease(position, button); diff --git a/Telegram/SourceFiles/menu/menu_item_download_files.cpp b/Telegram/SourceFiles/menu/menu_item_download_files.cpp index 01a990b11b..540f2ebb71 100644 --- a/Telegram/SourceFiles/menu/menu_item_download_files.cpp +++ b/Telegram/SourceFiles/menu/menu_item_download_files.cpp @@ -226,8 +226,8 @@ void AddDownloadFilesAction( return; } } - const auto done = [weak = Ui::MakeWeak(list)] { - if (const auto strong = weak.data()) { + const auto done = [weak = base::make_weak(list)] { + if (const auto strong = weak.get()) { strong->cancelSelection(); } }; @@ -253,8 +253,8 @@ void AddDownloadFilesAction( return; } } - const auto done = [weak = Ui::MakeWeak(list)] { - if (const auto strong = weak.data()) { + const auto done = [weak = base::make_weak(list)] { + if (const auto strong = weak.get()) { strong->clearSelected(); } }; diff --git a/Telegram/SourceFiles/menu/menu_send.cpp b/Telegram/SourceFiles/menu/menu_send.cpp index 4125ac0891..86518f725f 100644 --- a/Telegram/SourceFiles/menu/menu_send.cpp +++ b/Telegram/SourceFiles/menu/menu_send.cpp @@ -589,7 +589,7 @@ void EffectPreview::toggle(bool shown) { Fn DefaultCallback( std::shared_ptr show, Fn send) { - const auto guard = Ui::MakeWeak(show->toastParent()); + const auto guard = base::make_weak(show->toastParent()); return [=](Action action, Details details) { if (action.type == ActionType::Send) { send(action.options); @@ -601,9 +601,9 @@ Fn DefaultCallback( details, send, action.options); - const auto weak = Ui::MakeWeak(box.data()); + const auto weak = base::make_weak(box.data()); show->showBox(std::move(box)); - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->setCloseByOutsideClick(false); } }; @@ -618,7 +618,7 @@ FillMenuResult AttachSendMenuEffect( Expects(show != nullptr); using namespace HistoryView::Reactions; - const auto effect = std::make_shared>(); + const auto effect = std::make_shared>(); const auto position = desiredPositionOverride.value_or(QCursor::pos()); const auto selector = (show && details.effectAllowed) ? AttachSelectorToMenu( @@ -645,13 +645,13 @@ FillMenuResult AttachSendMenuEffect( const auto &effects = reactions.list(Data::Reactions::Type::Effects); const auto i = ranges::find(effects, chosen.id, &Data::Reaction::id); if (i != end(effects)) { - if (const auto strong = effect->data()) { + if (const auto strong = effect->get()) { strong->hideAnimated(); } - const auto weak = Ui::MakeWeak(menu); + const auto weak = base::make_weak(menu); const auto done = [=] { - delete effect->data(); - if (const auto strong = weak.data()) { + delete effect->get(); + if (const auto strong = weak.get()) { strong->hideMenu(true); } }; diff --git a/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.cpp b/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.cpp index 5bb4d5d205..89ad7d9625 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.cpp +++ b/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.cpp @@ -76,7 +76,7 @@ auto ConcurrentSender::with_instance(Method &&method) weak = _weak, method = std::forward(method) ]() mutable { - if (const auto instance = weak.data()) { + if (const auto instance = weak.get()) { std::move(method)(instance); } }); @@ -136,7 +136,7 @@ mtpRequestId ConcurrentSender::RequestBuilder::send() { } ConcurrentSender::ConcurrentSender( - QPointer weak, + base::weak_qptr weak, Fn)> runner) : _weak(weak) , _runner(runner) { diff --git a/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h b/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h index 47daaf7a6c..f96d0fe3ac 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h +++ b/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/bytes.h" #include "base/weak_ptr.h" +#include "base/weak_qptr.h" #include "base/flat_map.h" #include "mtproto/core_types.h" #include "mtproto/details/mtproto_serialized_request.h" @@ -83,7 +84,7 @@ class ConcurrentSender : public base::has_weak_ptr { public: ConcurrentSender( - QPointer weak, + base::weak_qptr weak, Fn)> runner); template @@ -184,7 +185,7 @@ private: void senderRequestCancelAll(); void senderRequestDetach(mtpRequestId requestId); - const QPointer _weak; + const base::weak_qptr _weak; const Fn)> _runner; base::flat_map _requests; diff --git a/Telegram/SourceFiles/passport/passport_form_view_controller.h b/Telegram/SourceFiles/passport/passport_form_view_controller.h index b2a22fbdbc..590d7c2109 100644 --- a/Telegram/SourceFiles/passport/passport_form_view_controller.h +++ b/Telegram/SourceFiles/passport/passport_form_view_controller.h @@ -63,11 +63,11 @@ public: } template - QPointer show( + base::weak_qptr show( object_ptr box, Ui::LayerOptions options = Ui::LayerOption::KeepOther, anim::type animated = anim::type::normal) { - auto result = QPointer(box.data()); + auto result = base::weak_qptr(box.data()); showBox(std::move(box), options, animated); return result; } diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.cpp b/Telegram/SourceFiles/passport/passport_panel_controller.cpp index e4979bf3b2..1abfa686be 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_controller.cpp @@ -910,7 +910,7 @@ void PanelController::suggestReset(Fn callback) { .confirmed = [=] { resetPassport(callback); }, .cancelled = [=] { cancelReset(); }, .confirmText = Lang::Hard::PassportCorruptedReset(), - })).data()); + })).get()); } void PanelController::resetPassport(Fn callback) { @@ -921,7 +921,7 @@ void PanelController::resetPassport(Fn callback) { .confirmText = Lang::Hard::PassportCorruptedReset(), .confirmStyle = &st::attentionBoxButton, })); - _resetBox = Ui::BoxPointer(box.data()); + _resetBox = Ui::BoxPointer(box.get()); } void PanelController::cancelReset() { @@ -1210,7 +1210,7 @@ void PanelController::startScopeEdit( std::move(scans), std::move(translations), PrepareSpecialFiles(*_editDocument)); - const auto weak = Ui::MakeWeak(result.data()); + const auto weak = base::make_weak(result.data()); _panelHasUnsavedChanges = [=] { return weak ? weak->hasUnsavedChanges() : false; }; @@ -1229,7 +1229,7 @@ void PanelController::startScopeEdit( std::move(preferredLanguage)), _editValue->error, _editValue->data.parsedInEdit); - const auto weak = Ui::MakeWeak(result.data()); + const auto weak = base::make_weak(result.data()); _panelHasUnsavedChanges = [=] { return weak ? weak->hasUnsavedChanges() : false; }; diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.h b/Telegram/SourceFiles/passport/passport_panel_controller.h index 5c3d296b47..c08645056e 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.h +++ b/Telegram/SourceFiles/passport/passport_panel_controller.h @@ -174,7 +174,7 @@ private: std::unique_ptr _panel; Fn _panelHasUnsavedChanges; - QPointer _confirmForgetChangesBox; + base::weak_qptr _confirmForgetChangesBox; std::vector _editScopeBoxes; Scope *_editScope = nullptr; const Value *_editValue = nullptr; diff --git a/Telegram/SourceFiles/passport/ui/passport_details_row.cpp b/Telegram/SourceFiles/passport/ui/passport_details_row.cpp index 55739b7dbb..0fa946fd96 100644 --- a/Telegram/SourceFiles/passport/ui/passport_details_row.cpp +++ b/Telegram/SourceFiles/passport/ui/passport_details_row.cpp @@ -571,7 +571,7 @@ DateRow::DateRow( GetYear(value)) , _value(valueCurrent()) { const auto focused = [=](const object_ptr &field) { - return [this, pointer = MakeWeak(field.data())]{ + return [this, pointer = base::make_weak(field.data())]{ _borderAnimationStart = pointer->borderAnimationStart() + pointer->x() - _day->x(); diff --git a/Telegram/SourceFiles/payments/payments_checkout_process.cpp b/Telegram/SourceFiles/payments/payments_checkout_process.cpp index 379036e6e9..d27161660e 100644 --- a/Telegram/SourceFiles/payments/payments_checkout_process.cpp +++ b/Telegram/SourceFiles/payments/payments_checkout_process.cpp @@ -410,7 +410,7 @@ void CheckoutProcess::handleFormUpdate(const FormUpdate &update) { UnregisterPaymentStart(this); _submitState = SubmitState::Validated; _panel->showWarning(data.bot->name(), data.provider->name()); - if (const auto box = _enterPasswordBox.data()) { + if (const auto box = _enterPasswordBox.get()) { box->closeBox(); } }, [&](const VerificationNeeded &data) { @@ -534,7 +534,7 @@ void CheckoutProcess::handleError(const Error &error) { showToast({ "SmartGlocal Error: " + id }); } break; case Error::Type::TmpPassword: - if (const auto box = _enterPasswordBox.data()) { + if (const auto box = _enterPasswordBox.get()) { if (!box->handleCustomCheckError(id)) { showToast({ "Error: Could not generate tmp password." }); } @@ -542,7 +542,7 @@ void CheckoutProcess::handleError(const Error &error) { break; case Error::Type::Send: _sendFormFailed = true; - if (const auto box = _enterPasswordBox.data()) { + if (const auto box = _enterPasswordBox.get()) { box->closeBox(); } if (_submitState == SubmitState::Finishing) { @@ -857,7 +857,7 @@ void CheckoutProcess::requestPassword() { fields.customSubmitButton = tr::lng_payments_password_submit(); fields.customCheckCallback = [=]( const Core::CloudPasswordResult &result, - QPointer box) { + base::weak_qptr box) { _enterPasswordBox = box; _form->submit(result); }; diff --git a/Telegram/SourceFiles/payments/payments_checkout_process.h b/Telegram/SourceFiles/payments/payments_checkout_process.h index 2f52caf23f..ad6648c500 100644 --- a/Telegram/SourceFiles/payments/payments_checkout_process.h +++ b/Telegram/SourceFiles/payments/payments_checkout_process.h @@ -189,7 +189,7 @@ private: const not_null _session; const std::unique_ptr
_form; const std::unique_ptr _panel; - QPointer _enterPasswordBox; + base::weak_qptr _enterPasswordBox; Fn _reactivate; Fn _nonPanelPaymentFormProcess; SubmitState _submitState = SubmitState::None; diff --git a/Telegram/SourceFiles/payments/payments_reaction_process.cpp b/Telegram/SourceFiles/payments/payments_reaction_process.cpp index 3e5236fda1..3bea078d30 100644 --- a/Telegram/SourceFiles/payments/payments_reaction_process.cpp +++ b/Telegram/SourceFiles/payments/payments_reaction_process.cpp @@ -140,7 +140,7 @@ void ShowPaidReactionDetails( const auto chosen = std::clamp(kDefaultPerReaction, 1, max); struct State { - QPointer selectBox; + base::weak_qptr selectBox; bool ignoreShownPeerSwitch = false; bool sending = false; }; @@ -155,7 +155,7 @@ void ShowPaidReactionDetails( state->sending = false; if (success && count > 0) { state->ignoreShownPeerSwitch = true; - if (const auto strong = state->selectBox.data()) { + if (const auto strong = state->selectBox.get()) { strong->closeBox(); } } @@ -260,7 +260,7 @@ void ShowPaidReactionDetails( }, })); - if (const auto strong = state->selectBox.data()) { + if (const auto strong = state->selectBox.get()) { session->data().itemRemoved( ) | rpl::start_with_next([=](not_null removed) { if (removed == item) { diff --git a/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp b/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp index 67ad2c7cc0..9a0011234e 100644 --- a/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp @@ -236,7 +236,7 @@ void AddArrowDown(not_null widget) { } void SelectShownPeer( - std::shared_ptr> menu, + std::shared_ptr> menu, not_null parent, const std::vector &mine, uint64 selected, @@ -311,7 +311,7 @@ void FillTopReactors( bool chosenChanged = false; }; const auto state = wrap->lifetime().make_state(); - const auto menu = std::make_shared>(); + const auto menu = std::make_shared>(); rpl::combine( std::move(chosen), diff --git a/Telegram/SourceFiles/settings/business/settings_away_message.cpp b/Telegram/SourceFiles/settings/business/settings_away_message.cpp index 58f3a61656..181582fa3f 100644 --- a/Telegram/SourceFiles/settings/business/settings_away_message.cpp +++ b/Telegram/SourceFiles/settings/business/settings_away_message.cpp @@ -119,10 +119,10 @@ void AddAwayScheduleSelector( Fn max, Fn done) { using namespace Ui; - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto save = [=](TimeId time) { done(time); - if (const auto strong = box->data()) { + if (const auto strong = box->get()) { strong->closeBox(); } }; diff --git a/Telegram/SourceFiles/settings/business/settings_greeting.cpp b/Telegram/SourceFiles/settings/business/settings_greeting.cpp index 8437acc7c0..a65d6946dd 100644 --- a/Telegram/SourceFiles/settings/business/settings_greeting.cpp +++ b/Telegram/SourceFiles/settings/business/settings_greeting.cpp @@ -89,9 +89,9 @@ void EditPeriodBox( const auto take = TimePickerBox(box, values, phrases, days); box->addButton(tr::lng_settings_save(), [=] { - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); save(take()); - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->closeBox(); } }); diff --git a/Telegram/SourceFiles/settings/business/settings_quick_replies.cpp b/Telegram/SourceFiles/settings/business/settings_quick_replies.cpp index e59ef7061d..9c4bcf11bb 100644 --- a/Telegram/SourceFiles/settings/business/settings_quick_replies.cpp +++ b/Telegram/SourceFiles/settings/business/settings_quick_replies.cpp @@ -220,8 +220,8 @@ void EditShortcutNameBox( if (!ValidShortcutName(name)) { field->showError(); } else { - submit(name, [weak = Ui::MakeWeak(box)] { - if (const auto strong = weak.data()) { + submit(name, [weak = base::make_weak(box)] { + if (const auto strong = weak.get()) { strong->closeBox(); } }); diff --git a/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp b/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp index 135f7df7e3..eb3dc498ed 100644 --- a/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp +++ b/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp @@ -178,7 +178,7 @@ private: bool cornerButtonsUnreadMayBeShown() override; bool cornerButtonsHas(CornerButtonType type) override; - QPointer createPinnedToBottom( + base::weak_qptr createPinnedToBottom( not_null parent) override; void setupComposeControls(); void processScroll(); @@ -773,7 +773,7 @@ void ShortcutMessages::setupComposeControls() { }, lifetime()); } -QPointer ShortcutMessages::createPinnedToBottom( +base::weak_qptr ShortcutMessages::createPinnedToBottom( not_null parent) { auto placeholder = rpl::deferred([=] { return _shortcutId.value(); diff --git a/Telegram/SourceFiles/settings/business/settings_working_hours.cpp b/Telegram/SourceFiles/settings/business/settings_working_hours.cpp index 6e0bf6f504..00e4c291c0 100644 --- a/Telegram/SourceFiles/settings/business/settings_working_hours.cpp +++ b/Telegram/SourceFiles/settings/business/settings_working_hours.cpp @@ -255,12 +255,12 @@ void EditTimeBox( }); box->addButton(tr::lng_settings_save(), [=] { - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); save(std::clamp( ((*minutesStart) / 60 + minutes->current()->index()) * 60, low, high)); - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->closeBox(); } }); @@ -398,9 +398,9 @@ void EditDayBox( AddDividerText(container, tr::lng_hours_about_day()); box->addButton(tr::lng_settings_save(), [=] { - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); save(state->data.current()); - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->closeBox(); } }); @@ -457,9 +457,9 @@ void ChooseTimezoneBox( }); } group->setChangedCallback([=](int index) { - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); save(list[index].id); - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->closeBox(); } }); diff --git a/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_common.cpp b/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_common.cpp index e8bb2607ab..cdc53eb748 100644 --- a/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_common.cpp +++ b/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_common.cpp @@ -80,7 +80,7 @@ BottomButton CreateBottomDisableButton( divider->show(); return { - .content = Ui::MakeWeak(not_null{ content }), + .content = base::make_weak(content), .isBottomFillerShown = divider->geometryValue( ) | rpl::map([](const QRect &r) { return r.height() > 0; diff --git a/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_common.h b/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_common.h index a87c1aaed5..cd6a53b85d 100644 --- a/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_common.h +++ b/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_common.h @@ -82,7 +82,7 @@ void AddSkipInsteadOfField(not_null content); void AddSkipInsteadOfError(not_null content); struct BottomButton { - QPointer content; + base::weak_qptr content; rpl::producer isBottomFillerShown; }; diff --git a/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_input.cpp b/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_input.cpp index 7719fc2ddd..a7dd669b4f 100644 --- a/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_input.cpp +++ b/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_input.cpp @@ -126,7 +126,7 @@ public: using TypedAbstractStep::TypedAbstractStep; [[nodiscard]] rpl::producer title() override; - [[nodiscard]] QPointer createPinnedToTop( + [[nodiscard]] base::weak_qptr createPinnedToTop( not_null parent) override; void setupContent(); void setupValidateGood(); @@ -156,7 +156,7 @@ rpl::producer Input::title() { return tr::lng_settings_cloud_password_password_title(); } -QPointer Input::createPinnedToTop( +base::weak_qptr Input::createPinnedToTop( not_null parent) { _parent = parent; return nullptr; diff --git a/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_login_email_confirm.cpp b/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_login_email_confirm.cpp index 211c6dff48..31c4c2aeb6 100644 --- a/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_login_email_confirm.cpp +++ b/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_login_email_confirm.cpp @@ -124,14 +124,14 @@ void LoginEmailConfirm::setupContent() { newInput->setFocus(); newInput->showError(); } else { - const auto weak = Ui::MakeWeak(controller()->content()); + const auto weak = base::make_weak(controller()->content()); const auto done = [=] { _api.reset(); _processFinishes.fire({}); cloudPassword().reload(); setStepData(StepData()); showBack(); - if (const auto strong = weak) { + if (const auto strong = weak.get()) { Ui::StartFireworks(strong); } }; diff --git a/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_manage.cpp b/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_manage.cpp index 1f7a876738..1c6c484ef6 100644 --- a/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_manage.cpp +++ b/Telegram/SourceFiles/settings/cloud_password/settings_cloud_password_manage.cpp @@ -53,7 +53,7 @@ public: [[nodiscard]] rpl::producer title() override; void setupContent(); - [[nodiscard]] QPointer createPinnedToBottom( + [[nodiscard]] base::weak_qptr createPinnedToBottom( not_null parent) override; protected: @@ -184,7 +184,7 @@ void Manage::setupContent() { Ui::ResizeFitChild(this, content); } -QPointer Manage::createPinnedToBottom( +base::weak_qptr Manage::createPinnedToBottom( not_null parent) { const auto disable = [=](Fn close) { diff --git a/Telegram/SourceFiles/settings/settings_active_sessions.cpp b/Telegram/SourceFiles/settings/settings_active_sessions.cpp index 2b8368b4df..48150fdeb6 100644 --- a/Telegram/SourceFiles/settings/settings_active_sessions.cpp +++ b/Telegram/SourceFiles/settings/settings_active_sessions.cpp @@ -496,7 +496,7 @@ void SessionInfoBox( box->addButton(tr::lng_about_done(), [=] { box->closeBox(); }); if (const auto hash = data.hash) { box->addLeftButton(tr::lng_sessions_terminate(), [=] { - const auto weak = Ui::MakeWeak(box.get()); + const auto weak = base::make_weak(box.get()); terminate(hash); if (weak) { box->closeBox(); @@ -652,7 +652,7 @@ private: Full _data; object_ptr _inner; - QPointer _terminateBox; + base::weak_qptr _terminateBox; base::Timer _shortPollTimer; @@ -843,12 +843,12 @@ void SessionsContent::terminate(Fn terminateRequest, QString message) { .confirmText = tr::lng_settings_reset_button(), .confirmStyle = &st::attentionBoxButton, }); - _terminateBox = Ui::MakeWeak(box.data()); + _terminateBox = base::make_weak(box.data()); _controller->show(std::move(box)); } void SessionsContent::terminateOne(uint64 hash) { - const auto weak = Ui::MakeWeak(this); + const auto weak = base::make_weak(this); auto callback = [=] { auto done = crl::guard(weak, [=](const MTPBool &result) { if (mtpIsFalse(result)) { @@ -877,7 +877,7 @@ void SessionsContent::terminateOne(uint64 hash) { } void SessionsContent::terminateAll() { - const auto weak = Ui::MakeWeak(this); + const auto weak = base::make_weak(this); auto callback = [=] { const auto reset = crl::guard(weak, [=] { _authorizations->cancelCurrentRequest(); diff --git a/Telegram/SourceFiles/settings/settings_blocked_peers.cpp b/Telegram/SourceFiles/settings/settings_blocked_peers.cpp index c0b2a47463..fbb8a065ee 100644 --- a/Telegram/SourceFiles/settings/settings_blocked_peers.cpp +++ b/Telegram/SourceFiles/settings/settings_blocked_peers.cpp @@ -73,7 +73,7 @@ rpl::producer Blocked::title() { return tr::lng_settings_blocked_users(); } -QPointer Blocked::createPinnedToTop(not_null parent) { +base::weak_qptr Blocked::createPinnedToTop(not_null parent) { const auto content = Ui::CreateChild(parent.get()); Ui::AddSkip(content); @@ -118,7 +118,7 @@ QPointer Blocked::createPinnedToTop(not_null parent) { }, subtitle->lifetime()); } - return Ui::MakeWeak(not_null{ content }); + return base::make_weak(not_null{ content }); } void Blocked::setupContent() { diff --git a/Telegram/SourceFiles/settings/settings_blocked_peers.h b/Telegram/SourceFiles/settings/settings_blocked_peers.h index b534cd87ec..e8a8e7c2da 100644 --- a/Telegram/SourceFiles/settings/settings_blocked_peers.h +++ b/Telegram/SourceFiles/settings/settings_blocked_peers.h @@ -29,7 +29,7 @@ public: [[nodiscard]] rpl::producer title() override; - [[nodiscard]] QPointer createPinnedToTop( + [[nodiscard]] base::weak_qptr createPinnedToTop( not_null parent) override; private: diff --git a/Telegram/SourceFiles/settings/settings_business.cpp b/Telegram/SourceFiles/settings/settings_business.cpp index a59c30b63f..a619971545 100644 --- a/Telegram/SourceFiles/settings/settings_business.cpp +++ b/Telegram/SourceFiles/settings/settings_business.cpp @@ -332,9 +332,9 @@ public: [[nodiscard]] rpl::producer title() override; - [[nodiscard]] QPointer createPinnedToTop( + [[nodiscard]] base::weak_qptr createPinnedToTop( not_null parent) override; - [[nodiscard]] QPointer createPinnedToBottom( + [[nodiscard]] base::weak_qptr createPinnedToBottom( not_null parent) override; void showFinished() override; @@ -582,7 +582,7 @@ void Business::setupContent() { Ui::ResizeFitChild(this, content); } -QPointer Business::createPinnedToTop( +base::weak_qptr Business::createPinnedToTop( not_null parent) { auto title = tr::lng_business_title(); auto about = [&]() -> rpl::producer { @@ -671,14 +671,14 @@ QPointer Business::createPinnedToTop( } }, content->lifetime()); - return Ui::MakeWeak(not_null{ content }); + return base::make_weak(not_null{ content }); } void Business::showFinished() { _showFinished.fire({}); } -QPointer Business::createPinnedToBottom( +base::weak_qptr Business::createPinnedToBottom( not_null parent) { const auto content = Ui::CreateChild(parent.get()); @@ -747,7 +747,7 @@ QPointer Business::createPinnedToBottom( _subscribe->setVisible(!premium && premiumPossible); }, _subscribe->lifetime()); - return Ui::MakeWeak(not_null{ content }); + return base::make_weak(not_null{ content }); } } // namespace diff --git a/Telegram/SourceFiles/settings/settings_calls.cpp b/Telegram/SourceFiles/settings/settings_calls.cpp index 16d3f3a249..d80f394a24 100644 --- a/Telegram/SourceFiles/settings/settings_calls.cpp +++ b/Telegram/SourceFiles/settings/settings_calls.cpp @@ -483,7 +483,7 @@ void ChooseMediaDeviceBox( state->currentId = std::move(currentId); const auto choose = [=](const QString &id) { - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); chosen(id); if (weak) { box->closeBox(); diff --git a/Telegram/SourceFiles/settings/settings_common.h b/Telegram/SourceFiles/settings/settings_common.h index 6a9e214951..bf4102f391 100644 --- a/Telegram/SourceFiles/settings/settings_common.h +++ b/Telegram/SourceFiles/settings/settings_common.h @@ -88,11 +88,11 @@ public: [[nodiscard]] virtual const Ui::RoundRect *bottomSkipRounding() const { return nullptr; } - [[nodiscard]] virtual QPointer createPinnedToTop( + [[nodiscard]] virtual base::weak_qptr createPinnedToTop( not_null parent) { return nullptr; } - [[nodiscard]] virtual QPointer createPinnedToBottom( + [[nodiscard]] virtual base::weak_qptr createPinnedToBottom( not_null parent) { return nullptr; } diff --git a/Telegram/SourceFiles/settings/settings_credits.cpp b/Telegram/SourceFiles/settings/settings_credits.cpp index 1ed8c28c51..b893508a66 100644 --- a/Telegram/SourceFiles/settings/settings_credits.cpp +++ b/Telegram/SourceFiles/settings/settings_credits.cpp @@ -73,7 +73,7 @@ public: [[nodiscard]] rpl::producer title() override; - [[nodiscard]] QPointer createPinnedToTop( + [[nodiscard]] base::weak_qptr createPinnedToTop( not_null parent) override; void showFinished() override; @@ -603,7 +603,7 @@ void Credits::setupContent() { Ui::ResizeFitChild(this, content); } -QPointer Credits::createPinnedToTop( +base::weak_qptr Credits::createPinnedToTop( not_null parent) { _parent = parent; const auto isCurrency = _creditsType == CreditsType::Ton; @@ -722,7 +722,7 @@ QPointer Credits::createPinnedToTop( } }, content->lifetime()); - return Ui::MakeWeak(not_null{ content }); + return base::make_weak(not_null{ content }); } void Credits::showFinished() { @@ -799,9 +799,9 @@ Fn BuyStarsHandler::handler( ? _api->options() : Data::CreditTopupOptions(); const auto amount = CreditsAmount(); - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); FillCreditOptions(show, inner, self, amount, [=] { - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->closeBox(); } if (const auto onstack = paid) { diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 2850e85a01..decb554373 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -625,9 +625,9 @@ void FillCreditOptions( .giftPeerId = PeerId(option.giftBarePeerId), }; - const auto weak = Ui::MakeWeak(button); + const auto weak = base::make_weak(button); const auto done = [=](Payments::CheckoutResult result) { - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->window()->setFocus(); if (result == Payments::CheckoutResult::Paid) { if (const auto onstack = paid) { @@ -889,10 +889,10 @@ void BoostCreditsBox( } void ProcessReceivedSubscriptions( - QPointer weak, + base::weak_qptr weak, not_null session) { const auto rebuilder = session->data().activeCreditsSubsRebuilder(); - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { if (!rebuilder) { return strong->closeBox(); } @@ -903,7 +903,7 @@ void ProcessReceivedSubscriptions( true); api->requestSubscriptions({}, [=](Data::CreditsStatusSlice first) { rebuilder->fire(std::move(first)); - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->closeBox(); } }); @@ -1759,7 +1759,7 @@ void GenericCreditsEntryBox( && !e.giftTransferred && !e.giftRefunded && !e.converted; - const auto toggleVisibility = [=, weak = Ui::MakeWeak(box)](bool save) { + const auto toggleVisibility = [=, weak = base::make_weak(box)](bool save) { const auto showSection = !e.fromGiftsList; const auto savedId = EntryToSavedStarGiftId(&show->session(), e); const auto done = [=](bool ok) { @@ -1771,7 +1771,7 @@ void GenericCreditsEntryBox( Info::Section::Type::PeerGifts)); } } - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { if (ok) { strong->closeBox(); } else { @@ -1817,7 +1817,7 @@ void GenericCreditsEntryBox( const auto canUpgradeFree = canUpgrade && (e.starsUpgradedBySender > 0); if (isStarGift && e.id.isEmpty()) { - const auto convert = [=, weak = Ui::MakeWeak(box)] { + const auto convert = [=, weak = base::make_weak(box)] { const auto stars = e.starsConverted; const auto days = canConvert ? ((timeLeft + 86399) / 86400) : 0; auto text = giftToChannelCanManage @@ -1851,7 +1851,7 @@ void GenericCreditsEntryBox( .action = GiftAction::Convert, }); } - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { if (ok) { strong->closeBox(); } else { @@ -1973,7 +1973,7 @@ void GenericCreditsEntryBox( if (button != Qt::LeftButton) { return false; } - const auto done = [=, weak = Ui::MakeWeak(box)] { + const auto done = [=, weak = base::make_weak(box)] { ProcessReceivedSubscriptions(weak, session); }; const auto fail = [=, s = box->uiShow()](const QString &e) { @@ -2024,7 +2024,7 @@ void GenericCreditsEntryBox( ? tr::lng_gift_show_on_channel : tr::lng_gift_show_on_page)() : tr::lng_box_ok())); - const auto send = [=, weak = Ui::MakeWeak(box)] { + const auto send = [=, weak = base::make_weak(box)] { if (toRejoin && !toRenew) { if (const auto window = show->resolveWindow()) { const auto finish = [=](Payments::CheckoutResult&&) { @@ -2049,7 +2049,7 @@ void GenericCreditsEntryBox( ProcessReceivedSubscriptions(weak, session); }; const auto fail = [=, show = box->uiShow()](const QString &e) { - if ([[maybe_unused]] const auto strong = weak.data()) { + if ([[maybe_unused]] const auto strong = weak.get()) { state->confirmButtonBusy = false; } show->showToast(e); diff --git a/Telegram/SourceFiles/settings/settings_folders.cpp b/Telegram/SourceFiles/settings/settings_folders.cpp index bd5d8be137..1c5129e2f2 100644 --- a/Telegram/SourceFiles/settings/settings_folders.cpp +++ b/Telegram/SourceFiles/settings/settings_folders.cpp @@ -353,7 +353,7 @@ void FilterRowButton::paintEvent(QPaintEvent *e) { not_null*> tagsButtonEnabled) { auto &lifetime = container->lifetime(); - const auto weak = Ui::MakeWeak(container); + const auto weak = base::make_weak(container); const auto session = &controller->session(); const auto limit = [=] { return Data::PremiumLimits(session).dialogFiltersCurrent(); @@ -909,9 +909,9 @@ void SetupTagContent( tagsButton->setToggleLocked(!value); }, tagsButton->lifetime()); - const auto send = [=, weak = Ui::MakeWeak(tagsButton)](bool checked) { + const auto send = [=, weak = base::make_weak(tagsButton)](bool checked) { session->data().chatsFilters().requestToggleTags(checked, [=] { - if ([[maybe_unused]] const auto strong = weak.data()) { + if ([[maybe_unused]] const auto strong = weak.get()) { state->tagsTurnOff.fire(!checked); } }); diff --git a/Telegram/SourceFiles/settings/settings_local_passcode.cpp b/Telegram/SourceFiles/settings/settings_local_passcode.cpp index 8f639c30a6..75943bcaef 100644 --- a/Telegram/SourceFiles/settings/settings_local_passcode.cpp +++ b/Telegram/SourceFiles/settings/settings_local_passcode.cpp @@ -404,7 +404,7 @@ public: [[nodiscard]] rpl::producer> removeFromStack() override; - [[nodiscard]] QPointer createPinnedToBottom( + [[nodiscard]] base::weak_qptr createPinnedToBottom( not_null parent) override; private: @@ -606,7 +606,7 @@ void LocalPasscodeManage::setupContent() { Ui::ResizeFitChild(this, content); } -QPointer LocalPasscodeManage::createPinnedToBottom( +base::weak_qptr LocalPasscodeManage::createPinnedToBottom( not_null parent) { auto callback = [=] { _controller->show( diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index f7098544c6..e212d2c457 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -478,7 +478,7 @@ void SetupValidatePhoneNumberSuggestion( st::inviteLinkButton); no->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); no->setClickedCallback([=] { - const auto sharedLabel = std::make_shared>(); + const auto sharedLabel = std::make_shared>(); const auto height = st::boxLabel.style.font->height; const auto customEmojiFactory = [=]( QStringView data, diff --git a/Telegram/SourceFiles/settings/settings_notifications_type.cpp b/Telegram/SourceFiles/settings/settings_notifications_type.cpp index df18b65ee1..391f63babb 100644 --- a/Telegram/SourceFiles/settings/settings_notifications_type.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications_type.cpp @@ -530,7 +530,7 @@ void SetupExceptions( state->controller->setDelegate(state->delegate.get()); add->setClickedCallback([=] { - const auto box = std::make_shared>(); + const auto box = std::make_shared>(); const auto done = [=](not_null peer) { state->controller->bringToTop(peer); if (*box) { diff --git a/Telegram/SourceFiles/settings/settings_premium.cpp b/Telegram/SourceFiles/settings/settings_premium.cpp index 76d93b9d5d..2b04f6db57 100644 --- a/Telegram/SourceFiles/settings/settings_premium.cpp +++ b/Telegram/SourceFiles/settings/settings_premium.cpp @@ -863,9 +863,9 @@ public: [[nodiscard]] rpl::producer title() override; - [[nodiscard]] QPointer createPinnedToTop( + [[nodiscard]] base::weak_qptr createPinnedToTop( not_null parent) override; - [[nodiscard]] QPointer createPinnedToBottom( + [[nodiscard]] base::weak_qptr createPinnedToBottom( not_null parent) override; void showFinished() override; @@ -1023,7 +1023,7 @@ void Premium::setupContent() { } -QPointer Premium::createPinnedToTop( +base::weak_qptr Premium::createPinnedToTop( not_null parent) { auto title = _controller->session().premium() ? tr::lng_premium_summary_title() @@ -1168,14 +1168,14 @@ QPointer Premium::createPinnedToTop( } }, content->lifetime()); - return Ui::MakeWeak(not_null{ content }); + return base::make_weak(not_null{ content }); } void Premium::showFinished() { _showFinished.fire({}); } -QPointer Premium::createPinnedToBottom( +base::weak_qptr Premium::createPinnedToBottom( not_null parent) { const auto content = Ui::CreateChild(parent.get()); @@ -1278,7 +1278,7 @@ QPointer Premium::createPinnedToBottom( _subscribe->setVisible(!premium && premiumPossible); }, _subscribe->lifetime()); - return Ui::MakeWeak(not_null{ content }); + return base::make_weak(not_null{ content }); } } // namespace diff --git a/Telegram/SourceFiles/settings/settings_shortcuts.cpp b/Telegram/SourceFiles/settings/settings_shortcuts.cpp index 9d5135f614..ecd2f7914c 100644 --- a/Telegram/SourceFiles/settings/settings_shortcuts.cpp +++ b/Telegram/SourceFiles/settings/settings_shortcuts.cpp @@ -194,7 +194,7 @@ struct Labeled { }; checkModified(); - const auto menu = std::make_shared>(); + const auto menu = std::make_shared>(); const auto fill = [=](Entry &entry) { auto index = 0; if (entry.original.empty()) { diff --git a/Telegram/SourceFiles/settings/settings_websites.cpp b/Telegram/SourceFiles/settings/settings_websites.cpp index 7f495998f0..f74ae4c800 100644 --- a/Telegram/SourceFiles/settings/settings_websites.cpp +++ b/Telegram/SourceFiles/settings/settings_websites.cpp @@ -182,7 +182,7 @@ void InfoBox( box->addButton(tr::lng_about_done(), [=] { box->closeBox(); }); if (const auto hash = data.hash) { box->addLeftButton(tr::lng_settings_disconnect(), [=] { - const auto weak = Ui::MakeWeak(box.get()); + const auto weak = base::make_weak(box.get()); terminate(hash); if (weak) { box->closeBox(); @@ -334,7 +334,7 @@ private: Api::Websites::List _data; object_ptr _inner; - QPointer _terminateBox; + base::weak_qptr _terminateBox; base::Timer _shortPollTimer; @@ -492,7 +492,7 @@ void Content::terminate( rpl::producer title, rpl::producer text, QString blockText) { - if (const auto strong = _terminateBox.data()) { + if (const auto strong = _terminateBox.get()) { strong->deleteLater(); } auto box = Box([=](not_null box) { @@ -517,12 +517,12 @@ void Content::terminate( *block = box->addRow(object_ptr(box, blockText)); } }); - _terminateBox = Ui::MakeWeak(box.data()); + _terminateBox = base::make_weak(box.data()); _controller->show(std::move(box)); } void Content::terminateOne(uint64 hash) { - const auto weak = Ui::MakeWeak(this); + const auto weak = base::make_weak(this); const auto i = ranges::find(_data, hash, &EntryData::hash); if (i == end(_data)) { return; @@ -552,7 +552,7 @@ void Content::terminateOne(uint64 hash) { } void Content::terminateAll() { - const auto weak = Ui::MakeWeak(this); + const auto weak = base::make_weak(this); auto callback = [=](bool block) { const auto reset = crl::guard(weak, [=] { _websites->cancelCurrentRequest(); diff --git a/Telegram/SourceFiles/stdafx.h b/Telegram/SourceFiles/stdafx.h index 6647362881..b111130433 100644 --- a/Telegram/SourceFiles/stdafx.h +++ b/Telegram/SourceFiles/stdafx.h @@ -128,7 +128,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/arc_angles.h" #include "ui/emoji_config.h" #include "ui/qt_object_factory.h" -#include "ui/qt_weak_factory.h" #include "ui/ui_rpl_filter.h" #include "styles/palette.h" diff --git a/Telegram/SourceFiles/support/support_autocomplete.cpp b/Telegram/SourceFiles/support/support_autocomplete.cpp index 45ad83edde..8122a476a2 100644 --- a/Telegram/SourceFiles/support/support_autocomplete.cpp +++ b/Telegram/SourceFiles/support/support_autocomplete.cpp @@ -520,7 +520,7 @@ void ConfirmContactBox::prepare() { _contact->initDimensions(); _submit = [=, original = std::move(_submit)](Qt::KeyboardModifiers m) { - const auto weak = Ui::MakeWeak(this); + const auto weak = base::make_weak(this); original(m); if (weak) { closeBox(); diff --git a/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp b/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp index 8651b5b010..0dfc516056 100644 --- a/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp +++ b/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp @@ -147,7 +147,7 @@ ChooseDateTimeBoxDescriptor ChooseDateTimeBox( }, content->lifetime()); const auto calendar - = content->lifetime().make_state>(); + = content->lifetime().make_state>(); const auto calendarStyle = args.style.calendarStyle; state->day->focusedChanges( ) | rpl::start_with_next([=](bool focused) { diff --git a/Telegram/SourceFiles/ui/boxes/choose_font_box.cpp b/Telegram/SourceFiles/ui/boxes/choose_font_box.cpp index 97f65b65d9..a891c422f1 100644 --- a/Telegram/SourceFiles/ui/boxes/choose_font_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/choose_font_box.cpp @@ -819,7 +819,7 @@ void PreviewPainter::layout() { const auto ratio = state->preview.devicePixelRatio(); raw->resize(state->preview.size() / int(ratio)); } else { - const auto weak = Ui::MakeWeak(raw); + const auto weak = base::make_weak(raw); const auto request = PrepareRequest(family); crl::async([=, bg = state->bg] { crl::on_main([ @@ -827,7 +827,7 @@ void PreviewPainter::layout() { state, preview = GeneratePreview(bg, request) ]() mutable { - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { state->preview = std::move(preview); const auto ratio = state->preview.devicePixelRatio(); strong->resize( diff --git a/Telegram/SourceFiles/ui/boxes/choose_time.cpp b/Telegram/SourceFiles/ui/boxes/choose_time.cpp index aa7f2836e2..ba2bdba9a7 100644 --- a/Telegram/SourceFiles/ui/boxes/choose_time.cpp +++ b/Telegram/SourceFiles/ui/boxes/choose_time.cpp @@ -76,9 +76,9 @@ ChooseTimeResult ChooseTimeWidget( QString::number(startMinutes)), }); - const auto day = Ui::MakeWeak(state->day); - const auto hour = Ui::MakeWeak(state->hour); - const auto minute = Ui::MakeWeak(state->minute); + const auto day = base::make_weak(state->day); + const auto hour = base::make_weak(state->hour); + const auto minute = base::make_weak(state->minute); if (hiddenDaysInput) { day->setVisible(false); @@ -88,24 +88,24 @@ ChooseTimeResult ChooseTimeWidget( day->setMaxValue(31); day->setWheelStep(1); day->putNext() | rpl::start_with_next([=](QChar ch) { - putNext(hour, ch); + putNext(hour.get(), ch); }, content->lifetime()); hour->setPhrase(tr::lng_hours); hour->setMaxValue(23); hour->setWheelStep(1); hour->putNext() | rpl::start_with_next([=](QChar ch) { - putNext(minute, ch); + putNext(minute.get(), ch); }, content->lifetime()); hour->erasePrevious() | rpl::start_with_next([=] { - erasePrevious(day); + erasePrevious(day.get()); }, content->lifetime()); minute->setPhrase(tr::lng_minutes); minute->setMaxValue(59); minute->setWheelStep(10); minute->erasePrevious() | rpl::start_with_next([=] { - erasePrevious(hour); + erasePrevious(hour.get()); }, content->lifetime()); content->sizeValue( @@ -127,9 +127,9 @@ ChooseTimeResult ChooseTimeWidget( rpl::merge( rpl::single(rpl::empty), - base::qt_signal_producer(day.data(), &MaskedInputField::changed), - base::qt_signal_producer(hour.data(), &MaskedInputField::changed), - base::qt_signal_producer(minute.data(), &MaskedInputField::changed) + base::qt_signal_producer(day.get(), &MaskedInputField::changed), + base::qt_signal_producer(hour.get(), &MaskedInputField::changed), + base::qt_signal_producer(minute.get(), &MaskedInputField::changed) ) | rpl::start_with_next([=] { state->valueInSeconds = 0 + day->getLastText().toUInt() * 3600 * 24 diff --git a/Telegram/SourceFiles/ui/boxes/confirm_box.cpp b/Telegram/SourceFiles/ui/boxes/confirm_box.cpp index 0c06fb5262..6d9f25c984 100644 --- a/Telegram/SourceFiles/ui/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/confirm_box.cpp @@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Ui { void ConfirmBox(not_null box, ConfirmBoxArgs &&args) { - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); const auto lifetime = box->lifetime().make_state(); const auto withTitle = !v::is_null(args.title); diff --git a/Telegram/SourceFiles/ui/boxes/edit_invite_link.cpp b/Telegram/SourceFiles/ui/boxes/edit_invite_link.cpp index 49905b87e2..4b0bf0c136 100644 --- a/Telegram/SourceFiles/ui/boxes/edit_invite_link.cpp +++ b/Telegram/SourceFiles/ui/boxes/edit_invite_link.cpp @@ -286,7 +286,7 @@ void EditInviteLinkBox( } }; - const auto guard = MakeWeak(box); + const auto guard = base::make_weak(box); expireGroup->setChangedCallback([=](int value) { if (value) { state->expireValue = value; diff --git a/Telegram/SourceFiles/ui/boxes/peer_qr_box.cpp b/Telegram/SourceFiles/ui/boxes/peer_qr_box.cpp index e49e457454..0585a18f21 100644 --- a/Telegram/SourceFiles/ui/boxes/peer_qr_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/peer_qr_box.cpp @@ -897,7 +897,7 @@ void FillPeerQrBox( const auto top = photoSize ? userpicMedia->image(photoSize) : QImage(); - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); crl::async([=] { const auto qrImage = TelegramQr( diff --git a/Telegram/SourceFiles/ui/boxes/single_choice_box.cpp b/Telegram/SourceFiles/ui/boxes/single_choice_box.cpp index 2083a0f483..10303d64a9 100644 --- a/Telegram/SourceFiles/ui/boxes/single_choice_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/single_choice_box.cpp @@ -46,7 +46,7 @@ void SingleChoiceBox( } const auto callback = args.callback.value(); group->setChangedCallback([=](int value) { - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); callback(value); if (weak) { box->closeBox(); diff --git a/Telegram/SourceFiles/ui/chat/choose_send_as.cpp b/Telegram/SourceFiles/ui/chat/choose_send_as.cpp index d7c7f08ab3..be0fa5601b 100644 --- a/Telegram/SourceFiles/ui/chat/choose_send_as.cpp +++ b/Telegram/SourceFiles/ui/chat/choose_send_as.cpp @@ -198,7 +198,7 @@ void ChooseSendAsBox( controller->clicked( ) | rpl::start_with_next([=](not_null peer) { - const auto weak = MakeWeak(box); + const auto weak = base::make_weak(box); if (done(peer) && weak) { box->closeBox(); } diff --git a/Telegram/SourceFiles/ui/controls/subsection_tabs_slider.cpp b/Telegram/SourceFiles/ui/controls/subsection_tabs_slider.cpp index 68c64708d7..42b0830749 100644 --- a/Telegram/SourceFiles/ui/controls/subsection_tabs_slider.cpp +++ b/Telegram/SourceFiles/ui/controls/subsection_tabs_slider.cpp @@ -384,7 +384,7 @@ void SubsectionSlider::activate(int index) { } } }; - const auto weak = MakeWeak(_bar); + const auto weak = base::make_weak(_bar); _sectionActivated.fire_copy(index); if (weak) { const auto duration = st::chatTabsSlider.duration; diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index bdf77d1c18..3cb78ae180 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -72,7 +72,7 @@ void CountryInput::mousePressEvent(QMouseEvent *e) { mouseMoveEvent(e); if (_active) { auto object = Box(); - const auto box = Ui::MakeWeak(object.data()); + const auto box = base::make_weak(object.data()); _show->showBox(std::move(object), Ui::LayerOption::CloseOther); box->entryChosen( ) | rpl::start_with_next([=]( diff --git a/Telegram/SourceFiles/ui/effects/scroll_content_shadow.cpp b/Telegram/SourceFiles/ui/effects/scroll_content_shadow.cpp index 5bc42cb8df..392caf2602 100644 --- a/Telegram/SourceFiles/ui/effects/scroll_content_shadow.cpp +++ b/Telegram/SourceFiles/ui/effects/scroll_content_shadow.cpp @@ -32,9 +32,9 @@ void SetupShadowsToScrollContent( bottomShadow->move( geometry.x(), geometry.y() + geometry.height() - st::lineWidth); - }, [t = Ui::MakeWeak(topShadow), b = Ui::MakeWeak(bottomShadow)] { - Ui::DestroyChild(t.data()); - Ui::DestroyChild(b.data()); + }, [t = base::make_weak(topShadow), b = base::make_weak(bottomShadow)] { + Ui::DestroyChild(t.get()); + Ui::DestroyChild(b.get()); }, topShadow->lifetime()); topShadow->toggleOn(scroll->scrollTopValue() | rpl::map(_1 > 0)); diff --git a/Telegram/SourceFiles/ui/ui_pch.h b/Telegram/SourceFiles/ui/ui_pch.h index eb9a86a713..f00ef0bf92 100644 --- a/Telegram/SourceFiles/ui/ui_pch.h +++ b/Telegram/SourceFiles/ui/ui_pch.h @@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/basic_types.h" #include "base/flat_map.h" #include "base/flat_set.h" +#include "base/weak_qptr.h" #include "core/credits_amount.h" @@ -40,5 +41,4 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/text.h" #include "ui/effects/animations.h" #include "ui/qt_object_factory.h" -#include "ui/qt_weak_factory.h" #include "styles/palette.h" diff --git a/Telegram/SourceFiles/ui/widgets/chat_filters_tabs_strip.cpp b/Telegram/SourceFiles/ui/widgets/chat_filters_tabs_strip.cpp index 176b5644c4..96a66687bb 100644 --- a/Telegram/SourceFiles/ui/widgets/chat_filters_tabs_strip.cpp +++ b/Telegram/SourceFiles/ui/widgets/chat_filters_tabs_strip.cpp @@ -88,7 +88,7 @@ void ShowMenu( addAction); auto showRemoveBox = [=] { - state->removeApi.request(Ui::MakeWeak(parent), controller, id); + state->removeApi.request(base::make_weak(parent), controller, id); }; addAction({ .text = tr::lng_filters_context_remove(tr::now), diff --git a/Telegram/SourceFiles/window/section_widget.cpp b/Telegram/SourceFiles/window/section_widget.cpp index 95944d2f90..29da7f47ad 100644 --- a/Telegram/SourceFiles/window/section_widget.cpp +++ b/Telegram/SourceFiles/window/section_widget.cpp @@ -264,7 +264,7 @@ void SectionWidget::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; diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp index e7baf9c612..deba4892ad 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp @@ -725,7 +725,7 @@ void Editor::showMenu() { _menu = base::make_unique_q( this, st::dropdownMenuWithIcons); - _menu->setHiddenCallback([weak = Ui::MakeWeak(this), menu = _menu.get()]{ + _menu->setHiddenCallback([weak = base::make_weak(this), menu = _menu.get()]{ menu->deleteLater(); if (weak && weak->_menu == menu) { weak->_menu = nullptr; diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_block.h b/Telegram/SourceFiles/window/themes/window_theme_editor_block.h index 3b3f256afe..b41e479c50 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_block.h +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_block.h @@ -26,8 +26,8 @@ public: }; struct Context { struct { - QPointer box; - QPointer editor; + base::weak_qptr box; + base::weak_qptr editor; } colorEditor; QString name; QString possibleCopyOf; diff --git a/Telegram/SourceFiles/window/window_chat_preview.cpp b/Telegram/SourceFiles/window/window_chat_preview.cpp index 2a9607accb..68498ec087 100644 --- a/Telegram/SourceFiles/window/window_chat_preview.cpp +++ b/Telegram/SourceFiles/window/window_chat_preview.cpp @@ -54,7 +54,7 @@ bool ChatPreviewManager::show( return false; } _menu = std::move(preview.menu); - const auto weakMenu = Ui::MakeWeak(_menu.get()); + const auto weakMenu = base::make_weak(_menu.get()); const auto weakThread = base::make_weak(row.key.entry()->asThread()); const auto weakController = base::make_weak(_controller); std::move( @@ -82,7 +82,7 @@ bool ChatPreviewManager::show( } } } - if (const auto strong = weakMenu.data()) { + if (const auto strong = weakMenu.get()) { strong->hideMenu(); } }, _menu->lifetime()); diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index fb47a4050e..437e75f0d5 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -276,7 +276,7 @@ void Controller::checkLockByTerms() { showTermsDecline(); }, box->lifetime()); - QObject::connect(box, &QObject::destroyed, [=] { + QObject::connect(box.get(), &QObject::destroyed, [=] { crl::on_main(widget(), [=] { checkLockByTerms(); }); }); diff --git a/Telegram/SourceFiles/window/window_controller.h b/Telegram/SourceFiles/window/window_controller.h index 3eb6184e9d..a1a2d23b4e 100644 --- a/Telegram/SourceFiles/window/window_controller.h +++ b/Telegram/SourceFiles/window/window_controller.h @@ -98,11 +98,11 @@ public: typename BoxType, typename = std::enable_if_t< std::is_base_of_v>> - QPointer show( + base::weak_qptr show( object_ptr content, Ui::LayerOptions options = Ui::LayerOption::KeepOther, anim::type animated = anim::type()) { - auto result = QPointer(content.data()); + auto result = base::weak_qptr(content.data()); showBox(std::move(content), options, animated); return result; } @@ -168,7 +168,7 @@ private: const std::unique_ptr _adaptive; std::unique_ptr _sessionController; rpl::variable _sessionControllerValue; - QPointer _termsBox; + base::weak_qptr _termsBox; rpl::event_stream _openInMediaViewRequests; diff --git a/Telegram/SourceFiles/window/window_filters_menu.cpp b/Telegram/SourceFiles/window/window_filters_menu.cpp index 1e71a84b78..b23efa32f9 100644 --- a/Telegram/SourceFiles/window/window_filters_menu.cpp +++ b/Telegram/SourceFiles/window/window_filters_menu.cpp @@ -389,7 +389,7 @@ void FiltersMenu::showMenu(QPoint position, FilterId id) { addAction({ .text = tr::lng_filters_context_remove(tr::now), .handler = crl::guard(&_outer, [=, this] { - _removeApi.request(Ui::MakeWeak(&_outer), _session, id); + _removeApi.request(base::make_weak(&_outer), _session, id); }), .icon = &st::menuIconDeleteAttention, .isAttention = true, diff --git a/Telegram/SourceFiles/window/window_lock_widgets.cpp b/Telegram/SourceFiles/window/window_lock_widgets.cpp index b674458d11..3e2f6cb0ce 100644 --- a/Telegram/SourceFiles/window/window_lock_widgets.cpp +++ b/Telegram/SourceFiles/window/window_lock_widgets.cpp @@ -212,10 +212,10 @@ void PasscodeLockWidget::suggestSystemUnlock() { ) | rpl::filter( rpl::mappers::_1 != SystemUnlockType::None ) | rpl::take(1) | rpl::start_with_next([=] { - const auto weak = Ui::MakeWeak(this); + const auto weak = base::make_weak(this); const auto done = [weak](SystemUnlockResult result) { crl::on_main([=] { - if (const auto strong = weak.data()) { + if (const auto strong = weak.get()) { strong->systemUnlockDone(result); } }); diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 7c0deede45..9c52ca45d6 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -751,7 +751,7 @@ void MainMenu::setupMenu() { tr::lng_theme_editor_cant_change_theme())); return; } - const auto weak = MakeWeak(this); + const auto weak = base::make_weak(this); const auto toggle = [=] { if (!weak) { Window::Theme::ToggleNightMode(); @@ -941,7 +941,7 @@ base::EventFilterResult MainMenu::redirectToInnerChecked(not_null e) { if (_insideEventRedirect) { return base::EventFilterResult::Continue; } - const auto weak = Ui::MakeWeak(this); + const auto weak = base::make_weak(this); _insideEventRedirect = true; QGuiApplication::sendEvent(_inner, e); if (weak) { diff --git a/Telegram/SourceFiles/window/window_main_menu_helpers.cpp b/Telegram/SourceFiles/window/window_main_menu_helpers.cpp index baf22753d5..0a05a3371e 100644 --- a/Telegram/SourceFiles/window/window_main_menu_helpers.cpp +++ b/Telegram/SourceFiles/window/window_main_menu_helpers.cpp @@ -353,7 +353,7 @@ void SetupMenuBots( st::mainMenuButton.iconLeft, (height - icon->height()) / 2); }, button->lifetime()); - const auto weak = Ui::MakeWeak(container); + const auto weak = base::make_weak(container); const auto show = controller->uiShow(); button->setAcceptBoth(true); button->clicks( diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index d16067c79f..58775ff4cb 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1832,7 +1832,7 @@ void PeerMenuShareContactBox( return; } // There is no async to make weak from controller. - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); auto callback = [=](not_null thread) { const auto peer = thread->peer(); if (!Data::CanSend(thread, ChatRestriction::SendOther)) { @@ -1956,7 +1956,7 @@ void PeerMenuCreatePoll( SendPaymentHelper sendPayment; bool lock = false; }; - const auto weak = QPointer(box); + const auto weak = base::make_weak(box); const auto state = box->lifetime().make_state(); state->create = [=](const CreatePollBox::Result &result) { auto action = Api::SendAction( @@ -2066,7 +2066,7 @@ void PeerMenuCreateTodoList( SendPaymentHelper sendPayment; bool lock = false; }; - const auto weak = QPointer(box); + const auto weak = base::make_weak(box); const auto state = box->lifetime().make_state(); state->create = [=](const EditTodoListBox::Result &result) { const auto withPaymentApproved = crl::guard(weak, [=](int stars) { @@ -2126,7 +2126,7 @@ void PeerMenuEditTodoList( return; } auto box = Box(controller, item); - const auto weak = QPointer(box); + const auto weak = base::make_weak(box); box->submitRequests( ) | rpl::start_with_next([=](const EditTodoListBox::Result &result) { const auto api = &item->history()->session().api(); @@ -2328,7 +2328,7 @@ object_ptr PrepareChooseRecipientBox( Fn>, Api::SendOptions)> sendMany) { - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); const auto selectable = (sendMany != nullptr); class Controller final : public ChooseRecipientBoxController { public: @@ -2463,7 +2463,7 @@ object_ptr PrepareChooseRecipientBox( state->refreshStarsToSend(); const auto shown = raw->hasSelected(); if (shown) { - const auto weak = Ui::MakeWeak(box); + const auto weak = base::make_weak(box); state->submit = [=](Api::SendOptions options) { state->submitLifetime.destroy(); const auto show = box->peerListUiShow(); @@ -2551,7 +2551,7 @@ object_ptr PrepareChooseRecipientBox( return result; } -QPointer ShowChooseRecipientBox( +base::weak_qptr ShowChooseRecipientBox( not_null navigation, FnMut)> &&chosen, rpl::producer titleOverride, @@ -2565,7 +2565,7 @@ QPointer ShowChooseRecipientBox( typesRestriction)); } -QPointer ShowForwardMessagesBox( +base::weak_qptr ShowForwardMessagesBox( std::shared_ptr show, Data::ForwardDraft &&draft, Fn &&successCallback) { @@ -2825,10 +2825,10 @@ QPointer ShowForwardMessagesBox( }; 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(); } if (successCallback) { @@ -2857,7 +2857,7 @@ QPointer ShowForwardMessagesBox( history, msgIds); - const auto weak = Ui::MakeWeak(state->box); + const auto weak = base::make_weak(state->box); const auto field = comment->entity(); state->submit = [=](Api::SendOptions options) { const auto peers = state->box->collectSelectedRows(); @@ -3090,10 +3090,10 @@ QPointer ShowForwardMessagesBox( }); }, state->box->lifetime()); - return QPointer(state->box); + return base::make_weak(state->box); } -QPointer ShowForwardMessagesBox( +base::weak_qptr ShowForwardMessagesBox( not_null navigation, Data::ForwardDraft &&draft, Fn &&successCallback) { @@ -3103,7 +3103,7 @@ QPointer ShowForwardMessagesBox( std::move(successCallback)); } -QPointer ShowForwardMessagesBox( +base::weak_qptr ShowForwardMessagesBox( not_null navigation, MessageIdsList &&items, Fn &&successCallback) { @@ -3113,13 +3113,13 @@ QPointer ShowForwardMessagesBox( std::move(successCallback)); } -QPointer ShowShareGameBox( +base::weak_qptr ShowShareGameBox( not_null navigation, not_null bot, QString shortName) { - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); auto chosen = [=](not_null thread) mutable { - const auto confirm = std::make_shared>(); + const auto confirm = std::make_shared>(); auto send = crl::guard(thread, [=] { ShareBotGame(bot, thread, shortName); if (const auto strong = *weak) { @@ -3166,15 +3166,15 @@ QPointer ShowShareGameBox( .moneyRestrictionError = WriteMoneyRestrictionError, }), std::move(initBox))); - return weak->data(); + return weak->get(); } -QPointer ShowDropMediaBox( +base::weak_qptr ShowDropMediaBox( not_null navigation, std::shared_ptr data, not_null forum, FnMut &&successCallback) { - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); auto chosen = [ data = std::move(data), callback = std::move(successCallback), @@ -3206,15 +3206,15 @@ QPointer ShowDropMediaBox( forum, std::move(chosen)), std::move(initBox))); - return weak->data(); + return weak->get(); } -QPointer ShowDropMediaBox( +base::weak_qptr ShowDropMediaBox( not_null navigation, std::shared_ptr data, not_null monoforum, FnMut &&successCallback) { - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); auto chosen = [ data = std::move(data), callback = std::move(successCallback), @@ -3246,10 +3246,10 @@ QPointer ShowDropMediaBox( monoforum, std::move(chosen)), std::move(initBox))); - return weak->data(); + return weak->get(); } -QPointer ShowSendNowMessagesBox( +base::weak_qptr ShowSendNowMessagesBox( not_null navigation, not_null history, MessageIdsList &&items, @@ -3298,7 +3298,7 @@ QPointer ShowSendNowMessagesBox( .text = text, .confirmed = std::move(done), .confirmText = tr::lng_send_button(), - })).data(); + })); } void PeerMenuAddChannelMembers( @@ -3826,7 +3826,7 @@ void PeerMenuConfirmToggleFee( return; } navigation->uiShow()->show(Box([=](not_null box) { - const auto refund = std::make_shared>(); + const auto refund = std::make_shared>(); Ui::ConfirmBox(box, { .text = tr::lng_payment_refund_text( tr::now, @@ -3846,7 +3846,7 @@ void PeerMenuConfirmToggleFee( *paid = paidAmount->value(); paid->value() | rpl::start_with_next([=](int already) { if (!already) { - delete base::take(*refund); + delete base::take(*refund).get(); } else if (!*refund) { const auto skip = st::defaultCheckbox.margin.top(); *refund = box->addRow( diff --git a/Telegram/SourceFiles/window/window_peer_menu.h b/Telegram/SourceFiles/window/window_peer_menu.h index 56c4a6baec..a39b2ba3ac 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.h +++ b/Telegram/SourceFiles/window/window_peer_menu.h @@ -182,45 +182,45 @@ object_ptr PrepareChooseRecipientBox( Fn>, Api::SendOptions)> sendMany = nullptr); -QPointer ShowChooseRecipientBox( +base::weak_qptr ShowChooseRecipientBox( not_null navigation, FnMut)> &&chosen, rpl::producer titleOverride = nullptr, FnMut &&successCallback = nullptr, InlineBots::PeerTypes typesRestriction = 0); -QPointer ShowForwardMessagesBox( +base::weak_qptr ShowForwardMessagesBox( std::shared_ptr show, Data::ForwardDraft &&draft, Fn &&successCallback = nullptr); -QPointer ShowForwardMessagesBox( +base::weak_qptr ShowForwardMessagesBox( not_null navigation, Data::ForwardDraft &&draft, Fn &&successCallback = nullptr); -QPointer ShowForwardMessagesBox( +base::weak_qptr ShowForwardMessagesBox( not_null navigation, MessageIdsList &&items, Fn &&successCallback = nullptr); -QPointer ShowShareUrlBox( +base::weak_qptr ShowShareUrlBox( not_null navigation, const QString &url, const QString &text, FnMut &&successCallback = nullptr); -QPointer ShowShareGameBox( +base::weak_qptr ShowShareGameBox( not_null navigation, not_null bot, QString shortName); -QPointer ShowDropMediaBox( +base::weak_qptr ShowDropMediaBox( not_null navigation, std::shared_ptr data, not_null forum, FnMut &&successCallback = nullptr); -QPointer ShowDropMediaBox( +base::weak_qptr ShowDropMediaBox( not_null navigation, std::shared_ptr data, not_null monoforum, FnMut &&successCallback = nullptr); -QPointer ShowSendNowMessagesBox( +base::weak_qptr ShowSendNowMessagesBox( not_null navigation, not_null history, MessageIdsList &&items, diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index e58806b515..76f4ed2732 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -1022,14 +1022,14 @@ void SessionNavigation::applyBoost( } done({}); } else { - const auto weak = std::make_shared>(); + const auto weak = std::make_shared>(); const auto reassign = [=]( std::vector slots, int groups, int channels) { const auto count = int(slots.size()); const auto callback = [=](Ui::BoostCounters counters) { - if (const auto strong = weak->data()) { + if (const auto strong = weak->get()) { strong->closeBox(); } done(counters); @@ -2934,7 +2934,7 @@ auto SessionController::stickerOrEmojiChosen() const return _stickerOrEmojiChosen.events(); } -QPointer SessionController::show( +base::weak_qptr SessionController::show( object_ptr content, Ui::LayerOptions options, anim::type animated) { diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 7bde45c28d..8ca4819def 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -390,7 +390,7 @@ public: void stickerOrEmojiChosen(FileChosen chosen); [[nodiscard]] rpl::producer stickerOrEmojiChosen() const; - QPointer show( + base::weak_qptr show( object_ptr content, Ui::LayerOptions options = Ui::LayerOption::KeepOther, anim::type animated = anim::type::normal); diff --git a/Telegram/lib_base b/Telegram/lib_base index 402034cba6..bed6d0be44 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit 402034cba675220647c5e2041f38cf9d977d496e +Subproject commit bed6d0be4422b8733d3c7e691eac6adf8439597f diff --git a/Telegram/lib_spellcheck b/Telegram/lib_spellcheck index c8ded8b758..81297706b3 160000 --- a/Telegram/lib_spellcheck +++ b/Telegram/lib_spellcheck @@ -1 +1 @@ -Subproject commit c8ded8b7585f8819780ea22a40c237625aec0c75 +Subproject commit 81297706b32a6ec829a7dff5461ff458f82fb602 diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 15bed2e494..1cb389224f 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 15bed2e494c4fa52c93681e7e03c4a83f1e15a6a +Subproject commit 1cb389224f285e619f2fbc3f9395516d17d62682