summaryrefslogtreecommitdiff
blob: ff88aec74eb6da4da9715ff5e71847fc773aa969 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From 844e9b60ddf01712082e7ff87cfe74bb20d97297 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Tue, 25 Feb 2020 16:12:04 +0400
Subject: [PATCH] Fix crash in SearchController.

Data::Histories cancels request in Main::Session::api(), so the
request must be sent using this global api(), not custom MTP::Sender.
---
 Telegram/SourceFiles/data/data_search_controller.cpp | 5 ++---
 Telegram/SourceFiles/data/data_search_controller.h   | 1 -
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/Telegram/SourceFiles/data/data_search_controller.cpp b/Telegram/SourceFiles/data/data_search_controller.cpp
index 08541b13da..90fbd36762 100644
--- a/Telegram/SourceFiles/data/data_search_controller.cpp
+++ b/Telegram/SourceFiles/data/data_search_controller.cpp
@@ -194,8 +194,7 @@ SearchController::CacheEntry::CacheEntry(const Query &query)
 }
 
 SearchController::SearchController(not_null<Main::Session*> session)
-: _session(session)
-, _api(session->api().instance()) {
+: _session(session) {
 }
 
 bool SearchController::hasInCache(const Query &query) const {
@@ -372,7 +371,7 @@ void SearchController::requestMore(
 	const auto type = ::Data::Histories::RequestType::History;
 	const auto history = _session->data().history(listData->peer);
 	auto requestId = histories.sendRequest(history, type, [=](Fn<void()> finish) {
-		return _api.request(
+		return _session->api().request(
 			std::move(*prepared)
 		).done([=](const MTPmessages_Messages &result) {
 			listData->requests.remove(key);
diff --git a/Telegram/SourceFiles/data/data_search_controller.h b/Telegram/SourceFiles/data/data_search_controller.h
index a439bb38ed..f9341ac4d4 100644
--- a/Telegram/SourceFiles/data/data_search_controller.h
+++ b/Telegram/SourceFiles/data/data_search_controller.h
@@ -130,7 +130,6 @@ class SearchController final {
 		Data *listData);
 
 	const not_null<Main::Session*> _session;
-	MTP::Sender _api;
 	Cache _cache;
 	Cache::iterator _current = _cache.end();