From 6fbecbca22ae878c2458978cf1d19010f361ad9e Mon Sep 17 00:00:00 2001 From: Evgenii Zheltonozhskii Date: Mon, 4 Jun 2018 22:31:45 +0300 Subject: [PATCH] Fix 0.01% of warnings --- CMakeLists.txt | 2 + Telegram/SourceFiles/boxes/calendar_box.cpp | 2 - Telegram/SourceFiles/boxes/edit_color_box.cpp | 1 - .../SourceFiles/boxes/edit_privacy_box.cpp | 4 +- Telegram/SourceFiles/boxes/peer_list_box.cpp | 1 - .../boxes/peer_list_controllers.cpp | 4 +- Telegram/SourceFiles/boxes/send_files_box.cpp | 1 - .../chat_helpers/field_autocomplete.cpp | 10 +--- .../chat_helpers/gifs_list_widget.cpp | 1 - .../chat_helpers/stickers_list_widget.cpp | 24 ++++---- .../SourceFiles/chat_helpers/tabbed_panel.cpp | 1 - .../chat_helpers/tabbed_selector.cpp | 2 - .../SourceFiles/codegen/style/generator.cpp | 4 +- .../dialogs/dialogs_inner_widget.cpp | 10 +--- .../SourceFiles/dialogs/dialogs_layout.cpp | 55 ++++++++++--------- 15 files changed, 52 insertions(+), 70 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0dbb3f47..208dcec8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,8 @@ if (CCACHE) set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE}) endif() + +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") add_subdirectory(Telegram) # clang-format diff --git a/Telegram/SourceFiles/boxes/calendar_box.cpp b/Telegram/SourceFiles/boxes/calendar_box.cpp index a01af4934..e0349db9f 100644 --- a/Telegram/SourceFiles/boxes/calendar_box.cpp +++ b/Telegram/SourceFiles/boxes/calendar_box.cpp @@ -125,8 +125,6 @@ void CalendarBox::Context::applyMonth(const QDate &month, bool forced) { _daysCount = month.daysInMonth(); _daysShift = daysShiftForMonth(month); _rowsCount = rowsCountForMonth(month); - auto yearIndex = month.year(); - auto monthIndex = month.month(); _highlightedIndex = month.daysTo(_highlighted); _minDayIndex = _min.isNull() ? INT_MIN : month.daysTo(_min); _maxDayIndex = _max.isNull() ? INT_MAX : month.daysTo(_max); diff --git a/Telegram/SourceFiles/boxes/edit_color_box.cpp b/Telegram/SourceFiles/boxes/edit_color_box.cpp index 9cfacf9fb..4451fde63 100644 --- a/Telegram/SourceFiles/boxes/edit_color_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_color_box.cpp @@ -742,7 +742,6 @@ void EditColorBox::updateHSVFields() { auto hue = std::round((1. - _hueSlider->value()) * 360); auto saturation = std::round(_picker->valueX() * 255); auto brightness = std::round((1. - _picker->valueY()) * 255); - auto alpha = std::round(_opacitySlider->value() * 255); _hueField->setTextWithFocus(QString::number(hue)); _saturationField->setTextWithFocus(QString::number(percentFromByte(saturation))); _brightnessField->setTextWithFocus(QString::number(percentFromByte(brightness))); diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index c06446e48..292768a89 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -110,7 +110,7 @@ void EditPrivacyBox::prepare() { int EditPrivacyBox::resizeGetHeight(int newWidth) { auto top = 0; - auto layoutRow = [this, newWidth, &top](auto &widget, style::margins padding) { + auto layoutRow = [newWidth, &top](auto &widget, style::margins padding) { if (!widget) return; widget->resizeToNaturalWidth(newWidth - padding.left() - padding.right()); widget->moveToLeft(padding.left(), top + padding.top()); @@ -152,7 +152,7 @@ int EditPrivacyBox::countDefaultHeight(int newWidth) { } return st::editPrivacyOptionMargin.top() + st::defaultCheck.diameter + st::editPrivacyOptionMargin.bottom(); }; - auto labelHeight = [this, newWidth](const QString &text, const style::FlatLabel &st, style::margins padding) { + auto labelHeight = [newWidth](const QString &text, const style::FlatLabel &st, style::margins padding) { if (text.isEmpty()) { return 0; } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 4b371b75e..df45501bd 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -973,7 +973,6 @@ void PeerListBox::Inner::paintRow(Painter &p, TimeMs ms, RowIndex index) { p.drawTextLeft(namex, st::contactsPadding.top() + st::contactsStatusTop, width(), highlightedPart); } else { grayedPart = st::contactsStatusFont->elided(grayedPart, availableWidth - highlightedWidth); - auto grayedWidth = st::contactsStatusFont->width(grayedPart); p.setPen(st::contactsStatusFgOnline); p.drawTextLeft(namex, st::contactsPadding.top() + st::contactsStatusTop, width(), highlightedPart); p.setPen(selected ? st::contactsStatusFgOver : st::contactsStatusFg); diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index 426b14e64..7e3864f78 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -666,8 +666,8 @@ void EditChatAdminsBoxController::Start(not_null chat) { Ui::show(Box(std::move(controller), std::move(initBox))); } -void AddBotToGroupBoxController::Start(not_null bot) { - auto initBox = [bot](not_null box) { +void AddBotToGroupBoxController::Start(not_null bot) { + auto initBox = [](not_null box) { box->addButton(langFactory(lng_cancel), [box] { box->closeBox(); }); }; Ui::show(Box(std::make_unique(bot), std::move(initBox))); diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 923701fb5..bc3867384 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -716,7 +716,6 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) { } } else if (_doc) { qint32 w = width() - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(); - qint32 h = _thumbw ? (0 + st::msgFileThumbSize + 0) : (0 + st::msgFileSize + 0); qint32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0; if (_thumbw) { nameleft = 0 + st::msgFileThumbSize + st::msgFileThumbPadding.right(); diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index ecf9eeaff..24685cddf 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -548,7 +548,6 @@ void FieldAutocompleteInner::paintEvent(QPaintEvent *e) { QRect r(e->rect()); if (r != rect()) p.setClipRect(r); - qint32 atwidth = st::mentionFont->width('@'), hashwidth = st::mentionFont->width('#'); qint32 mentionleft = 2 * st::mentionPadding.left() + st::mentionPhotoSize; qint32 mentionwidth = width() - mentionleft - 2 * st::mentionPadding.right(); qint32 htagleft = st::historyAttach.width + st::historyComposeField.textMrg.left() - st::lineWidth, @@ -928,13 +927,8 @@ void FieldAutocompleteInner::onUpdateSelected(bool force) { qint32 sel = -1, maxSel = 0; if (!_srows->isEmpty()) { - qint32 rows = rowscount(_srows->size(), _stickersPerRow); - qint32 row = (mouse.y() >= st::stickerPanPadding) ? - ((mouse.y() - st::stickerPanPadding) / st::stickerPanSize.height()) : - -1; - qint32 col = (mouse.x() >= st::stickerPanPadding) ? - ((mouse.x() - st::stickerPanPadding) / st::stickerPanSize.width()) : - -1; + qint32 row = (mouse.y() >= st::stickerPanPadding) ? ((mouse.y() - st::stickerPanPadding) / st::stickerPanSize.height()) : -1; + qint32 col = (mouse.x() >= st::stickerPanPadding) ? ((mouse.x() - st::stickerPanPadding) / st::stickerPanSize.width()) : -1; if (row >= 0 && col >= 0) { sel = row * _stickersPerRow + col; } diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index 5bf5edb81..eae203371 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -730,7 +730,6 @@ bool GifsListWidget::inlineItemVisible(const InlineBots::Layout::ItemBase *layou auto col = position % MatrixRowShift; Assert((row < _rows.size()) && (col < _rows[row].items.size())); - auto &inlineItems = _rows[row].items; auto top = 0; for (auto i = 0; i != row; ++i) { top += _rows[i].height; diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 626582d64..9594b4290 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -128,7 +128,6 @@ StickersListWidget::Footer::Footer(not_null parent) template void StickersListWidget::Footer::enumerateVisibleIcons(Callback callback) { int iconsX = std::round(_iconsX.current()); - auto index = iconsX / st::emojiCategory.width; auto x = _iconsLeft - (iconsX % st::emojiCategory.width); for (auto index = std::min(_icons.size(), iconsX / st::emojiCategory.width), last = std::min(_icons.size(), index + kVisibleIconsCount); @@ -139,7 +138,7 @@ template void StickersListWidget::Footer::enumerateVisibleIc } void StickersListWidget::Footer::preloadImages() { - enumerateVisibleIcons([this](const StickerIcon &icon, int x) { + enumerateVisibleIcons([](const StickerIcon &icon, int x) { if (auto sticker = icon.sticker) { sticker->thumb->load(); } @@ -1547,7 +1546,7 @@ void StickersListWidget::setSelected(OverState newSelected) { setCursor(newSelected ? style::cur_pointer : style::cur_default); auto &sets = shownSets(); - auto updateSelected = [this, &sets]() { + auto updateSelected = [this]() { if (auto sticker = base::get_if(&_selected)) { rtlupdate(stickerRect(sticker->section, sticker->index)); } else if (auto button = base::get_if(&_selected)) { @@ -1691,17 +1690,14 @@ void StickersListWidget::installSet(quint64 setId) { auto &sets = Global::StickerSets(); auto it = sets.constFind(setId); if (it != sets.cend()) { - request(MTPmessages_InstallStickerSet(Stickers::inputSetId(*it), MTP_bool(false))) - .done([this](const MTPmessages_StickerSetInstallResult &result) { - if (result.type() == mtpc_messages_stickerSetInstallResultArchive) { - Stickers::ApplyArchivedResult(result.c_messages_stickerSetInstallResultArchive()); - } - }) - .fail([this, setId](const RPCError &error) { - notInstalledLocally(setId); - Stickers::UndoInstallLocally(setId); - }) - .send(); + request(MTPmessages_InstallStickerSet(Stickers::inputSetId(*it), MTP_bool(false))).done([](const MTPmessages_StickerSetInstallResult &result) { + if (result.type() == mtpc_messages_stickerSetInstallResultArchive) { + Stickers::ApplyArchivedResult(result.c_messages_stickerSetInstallResultArchive()); + } + }).fail([this, setId](const RPCError &error) { + notInstalledLocally(setId); + Stickers::UndoInstallLocally(setId); + }).send(); installedLocally(setId); Stickers::InstallLocally(setId); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp index ba531b0d6..f0409087f 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp @@ -110,7 +110,6 @@ void TabbedPanel::updateContentHeight() { return; } - auto was = _contentHeight; _contentHeight = contentHeight; resize(QRect(0, 0, innerRect().width(), _contentHeight).marginsAdded(innerPadding()).size()); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index 49c609094..7d0dab0f6 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -142,8 +142,6 @@ void TabbedSelector::SlideAnimation::paintFrame(QPainter &p, double dt, double o _frameAlpha = anim::interpolate(1, 256, opacity); - auto frameInts = _frameInts + _innerLeft + _innerTop * _frameIntsPerLine; - auto leftToRight = (_direction == Direction::LeftToRight); auto easeOut = anim::easeOutCirc(1., dt); diff --git a/Telegram/SourceFiles/codegen/style/generator.cpp b/Telegram/SourceFiles/codegen/style/generator.cpp index 2cd12a962..c36eee498 100644 --- a/Telegram/SourceFiles/codegen/style/generator.cpp +++ b/Telegram/SourceFiles/codegen/style/generator.cpp @@ -687,7 +687,7 @@ bool Generator::writeIncludesInSource() { } auto includes = QStringList(); - std::function collector = [this, &collector, &includes](const Module &module) { + std::function collector = [&collector, &includes](const Module &module) { module.enumIncludes(collector); auto base = moduleBaseName(module); if (!includes.contains(base)) { @@ -771,7 +771,7 @@ void palette::finalize() {\n\ compute(0, -1, { 255, 255, 255, 0}); // special color\n"; QList names; - module_.enumVariables([this, &names](const Variable &variable) -> bool { + module_.enumVariables([&names](const Variable &variable) -> bool { names.push_back(variable.name); return true; }); diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 945630879..7b2a7cc43 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -104,7 +104,7 @@ DialogsInner::DialogsInner(QWidget *parent, not_null contr UpdateRowSection::Default | UpdateRowSection::Filtered); }); - subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &data) { + subscribe(Window::Theme::Background(), [](const Window::Theme::BackgroundUpdate &data) { if (data.paletteChanged()) { Dialogs::Layout::clearUnreadBadgesCache(); } @@ -2021,7 +2021,7 @@ void DialogsInner::loadPeerPhotos() { qint32 from = (yFrom - filteredOffset()) / st::dialogsRowHeight; if (from < 0) from = 0; if (from < _filterResults.size()) { - qint32 to = (yTo / qint32(st::dialogsRowHeight)) + 1, w = width(); + qint32 to = (yTo / qint32(st::dialogsRowHeight)) + 1; if (to > _filterResults.size()) to = _filterResults.size(); for (; from < to; ++from) { @@ -2035,11 +2035,7 @@ void DialogsInner::loadPeerPhotos() { _filterResults.size(); if (from < 0) from = 0; if (from < _peerSearchResults.size()) { - qint32 to = (yTo > filteredOffset() + st::searchedBarHeight ? - ((yTo - filteredOffset() - st::searchedBarHeight) / qint32(st::dialogsRowHeight)) : - 0) - - _filterResults.size() + 1, - w = width(); + qint32 to = (yTo > filteredOffset() + st::searchedBarHeight ? ((yTo - filteredOffset() - st::searchedBarHeight) / qint32(st::dialogsRowHeight)) : 0) - _filterResults.size() + 1; if (to > _peerSearchResults.size()) to = _peerSearchResults.size(); for (; from < to; ++from) { diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp index f30fcdb34..93676225e 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp @@ -347,32 +347,35 @@ void RowPainter::paint(Painter &p, const Row *row, int fullWidth, bool active, b (st::dialogsUnreadHeight - st::dialogsUnreadFont->height) / 2; auto unreadWidth = 0; - UnreadBadgeStyle st; - st.active = active; - st.muted = false; - st.padding = 0; - st.textTop = 0; - paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth); - availableWidth -= unreadWidth + st.padding + (hadOneBadge ? st::dialogsUnreadPadding : 0); - } - auto &color = active ? st::dialogsTextFgServiceActive : - (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService); - if (!history->paintSendAction(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) { - item->drawInDialog(p, QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height), active, - selected, HistoryItem::DrawInDialog::Normal, history->textCachedFor, - history->lastItemTextCache); - } - }, - [&p, fullWidth, active, selected, ms, history, unreadCount] { - if (unreadCount) { - auto counter = QString::number(unreadCount); - if (counter.size() > 4) { - counter = qsl("..") + counter.mid(counter.size() - 3); - } - auto mutedCounter = history->mute(); - auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize; - auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight; - auto unreadWidth = 0; + UnreadBadgeStyle st; + st.active = active; + st.muted = false; + st.padding = 0; + st.textTop = 0; + paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth); + availableWidth -= unreadWidth + st.padding + (hadOneBadge ? st::dialogsUnreadPadding : 0); + } + auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService); + if (!history->paintSendAction(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) { + item->drawInDialog( + p, + QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height), + active, + selected, + HistoryItem::DrawInDialog::Normal, + history->textCachedFor, + history->lastItemTextCache); + } + }, [&p, active, history, unreadCount] { + if (unreadCount) { + auto counter = QString::number(unreadCount); + if (counter.size() > 4) { + counter = qsl("..") + counter.mid(counter.size() - 3); + } + auto mutedCounter = history->mute(); + auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize; + auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight; + auto unreadWidth = 0; UnreadBadgeStyle st; st.active = active;