diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index da0b08d7e..9aba7d65b 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -881,6 +881,8 @@ void AttachWebView::request(const WebViewButton &button) { } void AttachWebView::cancel() { + Expects(!_catchingCancelInShowCall); + ActiveWebViews().remove(this); _session->api().request(base::take(_requestId)).cancel(); _session->api().request(base::take(_prolongId)).cancel(); @@ -1468,6 +1470,7 @@ void AttachWebView::show( _lastShownQueryId = queryId; _lastShownButtonText = buttonText; base::take(_panel); + _catchingCancelInShowCall = true; _panel = Ui::BotWebView::Show({ .url = url, .userDataPath = _session->domain().local().webviewDataPath(), @@ -1477,11 +1480,13 @@ void AttachWebView::show( .menuButtons = buttons, .allowClipboardRead = allowClipboardRead, }); + _catchingCancelInShowCall = false; started(queryId); } void AttachWebView::started(uint64 queryId) { - Expects(_bot != nullptr && _context != nullptr); + Expects(_bot != nullptr); + Expects(_context != nullptr); if (_context->fromSwitch || !queryId) { return; diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h index a389c9627..d1d2c0e44 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h @@ -267,6 +267,7 @@ private: base::flat_set> _disclaimerAccepted; std::unique_ptr _panel; + bool _catchingCancelInShowCall = false; };