Fix some possible crashes.
This commit is contained in:
parent
31998406dd
commit
a52392241d
|
@ -678,7 +678,7 @@ namespace App {
|
||||||
auto h = App::historyLoaded(chat->id);
|
auto h = App::historyLoaded(chat->id);
|
||||||
bool found = !h || !h->lastKeyboardFrom;
|
bool found = !h || !h->lastKeyboardFrom;
|
||||||
auto botStatus = -1;
|
auto botStatus = -1;
|
||||||
for (auto i = chat->participants.begin(), e = chat->participants.end(); i != e;) {
|
for (auto i = chat->participants.begin(); i != chat->participants.end();) {
|
||||||
auto [user, version] = *i;
|
auto [user, version] = *i;
|
||||||
if (version < pversion) {
|
if (version < pversion) {
|
||||||
i = chat->participants.erase(i);
|
i = chat->participants.erase(i);
|
||||||
|
|
|
@ -932,7 +932,7 @@ void StickersListWidget::refreshSearchRows() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListWidget::refreshSearchRows(
|
void StickersListWidget::refreshSearchRows(
|
||||||
const std::vector<Stickers::Set*> *cloudSets) {
|
const std::vector<uint64> *cloudSets) {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
|
||||||
_searchSets.clear();
|
_searchSets.clear();
|
||||||
|
@ -997,9 +997,12 @@ void StickersListWidget::fillLocalSearchRows(const QString &query) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListWidget::fillCloudSearchRows(
|
void StickersListWidget::fillCloudSearchRows(
|
||||||
const std::vector<Stickers::Set*> &sets) {
|
const std::vector<uint64> &cloudSets) {
|
||||||
for (const auto set : sets) {
|
const auto &sets = Auth().data().stickerSets();
|
||||||
addSearchRow(set);
|
for (const auto setId : cloudSets) {
|
||||||
|
if (const auto it = sets.find(setId); it != sets.end()) {
|
||||||
|
addSearchRow(&*it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,7 +1052,7 @@ void StickersListWidget::searchResultsDone(
|
||||||
if (it == _searchCache.cend()) {
|
if (it == _searchCache.cend()) {
|
||||||
it = _searchCache.emplace(
|
it = _searchCache.emplace(
|
||||||
_searchQuery,
|
_searchQuery,
|
||||||
std::vector<Stickers::Set*>()).first;
|
std::vector<uint64>()).first;
|
||||||
}
|
}
|
||||||
auto &d = result.c_messages_foundStickerSets();
|
auto &d = result.c_messages_foundStickerSets();
|
||||||
for_const (const auto &stickerSet, d.vsets.v) {
|
for_const (const auto &stickerSet, d.vsets.v) {
|
||||||
|
@ -1084,7 +1087,7 @@ void StickersListWidget::searchResultsDone(
|
||||||
if (set->stickers.empty() && set->covers.empty()) {
|
if (set->stickers.empty() && set->covers.empty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
it->second.push_back(set);
|
it->second.push_back(set->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showSearchResults();
|
showSearchResults();
|
||||||
|
|
|
@ -243,9 +243,9 @@ private:
|
||||||
void showSearchResults();
|
void showSearchResults();
|
||||||
void searchResultsDone(const MTPmessages_FoundStickerSets &result);
|
void searchResultsDone(const MTPmessages_FoundStickerSets &result);
|
||||||
void refreshSearchRows();
|
void refreshSearchRows();
|
||||||
void refreshSearchRows(const std::vector<Stickers::Set*> *cloudSets);
|
void refreshSearchRows(const std::vector<uint64> *cloudSets);
|
||||||
void fillLocalSearchRows(const QString &query);
|
void fillLocalSearchRows(const QString &query);
|
||||||
void fillCloudSearchRows(const std::vector<Stickers::Set*> &sets);
|
void fillCloudSearchRows(const std::vector<uint64> &cloudSets);
|
||||||
void addSearchRow(not_null<const Stickers::Set*> set);
|
void addSearchRow(not_null<const Stickers::Set*> set);
|
||||||
|
|
||||||
ChannelData *_megagroupSet = nullptr;
|
ChannelData *_megagroupSet = nullptr;
|
||||||
|
@ -284,7 +284,7 @@ private:
|
||||||
QTimer _previewTimer;
|
QTimer _previewTimer;
|
||||||
bool _previewShown = false;
|
bool _previewShown = false;
|
||||||
|
|
||||||
std::map<QString, std::vector<Stickers::Set*>> _searchCache;
|
std::map<QString, std::vector<uint64>> _searchCache;
|
||||||
std::vector<std::pair<uint64, QStringList>> _searchIndex;
|
std::vector<std::pair<uint64, QStringList>> _searchIndex;
|
||||||
base::Timer _searchRequestTimer;
|
base::Timer _searchRequestTimer;
|
||||||
QString _searchQuery, _searchNextQuery;
|
QString _searchQuery, _searchNextQuery;
|
||||||
|
|
|
@ -1261,11 +1261,17 @@ void ConnectionPrivate::markConnectionOld() {
|
||||||
|
|
||||||
void ConnectionPrivate::sendPingByTimer() {
|
void ConnectionPrivate::sendPingByTimer() {
|
||||||
if (_pingId) {
|
if (_pingId) {
|
||||||
if (_pingSendAt + kPingSendAfterForce - kPingSendAfter - TimeMs(1000) < getms(true)) {
|
// _pingSendAt: when to send next ping (lastPingAt + kPingSendAfter)
|
||||||
|
// could be equal to zero.
|
||||||
|
const auto now = getms(true);
|
||||||
|
const auto mustSendTill = _pingSendAt
|
||||||
|
+ kPingSendAfterForce
|
||||||
|
- kPingSendAfter;
|
||||||
|
if (mustSendTill < now + 1000) {
|
||||||
LOG(("Could not send ping for some seconds, restarting..."));
|
LOG(("Could not send ping for some seconds, restarting..."));
|
||||||
return restart();
|
return restart();
|
||||||
} else {
|
} else {
|
||||||
_pingSender.callOnce(_pingSendAt + kPingSendAfterForce - kPingSendAfter - getms(true));
|
_pingSender.callOnce(mustSendTill - now);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit needToSendAsync();
|
emit needToSendAsync();
|
||||||
|
|
Loading…
Reference in New Issue