Fix 0.01% of warnings

This commit is contained in:
Evgenii Zheltonozhskii 2018-06-04 22:31:45 +03:00
parent e5ca84bd80
commit 6fbecbca22
15 changed files with 52 additions and 70 deletions

View File

@ -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

View File

@ -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);

View File

@ -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)));

View File

@ -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;
}

View File

@ -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);

View File

@ -666,8 +666,8 @@ void EditChatAdminsBoxController::Start(not_null<ChatData *> chat) {
Ui::show(Box<PeerListBox>(std::move(controller), std::move(initBox)));
}
void AddBotToGroupBoxController::Start(not_null<UserData *> bot) {
auto initBox = [bot](not_null<PeerListBox *> box) {
void AddBotToGroupBoxController::Start(not_null<UserData*> bot) {
auto initBox = [](not_null<PeerListBox*> box) {
box->addButton(langFactory(lng_cancel), [box] { box->closeBox(); });
};
Ui::show(Box<PeerListBox>(std::make_unique<AddBotToGroupBoxController>(bot), std::move(initBox)));

View File

@ -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();

View File

@ -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;
}

View File

@ -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;

View File

@ -128,7 +128,6 @@ StickersListWidget::Footer::Footer(not_null<StickersListWidget *> parent)
template <typename Callback> 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<int>(_icons.size(), iconsX / st::emojiCategory.width),
last = std::min(_icons.size(), index + kVisibleIconsCount);
@ -139,7 +138,7 @@ template <typename Callback> 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<OverSticker>(&_selected)) {
rtlupdate(stickerRect(sticker->section, sticker->index));
} else if (auto button = base::get_if<OverButton>(&_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);

View File

@ -110,7 +110,6 @@ void TabbedPanel::updateContentHeight() {
return;
}
auto was = _contentHeight;
_contentHeight = contentHeight;
resize(QRect(0, 0, innerRect().width(), _contentHeight).marginsAdded(innerPadding()).size());

View File

@ -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);

View File

@ -687,7 +687,7 @@ bool Generator::writeIncludesInSource() {
}
auto includes = QStringList();
std::function<bool(const Module &)> collector = [this, &collector, &includes](const Module &module) {
std::function<bool(const Module&)> 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<structure::FullName> names;
module_.enumVariables([this, &names](const Variable &variable) -> bool {
module_.enumVariables([&names](const Variable &variable) -> bool {
names.push_back(variable.name);
return true;
});

View File

@ -104,7 +104,7 @@ DialogsInner::DialogsInner(QWidget *parent, not_null<Window::Controller *> 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) {

View File

@ -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;