From 755325fef3808c5c39b86890bf9aaaf6390b4a7d Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 21 Feb 2017 17:37:53 +0300 Subject: [PATCH] Updated Xcode build for using standard library. Also trying to use g++-6 for travis build. --- .travis.yml | 8 ++++---- Telegram/SourceFiles/boxes/abstractbox.cpp | 2 +- Telegram/SourceFiles/boxes/stickers_box.cpp | 2 +- Telegram/SourceFiles/core/basic_types.h | 15 +++++++++++++++ Telegram/SourceFiles/core/observer.h | 8 +++++--- Telegram/SourceFiles/dialogswidget.cpp | 4 ++-- .../inline_bots/inline_bot_layout_item.cpp | 2 +- Telegram/SourceFiles/intro/introwidget.cpp | 2 +- Telegram/SourceFiles/mainwidget.cpp | 4 ++-- .../SourceFiles/platform/mac/window_title_mac.mm | 2 +- Telegram/SourceFiles/stickers/emoji_pan.cpp | 2 +- .../SourceFiles/ui/effects/panel_animation.cpp | 2 +- .../SourceFiles/ui/effects/ripple_animation.cpp | 2 +- Telegram/SourceFiles/ui/images.cpp | 6 +++--- Telegram/SourceFiles/ui/style/style_core.h | 2 +- Telegram/SourceFiles/ui/style/style_core_icon.cpp | 6 +++--- Telegram/SourceFiles/ui/twidget.cpp | 4 ++-- .../SourceFiles/ui/widgets/inner_dropdown.cpp | 2 +- Telegram/SourceFiles/ui/widgets/labels.cpp | 6 +++--- Telegram/SourceFiles/ui/widgets/popup_menu.cpp | 2 +- Telegram/SourceFiles/ui/widgets/shadow.cpp | 2 +- .../window/themes/window_theme_preview.cpp | 2 +- Telegram/gyp/settings_mac.gypi | 1 + changelog.txt | 4 ++++ 24 files changed, 57 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index 57e5165ef..48e2659e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,8 +35,8 @@ addons: - dpatch - equivs - fakeroot - - g++-4.9 - - gcc-4.9 + - g++-6 + - gcc-6 - git - gnome-common - gobject-introspection @@ -62,8 +62,8 @@ addons: before_install: - "export TRAVIS_COMMIT_MSG=\"$(git log --format=%B --no-merges -n 1)\"" - .travis/check.sh - - export CXX="g++-4.9" CC="gcc-4.9" - - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 + - export CXX="g++-6" CC="gcc-6" + - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 - sudo update-alternatives --config gcc - g++ --version diff --git a/Telegram/SourceFiles/boxes/abstractbox.cpp b/Telegram/SourceFiles/boxes/abstractbox.cpp index 1936c59ba..ed68413dc 100644 --- a/Telegram/SourceFiles/boxes/abstractbox.cpp +++ b/Telegram/SourceFiles/boxes/abstractbox.cpp @@ -155,7 +155,7 @@ QPixmap BoxContent::grabInnerCache() { auto result = myGrab(this, _scroll->geometry()); if (isTopShadowVisible) _topShadow->show(); if (isBottomShadowVisible) _bottomShadow->show(); - return std::move(result); + return result; } void BoxContent::resizeEvent(QResizeEvent *e) { diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 2a22912a5..82ee6ba77 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -425,7 +425,7 @@ QPixmap StickersBox::grabContentCache() { _tabs->hide(); auto result = grabInnerCache(); _tabs->show(); - return std::move(result); + return result; } void StickersBox::installSet(uint64 setId) { diff --git a/Telegram/SourceFiles/core/basic_types.h b/Telegram/SourceFiles/core/basic_types.h index ae5f87d46..c759a37b8 100644 --- a/Telegram/SourceFiles/core/basic_types.h +++ b/Telegram/SourceFiles/core/basic_types.h @@ -26,6 +26,21 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include #include "core/build_config.h" + +#if defined COMPILER_CLANG || defined COMPILER_GCC +namespace std { + +template +constexpr std::add_const_t& as_const(T& t) noexcept { + return t; +} + +template +void as_const(const T&&) = delete; + +} // namespace std +#endif // COMPILER_CLANG || COMPILER_GCC + #include "core/ordered_set.h" //using uchar = unsigned char; // Qt has uchar diff --git a/Telegram/SourceFiles/core/observer.h b/Telegram/SourceFiles/core/observer.h index f5a9d3fed..57dd964da 100644 --- a/Telegram/SourceFiles/core/observer.h +++ b/Telegram/SourceFiles/core/observer.h @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #pragma once #include +#include #include "core/type_traits.h" namespace base { @@ -285,7 +286,7 @@ private: UnregisterActiveObservable(&this->_callHandlers); } - std::vector _events; + std::deque _events; bool _handling = false; }; @@ -425,9 +426,10 @@ protected: void unsubscribe(int index) { if (!index) return; - t_assert(index > 0 && index <= _subscriptions.size()); + auto count = static_cast(_subscriptions.size()); + t_assert(index > 0 && index <= count); _subscriptions[index - 1].destroy(); - if (index == _subscriptions.size()) { + if (index == count) { while (index > 0 && !_subscriptions[--index]) { _subscriptions.pop_back(); } diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 94d71fa02..a348f7559 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -215,8 +215,8 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO } } else if (_state == FilteredState || _state == SearchedState) { if (!_hashtagResults.empty()) { - int32 from = floorclamp(r.y(), st::mentionHeight, 0, _hashtagResults.size()); - int32 to = ceilclamp(r.y() + r.height(), st::mentionHeight, 0, _hashtagResults.size()); + auto from = floorclamp(r.y(), st::mentionHeight, 0, _hashtagResults.size()); + auto to = ceilclamp(r.y() + r.height(), st::mentionHeight, 0, _hashtagResults.size()); p.translate(0, from * st::mentionHeight); if (from < _hashtagResults.size()) { auto htagwidth = fullWidth - st::dialogsPadding.x() * 2; diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp index f5869c014..9ac7c59dd 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp @@ -150,7 +150,7 @@ QPixmap ItemBase::getResultContactAvatar(int width, int height) const { if (result.height() != height * cIntRetinaFactor()) { result = result.scaled(QSize(width, height) * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } - return std::move(result); + return result; } return QPixmap(); } diff --git a/Telegram/SourceFiles/intro/introwidget.cpp b/Telegram/SourceFiles/intro/introwidget.cpp index fecb3d89c..a884508ff 100644 --- a/Telegram/SourceFiles/intro/introwidget.cpp +++ b/Telegram/SourceFiles/intro/introwidget.cpp @@ -694,7 +694,7 @@ Widget::Step::CoverAnimation Widget::Step::prepareCoverAnimation(Step *after) { result.description = Ui::FlatLabel::CrossFade(after->_description->entity(), _description->entity(), st::introBg, after->_description->pos(), _description->pos()); result.contentSnapshotWas = after->prepareContentSnapshot(); result.contentSnapshotNow = prepareContentSnapshot(); - return std::move(result); + return result; } QPixmap Widget::Step::prepareContentSnapshot() { diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 49cc5ddd8..cad11e8dd 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2217,10 +2217,10 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, Ui::Show } _stack.clear(); } else { - for (int i = 0, s = _stack.size(); i < s; ++i) { + for (auto i = 0, s = int(_stack.size()); i < s; ++i) { if (_stack.at(i)->type() == HistoryStackItem && _stack.at(i)->peer->id == peerId) { foundInStack = true; - while (_stack.size() > i + 1) { + while (int(_stack.size()) > i + 1) { clearBotStartToken(_stack.back()->peer); _stack.pop_back(); } diff --git a/Telegram/SourceFiles/platform/mac/window_title_mac.mm b/Telegram/SourceFiles/platform/mac/window_title_mac.mm index 8749ecc96..f08e46199 100644 --- a/Telegram/SourceFiles/platform/mac/window_title_mac.mm +++ b/Telegram/SourceFiles/platform/mac/window_title_mac.mm @@ -115,7 +115,7 @@ QImage PreviewWindowSystemButton(QColor inner, QColor border) { p.drawEllipse(QRectF(0.5, 0.5, fullSize - 1., fullSize - 1.)); } result.setDevicePixelRatio(cRetinaFactor()); - return std::move(result); + return result; } void PreviewWindowTitle(Painter &p, const style::palette &palette, QRect body, int titleHeight, int outerWidth) { diff --git a/Telegram/SourceFiles/stickers/emoji_pan.cpp b/Telegram/SourceFiles/stickers/emoji_pan.cpp index 675e33ec1..e62522c2e 100644 --- a/Telegram/SourceFiles/stickers/emoji_pan.cpp +++ b/Telegram/SourceFiles/stickers/emoji_pan.cpp @@ -3317,7 +3317,7 @@ QImage EmojiPan::grabForPanelAnimation() { _inPanelGrab = true; render(&result); _inPanelGrab = false; - return std::move(result); + return result; } void EmojiPan::hideAnimated() { diff --git a/Telegram/SourceFiles/ui/effects/panel_animation.cpp b/Telegram/SourceFiles/ui/effects/panel_animation.cpp index d28f637e0..c6ba5b867 100644 --- a/Telegram/SourceFiles/ui/effects/panel_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/panel_animation.cpp @@ -99,7 +99,7 @@ QImage RoundShadowAnimation::cloneImage(const style::icon &source) { Painter p(&result); source.paint(p, 0, 0, source.width()); } - return std::move(result); + return result; } void RoundShadowAnimation::paintCorner(Corner &corner, int left, int top) { diff --git a/Telegram/SourceFiles/ui/effects/ripple_animation.cpp b/Telegram/SourceFiles/ui/effects/ripple_animation.cpp index c0ce98d91..7cfe979ec 100644 --- a/Telegram/SourceFiles/ui/effects/ripple_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/ripple_animation.cpp @@ -207,7 +207,7 @@ QImage RippleAnimation::maskByDrawer(QSize size, bool filled, base::lambda> 16)); } } - return std::move(image); + return image; } QImage prepareOpaque(QImage image) { @@ -285,7 +285,7 @@ QImage prepareOpaque(QImage image) { ints += addPerLine; } } - return std::move(image); + return image; } QImage prepare(QImage img, int w, int h, Images::Options options, int outerw, int outerh) { @@ -337,7 +337,7 @@ QImage prepare(QImage img, int w, int h, Images::Options options, int outerw, in t_assert(!img.isNull()); } img.setDevicePixelRatio(cRetinaFactor()); - return std::move(img); + return img; } } // namespace Images diff --git a/Telegram/SourceFiles/ui/style/style_core.h b/Telegram/SourceFiles/ui/style/style_core.h index 901573bef..40a6fa2fa 100644 --- a/Telegram/SourceFiles/ui/style/style_core.h +++ b/Telegram/SourceFiles/ui/style/style_core.h @@ -71,7 +71,7 @@ inline QImage colorizeImage(const QImage &src, QColor c, QRect srcRect = QRect() if (srcRect.isNull()) srcRect = src.rect(); auto result = QImage(srcRect.size(), QImage::Format_ARGB32_Premultiplied); colorizeImage(src, c, &result, srcRect); - return std::move(result); + return result; } inline QImage colorizeImage(const QImage &src, const color &c, QRect srcRect = QRect()) { diff --git a/Telegram/SourceFiles/ui/style/style_core_icon.cpp b/Telegram/SourceFiles/ui/style/style_core_icon.cpp index 487bc2fef..a2c7f901a 100644 --- a/Telegram/SourceFiles/ui/style/style_core_icon.cpp +++ b/Telegram/SourceFiles/ui/style/style_core_icon.cpp @@ -223,20 +223,20 @@ QImage MonoIcon::instance(QColor colorOverride, DBIScale scale) const { } else { colorizeImage(_maskImage, colorOverride, &result); } - return std::move(result); + return result; } auto size = readGeneratedSize(_mask, scale); if (!size.isEmpty()) { auto result = QImage(size * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied); result.setDevicePixelRatio(cRetinaFactor()); result.fill(colorOverride); - return std::move(result); + return result; } auto mask = createIconMask(_mask, scale); auto result = QImage(mask.size(), QImage::Format_ARGB32_Premultiplied); result.setDevicePixelRatio(cRetinaFactor()); colorizeImage(mask, colorOverride, &result); - return std::move(result); + return result; } void MonoIcon::ensureLoaded() const { diff --git a/Telegram/SourceFiles/ui/twidget.cpp b/Telegram/SourceFiles/ui/twidget.cpp index 0283c3d81..95eabf1c3 100644 --- a/Telegram/SourceFiles/ui/twidget.cpp +++ b/Telegram/SourceFiles/ui/twidget.cpp @@ -77,7 +77,7 @@ QPixmap myGrab(TWidget *target, QRect rect, QColor bg) { target->render(&result, QPoint(0, 0), rect, QWidget::DrawChildren | QWidget::IgnoreMask); target->grabFinish(); - return std::move(result); + return result; } QImage myGrabImage(TWidget *target, QRect rect, QColor bg) { @@ -94,7 +94,7 @@ QImage myGrabImage(TWidget *target, QRect rect, QColor bg) { target->render(&result, QPoint(0, 0), rect, QWidget::DrawChildren | QWidget::IgnoreMask); target->grabFinish(); - return std::move(result); + return result; } void sendSynteticMouseEvent(QWidget *widget, QEvent::Type type, Qt::MouseButton button, const QPoint &globalPoint) { diff --git a/Telegram/SourceFiles/ui/widgets/inner_dropdown.cpp b/Telegram/SourceFiles/ui/widgets/inner_dropdown.cpp index 74ad0b5aa..aac1f306c 100644 --- a/Telegram/SourceFiles/ui/widgets/inner_dropdown.cpp +++ b/Telegram/SourceFiles/ui/widgets/inner_dropdown.cpp @@ -274,7 +274,7 @@ QImage InnerDropdown::grabForPanelAnimation() { } } } - return std::move(result); + return result; } void InnerDropdown::opacityAnimationCallback() { diff --git a/Telegram/SourceFiles/ui/widgets/labels.cpp b/Telegram/SourceFiles/ui/widgets/labels.cpp index 41144d626..04ca11892 100644 --- a/Telegram/SourceFiles/ui/widgets/labels.cpp +++ b/Telegram/SourceFiles/ui/widgets/labels.cpp @@ -609,7 +609,7 @@ std::unique_ptr FlatLabel::CrossFade(FlatLabel *from, FlatLa result.lineAddTop = addedHeight / 2; result.lineHeight += addedHeight; } - return std::move(result); + return result; }; auto was = prepareData(from); auto now = prepareData(to); @@ -643,13 +643,13 @@ std::unique_ptr FlatLabel::CrossFade(FlatLabel *from, FlatLa } auto positionBase = position + label->pos(); result.position = positionBase + QPoint(label->_st.margin.left() + left, label->_st.margin.top() + top); - return std::move(result); + return result; }; for (int i = 0; i != maxLines; ++i) { result->addLine(preparePart(from, fromPosition, was, i, now), preparePart(to, toPosition, now, i, was)); } - return std::move(result); + return result; } Text::StateResult FlatLabel::dragActionUpdate() { diff --git a/Telegram/SourceFiles/ui/widgets/popup_menu.cpp b/Telegram/SourceFiles/ui/widgets/popup_menu.cpp index 5ecee1434..5ac741435 100644 --- a/Telegram/SourceFiles/ui/widgets/popup_menu.cpp +++ b/Telegram/SourceFiles/ui/widgets/popup_menu.cpp @@ -408,7 +408,7 @@ QImage PopupMenu::grabForPanelAnimation() { } } } - return std::move(result); + return result; } void PopupMenu::deleteOnHide(bool del) { diff --git a/Telegram/SourceFiles/ui/widgets/shadow.cpp b/Telegram/SourceFiles/ui/widgets/shadow.cpp index dd8f27905..c61758477 100644 --- a/Telegram/SourceFiles/ui/widgets/shadow.cpp +++ b/Telegram/SourceFiles/ui/widgets/shadow.cpp @@ -98,7 +98,7 @@ QPixmap Shadow::grab(TWidget *target, const style::Shadow &shadow, Sides sides) target->render(&p, QPoint(extend.left(), extend.top()), rect, QWidget::DrawChildren | QWidget::IgnoreMask); target->grabFinish(); } - return std::move(result); + return result; } } // namespace Ui diff --git a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp index 168419e1b..acd6f590d 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp @@ -895,7 +895,7 @@ std::unique_ptr GeneratePreview(const QString &filepath, const CurrentD return std::unique_ptr(); } result->preview = Generator(result->instance, data).generate(); - return std::move(result); + return result; } int DefaultPreviewTitleHeight() { diff --git a/Telegram/gyp/settings_mac.gypi b/Telegram/gyp/settings_mac.gypi index 6d60cfb47..c13c59278 100644 --- a/Telegram/gyp/settings_mac.gypi +++ b/Telegram/gyp/settings_mac.gypi @@ -54,6 +54,7 @@ '-Wno-switch', '-Wno-comment', '-Wno-missing-field-initializers', + '-Wno-sign-compare', ], }, 'xcode_settings': { diff --git a/changelog.txt b/changelog.txt index 897b180c7..0b28a76de 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +1.0.14 (20.02.17) + +- Bug fixes and other minor improvements. + 1.0.13 (20.02.17) - Bug fixes and other minor improvements.