diff --git a/Telegram/SourceFiles/base/weak_ptr.h b/Telegram/SourceFiles/base/weak_ptr.h index e4884bc25d101f..6bf381d6a9ee1f 100644 --- a/Telegram/SourceFiles/base/weak_ptr.h +++ b/Telegram/SourceFiles/base/weak_ptr.h @@ -315,24 +315,3 @@ struct guard_traits< }; } // namespace crl - -#ifdef QT_VERSION -template -inline void InvokeQueued(const base::has_weak_ptr *context, Lambda &&lambda) { - auto callback = [ - guard = base::make_weak(context), - lambda = std::forward(lambda) - ] { - if (guard) { - lambda(); - } - }; - QObject proxy; - QObject::connect( - &proxy, - &QObject::destroyed, - QCoreApplication::instance(), - std::move(callback), - Qt::QueuedConnection); -} -#endif // QT_VERSION diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index bf79686aa9cd05..642570bdcc13c2 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -632,7 +632,7 @@ void Call::handleControllerBarCountChange( // Expects(controller == _controller.get()); Expects(controller->implData == static_cast(this)); - InvokeQueued(this, [=] { + crl::on_main(this, [=] { setSignalBarCount(count); }); } @@ -763,10 +763,17 @@ void Call::finish(FinishType type, const MTPPhoneCallDiscardReason &reason) { auto duration = getDurationMs() / 1000; auto connectionId = _controller ? _controller->GetPreferredRelayID() : 0; _finishByTimeoutTimer.call(kHangupTimeoutMs, [this, finalState] { setState(finalState); }); - request(MTPphone_DiscardCall(MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash)), MTP_int(duration), reason, MTP_long(connectionId))).done([this, finalState](const MTPUpdates &result) { + request(MTPphone_DiscardCall( + MTP_inputPhoneCall( + MTP_long(_id), + MTP_long(_accessHash)), + MTP_int(duration), + reason, + MTP_long(connectionId) + )).done([=](const MTPUpdates &result) { // This could be destroyed by updates, so we set Ended after // updates being handled, but in a guarded way. - InvokeQueued(this, [this, finalState] { setState(finalState); }); + crl::on_main(this, [=] { setState(finalState); }); App::main()->sentUpdatesReceived(result); }).fail([this, finalState](const RPCError &error) { setState(finalState); @@ -774,13 +781,13 @@ void Call::finish(FinishType type, const MTPPhoneCallDiscardReason &reason) { } void Call::setStateQueued(State state) { - InvokeQueued(this, [=] { + crl::on_main(this, [=] { setState(state); }); } void Call::setFailedQueued(int error) { - InvokeQueued(this, [=] { + crl::on_main(this, [=] { handleControllerError(error); }); } diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index e60635c0699fe9..e8236c47247004 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -1254,7 +1254,7 @@ MtpChecker::MtpChecker(QPointer instance, bool testing) void MtpChecker::start() { if (!_mtp.valid()) { LOG(("Update Info: MTP is unavailable.")); - InvokeQueued(this, [=] { fail(); }); + crl::on_main(this, [=] { fail(); }); return; } constexpr auto kFeedUsername = "tdhbcfeed";