diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 7b071f53ac..92a14d3230 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,10,12,0 - PRODUCTVERSION 0,10,12,0 + FILEVERSION 0,10,13,0 + PRODUCTVERSION 0,10,13,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Telegram Messenger LLP" - VALUE "FileVersion", "0.10.12.0" + VALUE "FileVersion", "0.10.13.0" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.10.12.0" + VALUE "ProductVersion", "0.10.13.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 89d66d002e..8e0ae490b9 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,10,12,0 - PRODUCTVERSION 0,10,12,0 + FILEVERSION 0,10,13,0 + PRODUCTVERSION 0,10,13,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,10 +43,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Updater" - VALUE "FileVersion", "0.10.12.0" + VALUE "FileVersion", "0.10.13.0" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.10.12.0" + VALUE "ProductVersion", "0.10.13.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index d8616fe18c..21c6a3d09a 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -336,8 +336,7 @@ void Application::closeApplication() { manager->clearAllFast(); } - delete AppObject; - AppObject = 0; + delete base::take(AppObject); Sandbox::finish(); @@ -1103,8 +1102,7 @@ void AppClass::checkMapVersion() { AppClass::~AppClass() { Shortcuts::finish(); - auto window = createAndSwap(_window); - delete window; + delete base::take(_window); Window::Notifications::finish(); @@ -1117,8 +1115,8 @@ AppClass::~AppClass() { MTP::finish(); AppObject = nullptr; - deleteAndMark(_uploader); - deleteAndMark(_translator); + delete base::take(_uploader); + delete base::take(_translator); Window::chatBackground()->reset(); diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index f97a39ff9b..5e561ff33c 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -1405,7 +1405,7 @@ void RevokePublicLinkBox::mousePressEvent(QMouseEvent *e) { } void RevokePublicLinkBox::mouseReleaseEvent(QMouseEvent *e) { - auto pressed = createAndSwap(_pressed); + auto pressed = base::take(_pressed); setCursor((_selected || _pressed) ? style::cur_pointer : style::cur_default); if (pressed && pressed == _selected) { auto text_method = pressed->isMegagroup() ? lng_channels_too_much_public_revoke_confirm_group : lng_channels_too_much_public_revoke_confirm_channel; diff --git a/Telegram/SourceFiles/boxes/notifications_box.cpp b/Telegram/SourceFiles/boxes/notifications_box.cpp index 70c05eec13..172e2b67fc 100644 --- a/Telegram/SourceFiles/boxes/notifications_box.cpp +++ b/Telegram/SourceFiles/boxes/notifications_box.cpp @@ -274,7 +274,7 @@ void NotificationsBox::prepareNotificationSampleLarge() { auto rectForName = rtlrect(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::msgNameFont->height, w); - auto notifyText = st::dialogsTextFont->elided(lang(lng_notification_preview), itemWidth); + auto notifyText = st::dialogsTextFont->elided(lang(lng_notification_sample), itemWidth); p.setFont(st::dialogsTextFont); p.setPen(st::dialogsTextFgService); p.drawText(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height + st::dialogsTextFont->ascent, notifyText); @@ -398,7 +398,7 @@ void NotificationsBox::mousePressEvent(QMouseEvent *e) { } void NotificationsBox::mouseReleaseEvent(QMouseEvent *e) { - auto isDownCorner = createAndSwap(_isDownCorner); + auto isDownCorner = base::take(_isDownCorner); if (isDownCorner && _isOverCorner && _downCorner == _overCorner && _downCorner != _chosenCorner) { _chosenCorner = _downCorner; update(); diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index 85eb99476c..a9ef7f033e 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -212,7 +212,7 @@ Efzk2DWgkBluml8OREmvfraX3bkHZJTKX4EQSjBbbdJ2ZXIsRrYOXfaA+xayEGB+\n\ 8hdlLmAjbCVfaigxX0CDqWeR1yFL9kwd9P0NsZRPsmoqVwMbMu7mStFai6aIhc3n\n\ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB\n\ -----END RSA PUBLIC KEY-----"}; - keysCount = arraysize(keys); + keysCount = base::array_size(keys); return keys; } diff --git a/Telegram/SourceFiles/core/observer.h b/Telegram/SourceFiles/core/observer.h index 5ba24d25cf..7457372fb9 100644 --- a/Telegram/SourceFiles/core/observer.h +++ b/Telegram/SourceFiles/core/observer.h @@ -60,7 +60,7 @@ public: Subscription() = default; Subscription(const Subscription &) = delete; Subscription &operator=(const Subscription &) = delete; - Subscription(Subscription &&other) : _node(createAndSwap(other._node)), _removeMethod(other._removeMethod) { + Subscription(Subscription &&other) : _node(base::take(other._node)), _removeMethod(other._removeMethod) { } Subscription &operator=(Subscription &&other) { qSwap(_node, other._node); @@ -255,7 +255,7 @@ public: private: void callHandlers() { _handling = true; - auto events = createAndSwap(_events); + auto events = base::take(_events); for (auto &event : events) { this->notifyEnumerate([this, &event]() { this->_current->handler(event); @@ -302,7 +302,7 @@ public: private: void callHandlers() { _handling = true; - auto eventsCount = createAndSwap(_eventsCount); + auto eventsCount = base::take(_eventsCount); for (int i = 0; i != eventsCount; ++i) { this->notifyEnumerate([this]() { this->_current->handler(); @@ -349,7 +349,7 @@ protected: } ~Subscriber() { - auto subscriptions = createAndSwap(_subscriptions); + auto subscriptions = base::take(_subscriptions); for (auto &subscription : subscriptions) { subscription.destroy(); } diff --git a/Telegram/SourceFiles/core/utils.h b/Telegram/SourceFiles/core/utils.h index 7fb79b1c02..01a450d986 100644 --- a/Telegram/SourceFiles/core/utils.h +++ b/Telegram/SourceFiles/core/utils.h @@ -22,23 +22,21 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "core/basic_types.h" +namespace base { + template -inline constexpr size_t arraysize(T(&ArrahSizeHelper)[N]) { +inline constexpr size_t array_size(T(&)[N]) { return N; } template -void deleteAndMark(T *&link) { - delete link; - link = reinterpret_cast(0x00000BAD); +inline T take(T &source) { + T result = T(); + std_::swap(result, source); + return std_::move(result); } -template -T *getPointerAndReset(T *&ptr) { - T *result = nullptr; - qSwap(result, ptr); - return result; -} +} // namespace base template inline QFlags qFlags(Enum v) { @@ -87,13 +85,6 @@ inline void accumulate_max(T &a, const T &b) { if (a < b) a = b; } template inline void accumulate_min(T &a, const T &b) { if (a > b) a = b; } -template -T createAndSwap(T &value) { - T result = T(); - std_::swap(result, value); - return std_::move(result); -} - static volatile int *t_assert_nullptr = nullptr; inline void t_noop() {} inline void t_assert_fail(const char *message, const char *file, int32 line) { @@ -477,7 +468,7 @@ public: return _p; } T *release() { - return getPointerAndReset(_p); + return base::take(_p); } void reset(T *p = nullptr) { delete _p; @@ -520,7 +511,7 @@ public: return _p; } T *release() { - return getPointerAndReset(_p); + return base::take(_p); } void reset(T *p = nullptr) { delete _p; diff --git a/Telegram/SourceFiles/core/vector_of_moveable.h b/Telegram/SourceFiles/core/vector_of_moveable.h index 7077237d40..a0965b114f 100644 --- a/Telegram/SourceFiles/core/vector_of_moveable.h +++ b/Telegram/SourceFiles/core/vector_of_moveable.h @@ -34,9 +34,9 @@ public: vector_of_moveable(const vector_of_moveable &other) = delete; vector_of_moveable &operator=(const vector_of_moveable &other) = delete; vector_of_moveable(vector_of_moveable &&other) - : _size(createAndSwap(other._size)) - , _capacity(createAndSwap(other._capacity)) - , _plaindata(createAndSwap(other._plaindata)) { + : _size(base::take(other._size)) + , _capacity(base::take(other._capacity)) + , _plaindata(base::take(other._plaindata)) { } vector_of_moveable &operator=(vector_of_moveable &&other) { std_::swap(_size, other._size); diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index e3ef0cebd2..bc9856a6c9 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #define BETA_VERSION_MACRO (0ULL) -constexpr int AppVersion = 10012; -constexpr str_const AppVersionStr = "0.10.12"; +constexpr int AppVersion = 10013; +constexpr str_const AppVersionStr = "0.10.13"; constexpr bool AppAlphaVersion = true; constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO; diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index 934e43bc68..d49f6a1f4b 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -232,7 +232,7 @@ void HistoryFileMedia::checkAnimationFinished() { } HistoryFileMedia::~HistoryFileMedia() { - deleteAndMark(_animation); + delete base::take(_animation); } HistoryPhoto::HistoryPhoto(HistoryItem *parent, PhotoData *photo, const QString &caption) : HistoryFileMedia(parent) diff --git a/Telegram/SourceFiles/history/history_media_types.h b/Telegram/SourceFiles/history/history_media_types.h index 45c0ea3eae..68c913dc10 100644 --- a/Telegram/SourceFiles/history/history_media_types.h +++ b/Telegram/SourceFiles/history/history_media_types.h @@ -309,7 +309,7 @@ struct HistoryDocumentVoice : public RuntimeComponent { return *this; } ~HistoryDocumentVoice() { - deleteAndMark(_playback); + delete base::take(_playback); } void ensurePlayback(const HistoryDocument *interfaces) const; void checkPlaybackFinished() const; diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 581d15b8ef..c1b7511fa7 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -3372,7 +3372,7 @@ void HistoryWidget::writeDrafts(Data::Draft **localDraft, Data::Draft **editDraf } } - if (!_editMsgId) { + if (!_editMsgId && !_inlineBot) { _saveCloudDraftTimer.start(SaveCloudDraftIdleTimeout); } } @@ -5985,7 +5985,6 @@ bool HistoryWidget::hasSilentToggle() const { void HistoryWidget::inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result) { _inlineBotResolveRequestId = 0; // Notify::inlineBotRequesting(false); - _inlineBotUsername = QString(); UserData *resolvedBot = nullptr; if (result.type() == mtpc_contacts_resolvedPeer) { const auto &d(result.c_contacts_resolvedPeer()); @@ -8863,6 +8862,6 @@ bool HistoryWidget::touchScroll(const QPoint &delta) { } HistoryWidget::~HistoryWidget() { - deleteAndMark(_pinnedBar); - deleteAndMark(_list); + delete base::take(_pinnedBar); + delete base::take(_list); } diff --git a/Telegram/SourceFiles/lang.h b/Telegram/SourceFiles/lang.h index 4202e78451..e8e551900a 100644 --- a/Telegram/SourceFiles/lang.h +++ b/Telegram/SourceFiles/lang.h @@ -29,7 +29,7 @@ constexpr const str_const LanguageCodes[] = { "pt_BR", "ko", }; -constexpr const int languageTest = -1, languageDefault = 0, languageCount = arraysize(LanguageCodes); +constexpr const int languageTest = -1, languageDefault = 0, languageCount = base::array_size(LanguageCodes); class LangString : public QString { public: diff --git a/Telegram/SourceFiles/localstorage.cpp b/Telegram/SourceFiles/localstorage.cpp index bc71589ec9..991e64aa6c 100644 --- a/Telegram/SourceFiles/localstorage.cpp +++ b/Telegram/SourceFiles/localstorage.cpp @@ -2655,7 +2655,7 @@ public: virtual void readFromStream(QDataStream &stream, quint64 &first, quint64 &second, quint32 &type, QByteArray &data) = 0; virtual void clearInMap() = 0; virtual ~AbstractCachedLoadTask() { - deleteAndMark(_result); + delete base::take(_result); } protected: @@ -2931,7 +2931,7 @@ public: } } virtual ~WebFileLoadTask() { - deleteAndMark(_result); + delete base::take(_result); } protected: diff --git a/Telegram/SourceFiles/logs.cpp b/Telegram/SourceFiles/logs.cpp index fd83ba4220..5565cecbd3 100644 --- a/Telegram/SourceFiles/logs.cpp +++ b/Telegram/SourceFiles/logs.cpp @@ -1015,8 +1015,7 @@ namespace internal { #if !defined Q_OS_MAC || defined MAC_USE_BREAKPAD if (internal::BreakpadExceptionHandler) { - google_breakpad::ExceptionHandler *h = getPointerAndReset(internal::BreakpadExceptionHandler); - delete h; + delete base::take(internal::BreakpadExceptionHandler); } #endif // !Q_OS_MAC || MAC_USE_BREAKPAD diff --git a/Telegram/SourceFiles/media/media_audio_loaders.cpp b/Telegram/SourceFiles/media/media_audio_loaders.cpp index 491eb8cdaf..fed6ed7c68 100644 --- a/Telegram/SourceFiles/media/media_audio_loaders.cpp +++ b/Telegram/SourceFiles/media/media_audio_loaders.cpp @@ -75,7 +75,7 @@ AudioPlayerLoaders::~AudioPlayerLoaders() { } void AudioPlayerLoaders::clearFromVideoQueue() { - auto queue = createAndSwap(_fromVideoQueue); + auto queue = base::take(_fromVideoQueue); for (auto &packetData : queue) { AVPacket packet; FFMpeg::packetFromDataWrap(packet, packetData); diff --git a/Telegram/SourceFiles/media/media_child_ffmpeg_loader.cpp b/Telegram/SourceFiles/media/media_child_ffmpeg_loader.cpp index b5b7e8194f..20b645721f 100644 --- a/Telegram/SourceFiles/media/media_child_ffmpeg_loader.cpp +++ b/Telegram/SourceFiles/media/media_child_ffmpeg_loader.cpp @@ -197,7 +197,7 @@ void ChildFFMpegLoader::enqueuePackets(QQueue &packets } ChildFFMpegLoader::~ChildFFMpegLoader() { - auto queue = createAndSwap(_queue); + auto queue = base::take(_queue); for (auto &packetData : queue) { AVPacket packet; FFMpeg::packetFromDataWrap(packet, packetData); diff --git a/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp b/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp index aef676db3d..bd3abc4e07 100644 --- a/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp +++ b/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp @@ -525,7 +525,7 @@ void FFMpegReaderImplementation::finishPacket() { void FFMpegReaderImplementation::clearPacketQueue() { finishPacket(); - auto packets = createAndSwap(_packetQueue); + auto packets = base::take(_packetQueue); for (auto &packetData : packets) { AVPacket packet; FFMpeg::packetFromDataWrap(packet, packetData); diff --git a/Telegram/SourceFiles/media/media_clip_qtgif.cpp b/Telegram/SourceFiles/media/media_clip_qtgif.cpp index 6ab82b1e26..e826246918 100644 --- a/Telegram/SourceFiles/media/media_clip_qtgif.cpp +++ b/Telegram/SourceFiles/media/media_clip_qtgif.cpp @@ -106,7 +106,7 @@ bool QtGifReaderImplementation::start(Mode mode, int64 &positionMs) { } QtGifReaderImplementation::~QtGifReaderImplementation() { - deleteAndMark(_reader); + delete base::take(_reader); } bool QtGifReaderImplementation::jumpToStart() { diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index 96216cbc65..27fd69a074 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -619,7 +619,7 @@ void MediaView::clearData() { } MediaView::~MediaView() { - deleteAndMark(_menu); + delete base::take(_menu); } void MediaView::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { diff --git a/Telegram/SourceFiles/mtproto/connection_tcp.cpp b/Telegram/SourceFiles/mtproto/connection_tcp.cpp index 9e64751a43..4d73feab1a 100644 --- a/Telegram/SourceFiles/mtproto/connection_tcp.cpp +++ b/Telegram/SourceFiles/mtproto/connection_tcp.cpp @@ -298,7 +298,7 @@ void AbstractTCPConnection::tcpSend(mtpBuffer &buffer) { // prepare decryption key/iv char reversed[48]; memcpy(reversed, nonce + 8, sizeof(reversed)); - std::reverse(reversed, reversed + arraysize(reversed)); + std::reverse(reversed, reversed + base::array_size(reversed)); memcpy(_receiveKey, reversed, CTRState::KeySize); memcpy(_receiveState.ivec, reversed + CTRState::KeySize, CTRState::IvecSize); diff --git a/Telegram/SourceFiles/observer_peer.cpp b/Telegram/SourceFiles/observer_peer.cpp index e4d463e5f4..66dfb36020 100644 --- a/Telegram/SourceFiles/observer_peer.cpp +++ b/Telegram/SourceFiles/observer_peer.cpp @@ -98,8 +98,8 @@ void peerUpdatedSendDelayed() { if (!SmallUpdates || !AllUpdates || SmallUpdates->empty()) return; - auto smallList = createAndSwap(*SmallUpdates); - auto allList = createAndSwap(*AllUpdates); + auto smallList = base::take(*SmallUpdates); + auto allList = base::take(*AllUpdates); for (auto &update : smallList) { PeerUpdated().notify(std_::move(update), true); } diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index b0c83da451..55260b1db2 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -105,7 +105,7 @@ void RadialProgressItem::checkRadialFinished() { } RadialProgressItem::~RadialProgressItem() { - deleteAndMark(_radial); + delete base::take(_radial); } void FileBase::setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const { diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 6ff08d77ae..15dd898915 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -226,7 +226,7 @@ void start() { } Manager *manager() { - if (Global::NativeNotifications()) { + if (Global::started() && Global::NativeNotifications()) { return ManagerInstance.data(); } return nullptr; @@ -412,7 +412,7 @@ void Manager::Impl::showNextNotification() { void Manager::Impl::clearAll() { _queuedNotifications.clear(); - auto temp = createAndSwap(_notifications); + auto temp = base::take(_notifications); for_const (auto ¬ifications, temp) { for_const (auto notification, notifications) { notification->close(); @@ -431,7 +431,7 @@ void Manager::Impl::clearFromHistory(History *history) { auto i = _notifications.find(history->peer->id); if (i != _notifications.cend()) { - auto temp = createAndSwap(i.value()); + auto temp = base::take(i.value()); _notifications.erase(i); for_const (auto notification, temp) { diff --git a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp index c5746d3a3c..4dbcb5e36c 100644 --- a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp +++ b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp @@ -321,7 +321,7 @@ void start() { } Manager *manager() { - if (Global::NativeNotifications()) { + if (Global::started() && Global::NativeNotifications()) { return ManagerInstance.data(); } return nullptr; @@ -361,7 +361,7 @@ Manager::Impl::~Impl() { void Manager::Impl::clearAll() { if (!_notifier) return; - auto temp = createAndSwap(_notifications); + auto temp = base::take(_notifications); for_const (auto ¬ifications, temp) { for_const (auto ¬ification, notifications) { _notifier->Hide(notification.p.Get()); @@ -374,7 +374,7 @@ void Manager::Impl::clearFromHistory(History *history) { auto i = _notifications.find(history->peer->id); if (i != _notifications.cend()) { - auto temp = createAndSwap(i.value()); + auto temp = base::take(i.value()); _notifications.erase(i); for_const (auto ¬ification, temp) { diff --git a/Telegram/SourceFiles/profile/profile_actions_widget.cpp b/Telegram/SourceFiles/profile/profile_actions_widget.cpp index f8c04ae0f9..ef4ee8465d 100644 --- a/Telegram/SourceFiles/profile/profile_actions_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_actions_widget.cpp @@ -115,7 +115,7 @@ void ActionsWidget::resizeButton(Ui::LeftOutlineButton *button, int newWidth, in } void ActionsWidget::refreshButtons() { - auto buttons = createAndSwap(_buttons); + auto buttons = base::take(_buttons); for_const (auto &button, buttons) { delete button; } diff --git a/Telegram/SourceFiles/profile/profile_cover.cpp b/Telegram/SourceFiles/profile/profile_cover.cpp index 76adaa96e7..d9ac7434d2 100644 --- a/Telegram/SourceFiles/profile/profile_cover.cpp +++ b/Telegram/SourceFiles/profile/profile_cover.cpp @@ -444,7 +444,7 @@ void CoverWidget::setChannelButtons() { } void CoverWidget::clearButtons() { - auto buttons = createAndSwap(_buttons); + auto buttons = base::take(_buttons); for_const (auto button, buttons) { delete button.widget; delete button.replacement; diff --git a/Telegram/SourceFiles/profile/profile_members_widget.cpp b/Telegram/SourceFiles/profile/profile_members_widget.cpp index 665b4dc015..022f967724 100644 --- a/Telegram/SourceFiles/profile/profile_members_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_members_widget.cpp @@ -593,7 +593,7 @@ void MembersWidget::onUpdateOnlineDisplay() { } MembersWidget::~MembersWidget() { - auto members = createAndSwap(_membersByUser); + auto members = base::take(_membersByUser); for_const (auto member, members) { delete member; } diff --git a/Telegram/SourceFiles/pspecific_mac.cpp b/Telegram/SourceFiles/pspecific_mac.cpp index 2ed9fd9b75..cf6a12e4af 100644 --- a/Telegram/SourceFiles/pspecific_mac.cpp +++ b/Telegram/SourceFiles/pspecific_mac.cpp @@ -478,12 +478,12 @@ QString strNotificationAboutThemeChange() { QString strNotificationAboutScreenLocked() { const uint32 letters[] = { 0x22008263, 0x0800DB6F, 0x45004F6D, 0xCC00972E, 0x0E00A861, 0x9700D970, 0xA100D570, 0x8900686C, 0xB300B365, 0xFE00DE2E, 0x76009B73, 0xFA00BF63, 0xE000A772, 0x9C009F65, 0x4E006065, 0xD900426E, 0xB7007849, 0x64006473, 0x6700824C, 0xE300706F, 0x7C00A063, 0x8F00D76B, 0x04001C65, 0x1C00A664 }; - return strMakeFromLetters(letters, arraysize(letters)); + return strMakeFromLetters(letters, base::array_size(letters)); } QString strNotificationAboutScreenUnlocked() { const uint32 letters[] = { 0x9200D763, 0xC8003C6F, 0xD2003F6D, 0x6000012E, 0x36004061, 0x4400E570, 0xA500BF70, 0x2E00796C, 0x4A009E65, 0x2E00612E, 0xC8001D73, 0x57002263, 0xF0005872, 0x49000765, 0xE5008D65, 0xE600D76E, 0xE8007049, 0x19005C73, 0x34009455, 0xB800B36E, 0xF300CA6C, 0x4C00806F, 0x5300A763, 0xD1003B6B, 0x63003565, 0xF800F264 }; - return strMakeFromLetters(letters, arraysize(letters)); + return strMakeFromLetters(letters, base::array_size(letters)); } QString strStyleOfInterface() { diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index 43bd13f5d3..90630ef318 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -766,7 +766,7 @@ ImagePtr PhotoData::makeReplyPreview() { } PhotoData::~PhotoData() { - deleteAndMark(uploadingData); + delete base::take(uploadingData); } void PhotoOpenClickHandler::onClickImpl() const { diff --git a/Telegram/SourceFiles/structs.h b/Telegram/SourceFiles/structs.h index f75c8ade29..3e9f0d9fe4 100644 --- a/Telegram/SourceFiles/structs.h +++ b/Telegram/SourceFiles/structs.h @@ -246,7 +246,7 @@ protected: public: virtual ~PeerData() { if (notify != UnknownNotifySettings && notify != EmptyNotifySettings) { - deleteAndMark(notify); + delete base::take(notify); } } diff --git a/Telegram/SourceFiles/ui/animation.h b/Telegram/SourceFiles/ui/animation.h index eaa496fb86..1018053f2c 100644 --- a/Telegram/SourceFiles/ui/animation.h +++ b/Telegram/SourceFiles/ui/animation.h @@ -37,7 +37,7 @@ public: } ReaderPointer(const ReaderPointer &other) = delete; ReaderPointer &operator=(const ReaderPointer &other) = delete; - ReaderPointer(ReaderPointer &&other) : _pointer(createAndSwap(other._pointer)) { + ReaderPointer(ReaderPointer &&other) : _pointer(base::take(other._pointer)) { } ReaderPointer &operator=(ReaderPointer &&other) { swap(other); @@ -323,7 +323,7 @@ public: void start() { _implementation->start(); } void step(Animation *a, uint64 ms, bool timer) { _implementation->step(a, ms, timer); } - ~AnimationCallbacks() { deleteAndMark(_implementation); } + ~AnimationCallbacks() { delete base::take(_implementation); } private: AnimationImplementation *_implementation; diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index 5932eefbbd..e1b3f18166 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -294,14 +294,11 @@ void Manager::doClearAll() { void Manager::doClearAllFast() { _queuedNotifications.clear(); - auto notifications = createAndSwap(_notifications); + auto notifications = base::take(_notifications); for_const (auto notification, notifications) { delete notification; } - if (_hideAll) { - auto hideAll = createAndSwap(_hideAll); - delete hideAll; - } + delete base::take(_hideAll); } void Manager::doClearFromHistory(History *history) { @@ -321,6 +318,12 @@ void Manager::doClearFromHistory(History *history) { } void Manager::doClearFromItem(HistoryItem *item) { + for (auto i = 0, queuedCount = _queuedNotifications.size(); i != queuedCount; ++i) { + if (_queuedNotifications[i].item == item) { + _queuedNotifications.removeAt(i); + break; + } + } for_const (auto notification, _notifications) { // Calls unlinkFromShown() -> showNextFromQueue() notification->itemRemoved(item); @@ -866,7 +869,7 @@ void HideAllButton::mousePressEvent(QMouseEvent *e) { } void HideAllButton::mouseReleaseEvent(QMouseEvent *e) { - auto mouseDown = createAndSwap(_mouseDown); + auto mouseDown = base::take(_mouseDown); if (mouseDown && _mouseOver) { if (auto manager = ManagerInstance.data()) { manager->clearAll(); diff --git a/Telegram/build/version b/Telegram/build/version index 98c0ccfbee..4b2feb611d 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,6 +1,6 @@ -AppVersion 10012 +AppVersion 10013 AppVersionStrMajor 0.10 -AppVersionStrSmall 0.10.12 -AppVersionStr 0.10.12 +AppVersionStrSmall 0.10.13 +AppVersionStr 0.10.13 AlphaChannel 1 BetaVersion 0