From da49d8440a34ddbde7859dcd0f0c231ca4d4bc8a Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 26 Sep 2016 21:33:34 +0300 Subject: [PATCH] Beta 10008001: moved all Notify::Observer-s to base::Subscriber-s. --- Telegram/Resources/winrc/Telegram.rc | 8 +- Telegram/Resources/winrc/Updater.rc | 8 +- Telegram/SourceFiles/application.cpp | 3 - Telegram/SourceFiles/boxes/sharebox.cpp | 6 +- Telegram/SourceFiles/boxes/sharebox.h | 2 +- Telegram/SourceFiles/core/observer.cpp | 93 -------- Telegram/SourceFiles/core/observer.h | 224 ------------------ Telegram/SourceFiles/core/version.h | 2 +- Telegram/SourceFiles/observer_peer.cpp | 27 +-- Telegram/SourceFiles/observer_peer.h | 13 - .../profile/profile_actions_widget.cpp | 4 +- .../profile/profile_block_widget.h | 2 +- .../SourceFiles/profile/profile_cover.cpp | 4 +- Telegram/SourceFiles/profile/profile_cover.h | 2 +- .../SourceFiles/profile/profile_fixed_bar.cpp | 4 +- .../SourceFiles/profile/profile_fixed_bar.h | 2 +- .../profile/profile_info_widget.cpp | 4 +- .../profile/profile_invite_link_widget.cpp | 4 +- .../profile/profile_members_widget.cpp | 8 +- .../profile/profile_settings_widget.cpp | 4 +- .../profile/profile_shared_media_widget.cpp | 5 +- .../profile/profile_userpic_button.cpp | 5 +- .../profile/profile_userpic_button.h | 2 +- .../settings/settings_block_widget.h | 2 +- .../SourceFiles/settings/settings_cover.cpp | 5 +- Telegram/build/version | 2 +- 26 files changed, 47 insertions(+), 398 deletions(-) diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 72e344e2d..c52e8eb1c 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,8,0 - PRODUCTVERSION 0,10,8,0 + FILEVERSION 0,10,8,1 + PRODUCTVERSION 0,10,8,1 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Telegram Messenger LLP" - VALUE "FileVersion", "0.10.8.0" + VALUE "FileVersion", "0.10.8.1" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.10.8.0" + VALUE "ProductVersion", "0.10.8.1" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 69891e4dd..4ecec9605 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,8,0 - PRODUCTVERSION 0,10,8,0 + FILEVERSION 0,10,8,1 + PRODUCTVERSION 0,10,8,1 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.8.0" + VALUE "FileVersion", "0.10.8.1" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.10.8.0" + VALUE "ProductVersion", "0.10.8.1" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index 90c06fb18..247aef93a 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -217,7 +217,6 @@ void Application::singleInstanceChecked() { Logs::multipleInstances(); } - Notify::startObservers(); Sandbox::start(); if (!Logs::started() || (!cManyInstance() && !Logs::instanceChecked())) { @@ -356,8 +355,6 @@ void Application::closeApplication() { } _updateThread = 0; #endif - - Notify::finishObservers(); } #ifndef TDESKTOP_DISABLE_AUTOUPDATE diff --git a/Telegram/SourceFiles/boxes/sharebox.cpp b/Telegram/SourceFiles/boxes/sharebox.cpp index b3fbec61b..71b2d3e3a 100644 --- a/Telegram/SourceFiles/boxes/sharebox.cpp +++ b/Telegram/SourceFiles/boxes/sharebox.cpp @@ -262,11 +262,9 @@ ShareInner::ShareInner(QWidget *parent) : ScrolledWidget(parent) using UpdateFlag = Notify::PeerUpdate::Flag; auto observeEvents = UpdateFlag::NameChanged | UpdateFlag::PhotoChanged; - - Notify::registerPeerObserver(observeEvents, this, [this](const Notify::PeerUpdate &update) { + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); - + })); subscribe(FileDownload::ImageLoaded(), [this] { update(); }); } diff --git a/Telegram/SourceFiles/boxes/sharebox.h b/Telegram/SourceFiles/boxes/sharebox.h index d486e6e12..11288b6d8 100644 --- a/Telegram/SourceFiles/boxes/sharebox.h +++ b/Telegram/SourceFiles/boxes/sharebox.h @@ -108,7 +108,7 @@ private: namespace internal { -class ShareInner : public ScrolledWidget, public RPCSender, public Notify::Observer, private base::Subscriber { +class ShareInner : public ScrolledWidget, public RPCSender, private base::Subscriber { Q_OBJECT public: diff --git a/Telegram/SourceFiles/core/observer.cpp b/Telegram/SourceFiles/core/observer.cpp index cc9b9497f..c354e16e3 100644 --- a/Telegram/SourceFiles/core/observer.cpp +++ b/Telegram/SourceFiles/core/observer.cpp @@ -21,99 +21,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "core/observer.h" -namespace Notify { -namespace internal { -namespace { - -struct StartCallbackData { - void *that; - StartCallback call; -}; -struct FinishCallbackData { - void *that; - FinishCallback call; -}; -struct UnregisterCallbackData { - void *that; - UnregisterCallback call; -}; -using StartCallbacksList = QVector; -using FinishCallbacksList = QVector; -NeverFreedPointer StartCallbacks; -NeverFreedPointer FinishCallbacks; -UnregisterCallbackData UnregisterCallbacks[256]/* = { nullptr }*/; - -ObservedEvent LastRegisteredEvent/* = 0*/; - -} // namespace -} // namespace internal - -void startObservers() { - if (!internal::StartCallbacks) return; - - for (auto &callback : *internal::StartCallbacks) { - callback.call(callback.that); - } -} - -void finishObservers() { - if (!internal::FinishCallbacks) return; - - for (auto &callback : *internal::FinishCallbacks) { - callback.call(callback.that); - } - internal::StartCallbacks.clear(); - internal::FinishCallbacks.clear(); -} - -namespace internal { - -BaseObservedEventRegistrator::BaseObservedEventRegistrator(void *that -, StartCallback startCallback -, FinishCallback finishCallback -, UnregisterCallback unregisterCallback) { - _event = LastRegisteredEvent++; - - StartCallbacks.makeIfNull(); - StartCallbacks->push_back({ that, startCallback }); - - FinishCallbacks.makeIfNull(); - FinishCallbacks->push_back({ that, finishCallback }); - - UnregisterCallbacks[_event] = { that, unregisterCallback }; -} - -} // namespace internal - -// Observer base interface. -Observer::~Observer() { - for_const (auto connection, _connections) { - unregisterObserver(connection); - } -} - -void Observer::observerRegistered(ConnectionId connection) { - _connections.push_back(connection); -} - -void unregisterObserver(ConnectionId connection) { - auto event = static_cast(connection >> 24); - auto connectionIndex = int(connection & 0x00FFFFFFU) - 1; - auto &callback = internal::UnregisterCallbacks[event]; - if (connectionIndex >= 0 && callback.call && callback.that) { - callback.call(callback.that, connectionIndex); - } -} - -namespace internal { - -void observerRegisteredDefault(Observer *observer, ConnectionId connection) { - observer->observerRegistered(connection); -} - -} // namespace internal -} // namespace Notify - namespace base { namespace internal { namespace { diff --git a/Telegram/SourceFiles/core/observer.h b/Telegram/SourceFiles/core/observer.h index 91dd28d24..5ba24d25c 100644 --- a/Telegram/SourceFiles/core/observer.h +++ b/Telegram/SourceFiles/core/observer.h @@ -22,230 +22,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "core/vector_of_moveable.h" -namespace Notify { - -using ConnectionId = uint32; - -// startObservers() must be called after main() started (not in a global variable constructor). -// finishObservers() must be called before main() finished (not in a global variable destructor). -void startObservers(); -void finishObservers(); - -using StartObservedEventCallback = void(*)(); -using FinishObservedEventCallback = void(*)(); - -namespace internal { - -using ObservedEvent = uchar; -using StartCallback = void(*)(void*); -using FinishCallback = void(*)(void*); -using UnregisterCallback = void(*)(void*,int connectionIndex); - -class BaseObservedEventRegistrator { -public: - BaseObservedEventRegistrator(void *that - , StartCallback startCallback - , FinishCallback finishCallback - , UnregisterCallback unregisterCallback); - -protected: - inline ObservedEvent event() const { - return _event; - } - -private: - ObservedEvent _event; - -}; - -// Handler is one of base::lambda_unique<> instantiations. -template -struct ObserversList { - struct Entry { - Flags flags; - Handler handler; - }; - std_::vector_of_moveable entries; - QVector freeIndices; -}; - -// If no filtering by flags is done, you can use Flags=int and this value. -constexpr int UniversalFlag = 0x01; - -} // namespace internal - -// Objects of this class should be constructed in global scope. -// startCallback will be called from Notify::startObservers(). -// finishCallback will be called from Notify::finishObservers(). -template -class ObservedEventRegistrator : public internal::BaseObservedEventRegistrator { -public: - ObservedEventRegistrator(StartObservedEventCallback startCallback, - FinishObservedEventCallback finishCallback) : internal::BaseObservedEventRegistrator(static_cast(this), - ObservedEventRegistrator::start, - ObservedEventRegistrator::finish, - ObservedEventRegistrator::unregister) - , _startCallback(startCallback), _finishCallback(finishCallback) { - } - - bool started() const { - return _list != nullptr; - } - - ConnectionId registerObserver(Flags flags, Handler &&handler) { - t_assert(started()); - - int connectionIndex = doRegisterObserver(flags, std_::forward(handler)); - return (static_cast(event()) << 24) | static_cast(connectionIndex + 1); - } - - template - void notify(Flags flags, Args&&... args) { - t_assert(started()); - - auto &entries = _list->entries; - // This way of iterating (i < entries.size() should be used - // because some entries can be removed from the end of the - // entries list while the loop is still running. - for (int i = 0; i < entries.size(); ++i) { - auto &entry = entries[i]; - if (entry.handler && (flags & entry.flags)) { - entry.handler(std_::forward(args)...); - } - } - } - -private: - using Self = ObservedEventRegistrator; - static void start(void *vthat) { - Self *that = static_cast(vthat); - - t_assert(!that->started()); - if (that->_startCallback) that->_startCallback(); - that->_list = new internal::ObserversList(); - } - static void finish(void *vthat) { - Self *that = static_cast(vthat); - - if (that->_finishCallback) that->_finishCallback(); - delete that->_list; - that->_list = nullptr; - } - static void unregister(void *vthat, int connectionIndex) { - Self *that = static_cast(vthat); - - t_assert(that->started()); - - auto &entries = that->_list->entries; - if (entries.size() <= connectionIndex) return; - - if (entries.size() == connectionIndex + 1) { - for (entries.pop_back(); !entries.isEmpty() && !entries.back().handler;) { - entries.pop_back(); - } - } else { - entries[connectionIndex].handler = Handler(); - that->_list->freeIndices.push_back(connectionIndex); - } - } - - int doRegisterObserver(Flags flags, Handler &&handler) { - while (!_list->freeIndices.isEmpty()) { - auto freeIndex = _list->freeIndices.back(); - _list->freeIndices.pop_back(); - - if (freeIndex < _list->entries.size()) { - _list->entries[freeIndex] = { flags, std_::move(handler) }; - return freeIndex; - } - } - _list->entries.push_back({ flags, std_::move(handler) }); - return _list->entries.size() - 1; - } - - StartObservedEventCallback _startCallback; - FinishObservedEventCallback _finishCallback; - internal::ObserversList *_list = nullptr; - -}; - -// If no filtering of notifications by Flags is intended use this class. -template -class SimpleObservedEventRegistrator { -public: - SimpleObservedEventRegistrator(StartObservedEventCallback startCallback, - FinishObservedEventCallback finishCallback) : _implementation(startCallback, finishCallback) { - } - - bool started() const { - return _implementation.started(); - } - - ConnectionId registerObserver(Handler &&handler) { - return _implementation.registerObserver(internal::UniversalFlag, std_::forward(handler)); - } - - template - void notify(Args&&... args) { - return _implementation.notify(internal::UniversalFlag, std_::forward(args)...); - } - -private: - ObservedEventRegistrator _implementation; - -}; - -// Each observer type should have observerRegistered(Notify::ConnectionId connection) method. -// Usually it is done by deriving the type from the Notify::Observer base class. -// In destructor it should call Notify::unregisterObserver(connection) for all the connections. - -class Observer; -namespace internal { -void observerRegisteredDefault(Observer *observer, ConnectionId connection); -} // namespace internal - -void unregisterObserver(ConnectionId connection); - -class Observer { -public: - virtual ~Observer() = 0; - -private: - void observerRegistered(ConnectionId connection); - friend void internal::observerRegisteredDefault(Observer *observer, ConnectionId connection); - - QVector _connections; - -}; - -namespace internal { - -template -struct ObserverRegisteredGeneric { - static inline void call(ObserverType *observer, ConnectionId connection) { - observer->observerRegistered(connection); - } -}; - -template -struct ObserverRegisteredGeneric { - static inline void call(ObserverType *observer, ConnectionId connection) { - observerRegisteredDefault(observer, connection); - } -}; - -} // namespace internal - -template -inline void observerRegistered(ObserverType *observer, ConnectionId connection) { - // For derivatives of the Observer class we call special friend function observerRegistered(). - // For all other classes we call just a member function observerRegistered(). - using ObserverRegistered = internal::ObserverRegisteredGeneric::value>; - ObserverRegistered::call(observer, connection); -} - -} // namespace Notify - namespace base { namespace internal { diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 23ee2bd5b..87b63fb6a 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,7 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "core/basic_types.h" -#define BETA_VERSION_MACRO (0ULL) +#define BETA_VERSION_MACRO (10008001ULL) constexpr int AppVersion = 10008; constexpr str_const AppVersionStr = "0.10.8"; diff --git a/Telegram/SourceFiles/observer_peer.cpp b/Telegram/SourceFiles/observer_peer.cpp index 8347b8973..e4d463e5f 100644 --- a/Telegram/SourceFiles/observer_peer.cpp +++ b/Telegram/SourceFiles/observer_peer.cpp @@ -31,8 +31,6 @@ void emitPeerUpdated(); namespace Notify { namespace { -using internal::PeerUpdateHandler; - using SmallUpdatesList = QVector; NeverFreedPointer SmallUpdates; using AllUpdatesList = QMap; @@ -46,21 +44,11 @@ void FinishCallback() { SmallUpdates.clear(); AllUpdates.clear(); } -ObservedEventRegistrator creator(StartCallback, FinishCallback); base::Observable PeerUpdatedObservable; } // namespace -namespace internal { - -ConnectionId plainRegisterPeerObserver(PeerUpdate::Flags events, PeerUpdateHandler &&handler) { - constexpr auto tmp = sizeof(PeerUpdate); - return creator.registerObserver(events, std_::forward(handler)); -} - -} // namespace internal - void mergePeerUpdate(PeerUpdate &mergeTo, const PeerUpdate &mergeFrom) { if (!(mergeTo.flags & PeerUpdate::Flag::NameChanged)) { if (mergeFrom.flags & PeerUpdate::Flag::NameChanged) { @@ -75,7 +63,8 @@ void mergePeerUpdate(PeerUpdate &mergeTo, const PeerUpdate &mergeFrom) { } void peerUpdatedDelayed(const PeerUpdate &update) { - t_assert(creator.started()); + SmallUpdates.makeIfNull(); + AllUpdates.makeIfNull(); Global::RefHandleDelayedPeerUpdates().call(); @@ -87,6 +76,7 @@ void peerUpdatedDelayed(const PeerUpdate &update) { return; } } + if (AllUpdates->isEmpty()) { if (existingUpdatesCount < 5) { SmallUpdates->push_back(update); @@ -104,26 +94,19 @@ void peerUpdatedDelayed(const PeerUpdate &update) { } void peerUpdatedSendDelayed() { - if (!creator.started()) return; - App::emitPeerUpdated(); - if (SmallUpdates->isEmpty()) return; + if (!SmallUpdates || !AllUpdates || SmallUpdates->empty()) return; auto smallList = createAndSwap(*SmallUpdates); auto allList = createAndSwap(*AllUpdates); - for_const (auto &update, smallList) { - creator.notify(update.flags, update); - } - for_const (auto &update, allList) { - creator.notify(update.flags, update); - } for (auto &update : smallList) { PeerUpdated().notify(std_::move(update), true); } for (auto &update : allList) { PeerUpdated().notify(std_::move(update), true); } + if (SmallUpdates->isEmpty()) { std::swap(smallList, *SmallUpdates); SmallUpdates->resize(0); diff --git a/Telegram/SourceFiles/observer_peer.h b/Telegram/SourceFiles/observer_peer.h index d56299c9d..7dd1317d0 100644 --- a/Telegram/SourceFiles/observer_peer.h +++ b/Telegram/SourceFiles/observer_peer.h @@ -89,19 +89,6 @@ inline void peerUpdatedDelayed(PeerData *peer, PeerUpdate::Flags events) { } void peerUpdatedSendDelayed(); -namespace internal { - -using PeerUpdateHandler = base::lambda_unique; -ConnectionId plainRegisterPeerObserver(PeerUpdate::Flags events, PeerUpdateHandler &&handler); - -} // namespace internal - -template -void registerPeerObserver(PeerUpdate::Flags events, ObserverType *observer, Lambda &&other) { - auto connection = internal::plainRegisterPeerObserver(events, std_::move(other)); - observerRegistered(observer, connection); -} - class PeerUpdatedHandler { public: template diff --git a/Telegram/SourceFiles/profile/profile_actions_widget.cpp b/Telegram/SourceFiles/profile/profile_actions_widget.cpp index 49f64ee4d..f8c04ae0f 100644 --- a/Telegram/SourceFiles/profile/profile_actions_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_actions_widget.cpp @@ -39,9 +39,9 @@ ActionsWidget::ActionsWidget(QWidget *parent, PeerData *peer) : BlockWidget(pare | UpdateFlag::UserIsBlocked | UpdateFlag::BotCommandsChanged | UpdateFlag::MembersChanged; - Notify::registerPeerObserver(observeEvents, this, [this](const Notify::PeerUpdate &update) { + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); + })); validateBlockStatus(); refreshButtons(); diff --git a/Telegram/SourceFiles/profile/profile_block_widget.h b/Telegram/SourceFiles/profile/profile_block_widget.h index 541c9dede..d185f9f04 100644 --- a/Telegram/SourceFiles/profile/profile_block_widget.h +++ b/Telegram/SourceFiles/profile/profile_block_widget.h @@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org namespace Profile { -class BlockWidget : public ScrolledWidget, public Notify::Observer, protected base::Subscriber { +class BlockWidget : public ScrolledWidget, protected base::Subscriber { Q_OBJECT public: diff --git a/Telegram/SourceFiles/profile/profile_cover.cpp b/Telegram/SourceFiles/profile/profile_cover.cpp index cdcc56151..cb13f68fc 100644 --- a/Telegram/SourceFiles/profile/profile_cover.cpp +++ b/Telegram/SourceFiles/profile/profile_cover.cpp @@ -68,9 +68,9 @@ CoverWidget::CoverWidget(QWidget *parent, PeerData *peer) : TWidget(parent) auto observeEvents = ButtonsUpdateFlags | UpdateFlag::NameChanged | UpdateFlag::UserOnlineChanged; - Notify::registerPeerObserver(observeEvents, this, [this](const Notify::PeerUpdate &update) { + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); + })); subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) { notifyFileQueryUpdated(update); }); diff --git a/Telegram/SourceFiles/profile/profile_cover.h b/Telegram/SourceFiles/profile/profile_cover.h index a735c1062..3abd8e66e 100644 --- a/Telegram/SourceFiles/profile/profile_cover.h +++ b/Telegram/SourceFiles/profile/profile_cover.h @@ -40,7 +40,7 @@ class BackButton; class UserpicButton; class CoverDropArea; -class CoverWidget final : public TWidget, public Notify::Observer, private base::Subscriber { +class CoverWidget final : public TWidget, private base::Subscriber { Q_OBJECT public: diff --git a/Telegram/SourceFiles/profile/profile_fixed_bar.cpp b/Telegram/SourceFiles/profile/profile_fixed_bar.cpp index 36d44ee86..c936b2296 100644 --- a/Telegram/SourceFiles/profile/profile_fixed_bar.cpp +++ b/Telegram/SourceFiles/profile/profile_fixed_bar.cpp @@ -83,9 +83,9 @@ FixedBar::FixedBar(QWidget *parent, PeerData *peer) : TWidget(parent) auto observeEvents = ButtonsUpdateFlags | UpdateFlag::MigrationChanged; - Notify::registerPeerObserver(observeEvents, this, [this](const Notify::PeerUpdate &update) { + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdate(update); - }); + })); refreshRightActions(); } diff --git a/Telegram/SourceFiles/profile/profile_fixed_bar.h b/Telegram/SourceFiles/profile/profile_fixed_bar.h index 3030eef49..18fa64d05 100644 --- a/Telegram/SourceFiles/profile/profile_fixed_bar.h +++ b/Telegram/SourceFiles/profile/profile_fixed_bar.h @@ -34,7 +34,7 @@ namespace Profile { class BackButton; -class FixedBar final : public TWidget, public Notify::Observer { +class FixedBar final : public TWidget, private base::Subscriber { Q_OBJECT public: diff --git a/Telegram/SourceFiles/profile/profile_info_widget.cpp b/Telegram/SourceFiles/profile/profile_info_widget.cpp index c844fcb2f..e1d2b7247 100644 --- a/Telegram/SourceFiles/profile/profile_info_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_info_widget.cpp @@ -36,9 +36,9 @@ InfoWidget::InfoWidget(QWidget *parent, PeerData *peer) : BlockWidget(parent, pe | UpdateFlag::UsernameChanged | UpdateFlag::UserPhoneChanged | UpdateFlag::UserCanShareContact; - Notify::registerPeerObserver(observeEvents, this, [this](const Notify::PeerUpdate &update) { + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); + })); refreshLabels(); } diff --git a/Telegram/SourceFiles/profile/profile_invite_link_widget.cpp b/Telegram/SourceFiles/profile/profile_invite_link_widget.cpp index e5c3f29a9..c33bad2e1 100644 --- a/Telegram/SourceFiles/profile/profile_invite_link_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_invite_link_widget.cpp @@ -33,9 +33,9 @@ using UpdateFlag = Notify::PeerUpdate::Flag; InviteLinkWidget::InviteLinkWidget(QWidget *parent, PeerData *peer) : BlockWidget(parent, peer, lang(lng_profile_invite_link_section)) { auto observeEvents = UpdateFlag::InviteLinkChanged | UpdateFlag::UsernameChanged; - Notify::registerPeerObserver(observeEvents, this, [this](const Notify::PeerUpdate &update) { + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); + })); refreshLink(); refreshVisibility(); diff --git a/Telegram/SourceFiles/profile/profile_members_widget.cpp b/Telegram/SourceFiles/profile/profile_members_widget.cpp index f6bcc2f50..665b4dc01 100644 --- a/Telegram/SourceFiles/profile/profile_members_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_members_widget.cpp @@ -49,9 +49,9 @@ MembersWidget::MembersWidget(QWidget *parent, PeerData *peer, TitleVisibility ti auto observeEvents = UpdateFlag::AdminsChanged | UpdateFlag::MembersChanged | UpdateFlag::UserOnlineChanged; - Notify::registerPeerObserver(observeEvents, this, [this](const Notify::PeerUpdate &update) { + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); + })); subscribe(FileDownload::ImageLoaded(), [this] { update(); }); refreshMembers(); @@ -604,9 +604,9 @@ ChannelMembersWidget::ChannelMembersWidget(QWidget *parent, PeerData *peer) : Bl | UpdateFlag::ChannelCanViewMembers | UpdateFlag::AdminsChanged | UpdateFlag::MembersChanged; - Notify::registerPeerObserver(observeEvents, this, [this](const Notify::PeerUpdate &update) { + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); + })); refreshButtons(); } diff --git a/Telegram/SourceFiles/profile/profile_settings_widget.cpp b/Telegram/SourceFiles/profile/profile_settings_widget.cpp index ed47209de..d94ec9868 100644 --- a/Telegram/SourceFiles/profile/profile_settings_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_settings_widget.cpp @@ -51,9 +51,9 @@ SettingsWidget::SettingsWidget(QWidget *parent, PeerData *peer) : BlockWidget(pa observeEvents |= UpdateFlag::UsernameChanged | UpdateFlag::InviteLinkChanged; } } - Notify::registerPeerObserver(observeEvents, this, [this](const Notify::PeerUpdate &update) { + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); + })); refreshButtons(); _enableNotifications->finishAnimations(); diff --git a/Telegram/SourceFiles/profile/profile_shared_media_widget.cpp b/Telegram/SourceFiles/profile/profile_shared_media_widget.cpp index 1f6e4679e..4bb82923d 100644 --- a/Telegram/SourceFiles/profile/profile_shared_media_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_shared_media_widget.cpp @@ -51,9 +51,10 @@ QString getButtonText(MediaOverviewType type, int count) { SharedMediaWidget::SharedMediaWidget(QWidget *parent, PeerData *peer) : BlockWidget(parent, peer, lang(lng_profile_shared_media)) , _history(App::history(peer)) , _migrated(peer->migrateFrom() ? App::history(peer->migrateFrom()) : nullptr) { - Notify::registerPeerObserver(Notify::PeerUpdate::Flag::SharedMediaChanged, this, [this](const Notify::PeerUpdate &update) { + auto observeEvents = Notify::PeerUpdate::Flag::SharedMediaChanged; + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); + })); App::main()->preloadOverviews(peer); if (_migrated) { diff --git a/Telegram/SourceFiles/profile/profile_userpic_button.cpp b/Telegram/SourceFiles/profile/profile_userpic_button.cpp index 6b7b1ed91..547d93a10 100644 --- a/Telegram/SourceFiles/profile/profile_userpic_button.cpp +++ b/Telegram/SourceFiles/profile/profile_userpic_button.cpp @@ -36,9 +36,10 @@ UserpicButton::UserpicButton(QWidget *parent, PeerData *peer) : Button(parent), _userpic = prepareUserpicPixmap(); } - Notify::registerPeerObserver(Notify::PeerUpdate::Flag::PhotoChanged, this, [this](const Notify::PeerUpdate &update) { + auto observeEvents = Notify::PeerUpdate::Flag::PhotoChanged; + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); + })); subscribe(FileDownload::ImageLoaded(), [this] { if (_waiting && _peer->userpicLoaded()) { _waiting = false; diff --git a/Telegram/SourceFiles/profile/profile_userpic_button.h b/Telegram/SourceFiles/profile/profile_userpic_button.h index cfac826e1..0bec52b7a 100644 --- a/Telegram/SourceFiles/profile/profile_userpic_button.h +++ b/Telegram/SourceFiles/profile/profile_userpic_button.h @@ -28,7 +28,7 @@ struct PeerUpdate; namespace Profile { -class UserpicButton final : public Button, public Notify::Observer, private base::Subscriber { +class UserpicButton final : public Button, private base::Subscriber { public: UserpicButton(QWidget *parent, PeerData *peer); diff --git a/Telegram/SourceFiles/settings/settings_block_widget.h b/Telegram/SourceFiles/settings/settings_block_widget.h index 2118db484..6f34ae152 100644 --- a/Telegram/SourceFiles/settings/settings_block_widget.h +++ b/Telegram/SourceFiles/settings/settings_block_widget.h @@ -32,7 +32,7 @@ class WidgetSlideWrap; namespace Settings { -class BlockWidget : public ScrolledWidget, public Notify::Observer, protected base::Subscriber { +class BlockWidget : public ScrolledWidget, protected base::Subscriber { Q_OBJECT public: diff --git a/Telegram/SourceFiles/settings/settings_cover.cpp b/Telegram/SourceFiles/settings/settings_cover.cpp index 2f63bd4b4..01ab0d450 100644 --- a/Telegram/SourceFiles/settings/settings_cover.cpp +++ b/Telegram/SourceFiles/settings/settings_cover.cpp @@ -57,10 +57,9 @@ CoverWidget::CoverWidget(QWidget *parent, UserData *self) : BlockWidget(parent, connect(_editNameInline, SIGNAL(clicked()), this, SLOT(onEditName())); auto observeEvents = Notify::PeerUpdate::Flag::NameChanged; - Notify::registerPeerObserver(observeEvents, this, [this](const Notify::PeerUpdate &update) { + subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); - }); - + })); subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) { notifyFileQueryUpdated(update); }); diff --git a/Telegram/build/version b/Telegram/build/version index 8cf1ec88d..a56338061 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -3,4 +3,4 @@ AppVersionStrMajor 0.10 AppVersionStrSmall 0.10.8 AppVersionStr 0.10.8 AlphaChannel 0 -BetaVersion 0 +BetaVersion 10008001