From 37b018257e25a8ed0510954ec117929ec94f7580 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 18 Dec 2017 14:38:14 +0400 Subject: [PATCH] Replace some std::shared_ptr with std::unique_ptr. --- .../SourceFiles/chat_helpers/bot_keyboard.cpp | 18 +- .../chat_helpers/stickers_list_widget.cpp | 60 ++-- .../chat_helpers/stickers_list_widget.h | 34 ++- .../SourceFiles/core/click_handler_types.h | 1 - Telegram/SourceFiles/history/history_item.cpp | 113 +++++--- Telegram/SourceFiles/history/history_item.h | 39 ++- .../SourceFiles/history/history_widget.cpp | 12 +- Telegram/SourceFiles/logs.cpp | 4 +- .../SourceFiles/overview/overview_layout.h | 2 +- Telegram/SourceFiles/storage/file_upload.cpp | 262 ++++++++++++------ Telegram/SourceFiles/storage/file_upload.h | 16 +- .../SourceFiles/storage/localimageloader.cpp | 64 +++-- .../SourceFiles/storage/localimageloader.h | 10 +- Telegram/SourceFiles/storage/localstorage.cpp | 19 +- .../ui/widgets/discrete_sliders.cpp | 11 +- .../SourceFiles/ui/widgets/discrete_sliders.h | 4 +- 16 files changed, 421 insertions(+), 248 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp index e933ba2b3..c5a468f8a 100644 --- a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp +++ b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp @@ -108,16 +108,18 @@ void BotKeyboard::leaveEventHook(QEvent *e) { } bool BotKeyboard::moderateKeyActivate(int key) { - if (auto item = App::histItemById(_wasForMsgId)) { - if (auto markup = item->Get()) { + if (const auto item = App::histItemById(_wasForMsgId)) { + if (const auto markup = item->Get()) { if (key >= Qt::Key_1 && key <= Qt::Key_9) { - int index = (key - Qt::Key_1); - if (!markup->rows.isEmpty() && index >= 0 && index < markup->rows.front().size()) { + const auto index = int(key - Qt::Key_1); + if (!markup->rows.empty() + && index >= 0 + && index < int(markup->rows.front().size())) { App::activateBotCommand(item, 0, index); return true; } } else if (key == Qt::Key_Q) { - if (auto user = item->history()->peer->asUser()) { + if (const auto user = item->history()->peer->asUser()) { if (user->botInfo && item->from() == user) { App::sendBotCommand(user, user, qsl("/translate")); return true; @@ -163,8 +165,10 @@ bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) { _impl = nullptr; if (auto markup = to->Get()) { - if (!markup->rows.isEmpty()) { - _impl.reset(new ReplyKeyboard(to, std::make_unique