From 20c9280ada31148da9b704d93cc01618f72429b8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 24 Nov 2017 21:41:31 +0400 Subject: [PATCH] Add some more debug info for crashes. --- Telegram/Resources/langs/lang.strings | 2 + Telegram/SourceFiles/boxes/about_box.cpp | 1 - .../SourceFiles/history/history_widget.cpp | 49 ++++++++++++++++--- Telegram/SourceFiles/history/history_widget.h | 6 +++ 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 8838f17bd..46e0cab71 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -217,6 +217,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org "lng_signin_reset_in_days" = "{days_count} {hours_count} {minutes_count}"; "lng_signin_reset_in_hours" = "{hours_count} {minutes_count}"; "lng_signin_reset_cancelled" = "Your recent attempts to reset this account have been cancelled by its active user. Please try again in 7 days."; +"lng_signin_banned_text" = "This phone number is banned."; +"lng_signin_banned_help" = "Help"; "lng_signup_title" = "Your Info"; "lng_signup_desc" = "Please enter your name and\nupload a photo."; diff --git a/Telegram/SourceFiles/boxes/about_box.cpp b/Telegram/SourceFiles/boxes/about_box.cpp index 6f2ed8504..2e235a760 100644 --- a/Telegram/SourceFiles/boxes/about_box.cpp +++ b/Telegram/SourceFiles/boxes/about_box.cpp @@ -39,7 +39,6 @@ AboutBox::AboutBox(QWidget *parent) } void AboutBox::prepare() { - constexpr auto test = std::is_convertible::value; setTitle([] { return qsl("Telegram Desktop"); }); addButton(langFactory(lng_close), [this] { closeBox(); }); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index c91e5f602..58023781b 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -2318,9 +2318,27 @@ void HistoryWidget::messagesReceived(PeerData *peer, const MTPmessages_Messages } break; } + const auto ExtractFirstId = [&] { + return histList->empty() ? -1 : idFromMessage(histList->front()); + }; + const auto ExtractLastId = [&] { + return histList->empty() ? -1 : idFromMessage(histList->back()); + }; + if (_preloadRequest == requestId) { auto to = toMigrated ? _migrated : _history; - SignalHandlers::setCrashAnnotation("old_minmaxbefore_minmaxnow", QString("%1;%2;%3;%4").arg(_debug_preloadMin).arg(_debug_preloadMax).arg(to->minMsgId()).arg(to->maxMsgId())); + SignalHandlers::setCrashAnnotation("old_minmaxbefore_minmaxnow", QString( + "%1=%6;%2=%7;%3;%4;%5;(%8:%9)" + ).arg(_debug_preloadMin + ).arg(_debug_preloadMax + ).arg(_debug_preloadOffsetId + ).arg(_debug_preloadAddOffset + ).arg(_debug_preloadLoadCount + ).arg(to->minMsgId() + ).arg(to->maxMsgId() + ).arg(ExtractFirstId() + ).arg(ExtractLastId() + )); addMessagesToFront(peer, *histList); @@ -2334,7 +2352,18 @@ void HistoryWidget::messagesReceived(PeerData *peer, const MTPmessages_Messages } } else if (_preloadDownRequest == requestId) { auto to = toMigrated ? _migrated : _history; - SignalHandlers::setCrashAnnotation("new_minmaxbefore_minmaxnow", QString("%1;%2;%3;%4").arg(_debug_preloadDownMin).arg(_debug_preloadDownMax).arg(to->minMsgId()).arg(to->maxMsgId())); + SignalHandlers::setCrashAnnotation("new_minmaxbefore_minmaxnow", QString( + "%1=%6;%2=%7;%3;%4;%5;(%8:%9)" + ).arg(_debug_preloadDownMin + ).arg(_debug_preloadDownMax + ).arg(_debug_preloadDownOffsetId + ).arg(_debug_preloadDownAddOffset + ).arg(_debug_preloadDownLoadCount + ).arg(to->minMsgId() + ).arg(to->maxMsgId() + ).arg(ExtractFirstId() + ).arg(ExtractLastId() + )); addMessagesToBack(peer, *histList); @@ -2522,7 +2551,7 @@ void HistoryWidget::loadMessages() { } auto offsetId = from->minMsgId(); - auto offset = 0; + auto addOffset = 0; auto loadCount = offsetId ? kMessagesPerPage : kMessagesPerPageFirst; @@ -2533,12 +2562,15 @@ void HistoryWidget::loadMessages() { _debug_preloadMin = from->minMsgId(); _debug_preloadMax = from->maxMsgId(); + _debug_preloadOffsetId = offsetId + 1; + _debug_preloadAddOffset = addOffset; + _debug_preloadLoadCount = loadCount; _preloadRequest = MTP::send( MTPmessages_GetHistory( from->peer->input, MTP_int(offsetId), MTP_int(offsetDate), - MTP_int(offset), + MTP_int(addOffset), MTP_int(loadCount), MTP_int(maxId), MTP_int(minId), @@ -2561,12 +2593,12 @@ void HistoryWidget::loadMessagesDown() { } auto loadCount = kMessagesPerPage; - auto offset = -loadCount; + auto addOffset = -loadCount; auto offsetId = from->maxMsgId(); if (!offsetId) { if (loadMigrated || !_migrated) return; ++offsetId; - ++offset; + ++addOffset; } auto offsetDate = 0; auto maxId = 0; @@ -2575,12 +2607,15 @@ void HistoryWidget::loadMessagesDown() { _debug_preloadDownMin = from->minMsgId(); _debug_preloadDownMax = from->maxMsgId(); + _debug_preloadDownOffsetId = offsetId + 1; + _debug_preloadDownAddOffset = addOffset; + _debug_preloadDownLoadCount = loadCount; _preloadDownRequest = MTP::send( MTPmessages_GetHistory( from->peer->input, MTP_int(offsetId + 1), MTP_int(offsetDate), - MTP_int(offset), + MTP_int(addOffset), MTP_int(loadCount), MTP_int(maxId), MTP_int(minId), diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 20b53b376..5d5ad9fe0 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -727,8 +727,14 @@ private: MsgId _debug_preloadMin = 0; MsgId _debug_preloadMax = 0; + MsgId _debug_preloadOffsetId = 0; + int32 _debug_preloadAddOffset = 0; + int32 _debug_preloadLoadCount = 0; MsgId _debug_preloadDownMin = 0; MsgId _debug_preloadDownMax = 0; + MsgId _debug_preloadDownOffsetId = 0; + int32 _debug_preloadDownAddOffset = 0; + int32 _debug_preloadDownLoadCount = 0; MsgId _delayedShowAtMsgId = -1; // wtf? mtpRequestId _delayedShowAtRequest = 0;