Use shared_ptr<Memento> for sections.

This commit is contained in:
John Preston 2020-12-14 18:48:10 +04:00
parent baba7e272d
commit b6483cb65c
54 changed files with 147 additions and 152 deletions

View file

@ -3412,7 +3412,7 @@ void ApiWrap::jumpToHistoryDate(not_null<PeerData*> peer, const QDate &date) {
// requestMessageAfterDate(feed, date, [=](Data::MessagePosition result) { // requestMessageAfterDate(feed, date, [=](Data::MessagePosition result) {
// Ui::hideLayer(); // Ui::hideLayer();
// App::wnd()->sessionController()->showSection( // App::wnd()->sessionController()->showSection(
// std::make_unique<HistoryFeed::Memento>(feed, result)); // std::make_shared<HistoryFeed::Memento>(feed, result));
// }); // });
//} //}

View file

@ -1002,7 +1002,7 @@ void Controller::fillManageSection() {
if (hasRecentActions) { if (hasRecentActions) {
auto callback = [=] { auto callback = [=] {
_navigation->showSection( _navigation->showSection(
std::make_unique<AdminLog::SectionMemento>(channel)); std::make_shared<AdminLog::SectionMemento>(channel));
}; };
AddButtonWithCount( AddButtonWithCount(
_controls.buttonsLayout, _controls.buttonsLayout,

View file

@ -1591,7 +1591,7 @@ void UpdateApplication() {
if (const auto window = App::wnd()) { if (const auto window = App::wnd()) {
if (const auto controller = window->sessionController()) { if (const auto controller = window->sessionController()) {
controller->showSection( controller->showSection(
std::make_unique<Info::Memento>( std::make_shared<Info::Memento>(
Info::Settings::Tag{ controller->session().user() }, Info::Settings::Tag{ controller->session().user() },
Info::Section::SettingsType::Advanced), Info::Section::SettingsType::Advanced),
Window::SectionShow()); Window::SectionShow());

View file

@ -56,7 +56,7 @@ void SharedMediaShowOverview(
return; return;
} }
} }
windows.front()->showSection(std::make_unique<Info::Memento>( windows.front()->showSection(std::make_shared<Info::Memento>(
history->peer, history->peer,
Info::Section(type))); Info::Section(type)));
} }

View file

@ -1776,7 +1776,7 @@ bool Widget::onCancelSearch() {
if (const auto peer = _searchInChat.peer()) { if (const auto peer = _searchInChat.peer()) {
Ui::showPeerHistory(peer, ShowAtUnreadMsgId); Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
//} else if (const auto feed = _searchInChat.feed()) { // #feed //} else if (const auto feed = _searchInChat.feed()) { // #feed
// controller()->showSection(std::make_unique<HistoryFeed::Memento>(feed)); // controller()->showSection(std::make_shared<HistoryFeed::Memento>(feed));
} else { } else {
Unexpected("Empty key in onCancelSearch()."); Unexpected("Empty key in onCancelSearch().");
} }
@ -1800,7 +1800,7 @@ void Widget::onCancelSearchInChat() {
if (const auto peer = _searchInChat.peer()) { if (const auto peer = _searchInChat.peer()) {
Ui::showPeerHistory(peer, ShowAtUnreadMsgId); Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
//} else if (const auto feed = _searchInChat.feed()) { // #feed //} else if (const auto feed = _searchInChat.feed()) { // #feed
// controller()->showSection(std::make_unique<HistoryFeed::Memento>(feed)); // controller()->showSection(std::make_shared<HistoryFeed::Memento>(feed));
} else { } else {
Unexpected("Empty key in onCancelSearchInPeer()."); Unexpected("Empty key in onCancelSearchInPeer().");
} }

View file

@ -371,8 +371,8 @@ void Widget::setupShortcuts() {
}, lifetime()); }, lifetime());
} }
std::unique_ptr<Window::SectionMemento> Widget::createMemento() { std::shared_ptr<Window::SectionMemento> Widget::createMemento() {
auto result = std::make_unique<SectionMemento>(channel()); auto result = std::make_shared<SectionMemento>(channel());
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -59,7 +59,7 @@ public:
bool showInternal( bool showInternal(
not_null<Window::SectionMemento*> memento, not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params) override; const Window::SectionShow &params) override;
std::unique_ptr<Window::SectionMemento> createMemento() override; std::shared_ptr<Window::SectionMemento> createMemento() override;
void setInternalState(const QRect &geometry, not_null<SectionMemento*> memento); void setInternalState(const QRect &geometry, not_null<SectionMemento*> memento);

View file

@ -687,7 +687,7 @@ HistoryWidget::HistoryWidget(
cancelReply(lastKeyboardUsed); cancelReply(lastKeyboardUsed);
crl::on_main(this, [=, history = action.history]{ crl::on_main(this, [=, history = action.history]{
controller->showSection( controller->showSection(
std::make_unique<HistoryView::ScheduledMemento>(history)); std::make_shared<HistoryView::ScheduledMemento>(history));
}); });
} else { } else {
fastShowAtEnd(action.history); fastShowAtEnd(action.history);
@ -1502,7 +1502,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U
} else if (to.section == Section::Scheduled) { } else if (to.section == Section::Scheduled) {
history->setDraft(Data::DraftKey::Scheduled(), std::move(draft)); history->setDraft(Data::DraftKey::Scheduled(), std::move(draft));
controller()->showSection( controller()->showSection(
std::make_unique<HistoryView::ScheduledMemento>(history)); std::make_shared<HistoryView::ScheduledMemento>(history));
} else { } else {
history->setLocalDraft(std::move(draft)); history->setLocalDraft(std::move(draft));
if (history == _history) { if (history == _history) {
@ -2070,7 +2070,7 @@ void HistoryWidget::refreshScheduledToggle() {
_scheduled->show(); _scheduled->show();
_scheduled->addClickHandler([=] { _scheduled->addClickHandler([=] {
controller()->showSection( controller()->showSection(
std::make_unique<HistoryView::ScheduledMemento>(_history)); std::make_shared<HistoryView::ScheduledMemento>(_history));
}); });
orderWidgets(); // Raise drag areas to the top. orderWidgets(); // Raise drag areas to the top.
} else if (_scheduled && !has) { } else if (_scheduled && !has) {
@ -3880,7 +3880,7 @@ bool HistoryWidget::pushTabbedSelectorToThirdSection(
Core::App().settings().setTabbedReplacedWithInfo(false); Core::App().settings().setTabbedReplacedWithInfo(false);
controller()->resizeForThirdSection(); controller()->resizeForThirdSection();
controller()->showSection( controller()->showSection(
std::make_unique<ChatHelpers::TabbedMemento>(), std::make_shared<ChatHelpers::TabbedMemento>(),
params.withThirdColumn()); params.withThirdColumn());
return true; return true;
} }
@ -5387,7 +5387,7 @@ void HistoryWidget::refreshPinnedBarButton(bool many) {
const auto id = _pinnedTracker->currentMessageId(); const auto id = _pinnedTracker->currentMessageId();
if (id.message) { if (id.message) {
controller()->showSection( controller()->showSection(
std::make_unique<HistoryView::PinnedMemento>( std::make_shared<HistoryView::PinnedMemento>(
_history, _history,
((!_migrated || id.message.channel) ((!_migrated || id.message.channel)
? id.message.msg ? id.message.msg

View file

@ -1736,7 +1736,7 @@ bool ComposeControls::pushTabbedSelectorToThirdSection(
&st::historyRecordVoiceRippleBgActive); &st::historyRecordVoiceRippleBgActive);
_window->resizeForThirdSection(); _window->resizeForThirdSection();
_window->showSection( _window->showSection(
std::make_unique<ChatHelpers::TabbedMemento>(), std::make_shared<ChatHelpers::TabbedMemento>(),
params.withThirdColumn()); params.withThirdColumn());
return true; return true;
} }

View file

@ -342,8 +342,8 @@ void PinnedWidget::setInternalState(
restoreState(memento); restoreState(memento);
} }
std::unique_ptr<Window::SectionMemento> PinnedWidget::createMemento() { std::shared_ptr<Window::SectionMemento> PinnedWidget::createMemento() {
auto result = std::make_unique<PinnedMemento>(history()); auto result = std::make_shared<PinnedMemento>(history());
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -56,7 +56,7 @@ public:
bool showInternal( bool showInternal(
not_null<Window::SectionMemento*> memento, not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params) override; const Window::SectionShow &params) override;
std::unique_ptr<Window::SectionMemento> createMemento() override; std::shared_ptr<Window::SectionMemento> createMemento() override;
bool showMessage( bool showMessage(
PeerId peerId, PeerId peerId,
const Window::SectionShow &params, const Window::SectionShow &params,

View file

@ -1367,8 +1367,8 @@ bool RepliesWidget::returnTabbedSelector() {
return _composeControls->returnTabbedSelector(); return _composeControls->returnTabbedSelector();
} }
std::unique_ptr<Window::SectionMemento> RepliesWidget::createMemento() { std::shared_ptr<Window::SectionMemento> RepliesWidget::createMemento() {
auto result = std::make_unique<RepliesMemento>(history(), _rootId); auto result = std::make_shared<RepliesMemento>(history(), _rootId);
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -87,7 +87,7 @@ public:
bool showInternal( bool showInternal(
not_null<Window::SectionMemento*> memento, not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params) override; const Window::SectionShow &params) override;
std::unique_ptr<Window::SectionMemento> createMemento() override; std::shared_ptr<Window::SectionMemento> createMemento() override;
bool showMessage( bool showMessage(
PeerId peerId, PeerId peerId,
const Window::SectionShow &params, const Window::SectionShow &params,

View file

@ -941,8 +941,8 @@ bool ScheduledWidget::returnTabbedSelector() {
return _composeControls->returnTabbedSelector(); return _composeControls->returnTabbedSelector();
} }
std::unique_ptr<Window::SectionMemento> ScheduledWidget::createMemento() { std::shared_ptr<Window::SectionMemento> ScheduledWidget::createMemento() {
auto result = std::make_unique<ScheduledMemento>(history()); auto result = std::make_shared<ScheduledMemento>(history());
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -72,7 +72,7 @@ public:
bool showInternal( bool showInternal(
not_null<Window::SectionMemento*> memento, not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params) override; const Window::SectionShow &params) override;
std::unique_ptr<Window::SectionMemento> createMemento() override; std::shared_ptr<Window::SectionMemento> createMemento() override;
void setInternalState( void setInternalState(
const QRect &geometry, const QRect &geometry,

View file

@ -493,15 +493,15 @@ void TopBarWidget::infoClicked() {
} else if (key.folder()) { } else if (key.folder()) {
_controller->closeFolder(); _controller->closeFolder();
//} else if (const auto feed = _activeChat.feed()) { // #feed //} else if (const auto feed = _activeChat.feed()) { // #feed
// _controller->showSection(std::make_unique<Info::Memento>( // _controller->showSection(std::make_shared<Info::Memento>(
// feed, // feed,
// Info::Section(Info::Section::Type::Profile))); // Info::Section(Info::Section::Type::Profile)));
} else if (key.peer()->isSelf()) { } else if (key.peer()->isSelf()) {
_controller->showSection(std::make_unique<Info::Memento>( _controller->showSection(std::make_shared<Info::Memento>(
key.peer(), key.peer(),
Info::Section(Storage::SharedMediaType::Photo))); Info::Section(Storage::SharedMediaType::Photo)));
} else if (key.peer()->isRepliesChat()) { } else if (key.peer()->isRepliesChat()) {
_controller->showSection(std::make_unique<Info::Memento>( _controller->showSection(std::make_shared<Info::Memento>(
key.peer(), key.peer(),
Info::Section(Storage::SharedMediaType::Photo))); Info::Section(Storage::SharedMediaType::Photo)));
} else { } else {

View file

@ -87,8 +87,8 @@ void Widget::setInternalState(
restoreState(memento); restoreState(memento);
} }
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::shared_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(user()); auto result = std::make_shared<Memento>(user());
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -64,7 +64,7 @@ private:
void saveState(not_null<Memento*> memento); void saveState(not_null<Memento*> memento);
void restoreState(not_null<Memento*> memento); void restoreState(not_null<Memento*> memento);
std::unique_ptr<ContentMemento> doCreateMemento() override; std::shared_ptr<ContentMemento> doCreateMemento() override;
InnerWidget *_inner = nullptr; InnerWidget *_inner = nullptr;

View file

@ -94,7 +94,7 @@ void ContentWidget::updateControlsGeometry() {
} }
} }
std::unique_ptr<ContentMemento> ContentWidget::createMemento() { std::shared_ptr<ContentMemento> ContentWidget::createMemento() {
auto result = doCreateMemento(); auto result = doCreateMemento();
_controller->saveSearchState(result.get()); _controller->saveSearchState(result.get());
return result; return result;

View file

@ -39,7 +39,7 @@ public:
virtual bool showInternal( virtual bool showInternal(
not_null<ContentMemento*> memento) = 0; not_null<ContentMemento*> memento) = 0;
std::unique_ptr<ContentMemento> createMemento(); std::shared_ptr<ContentMemento> createMemento();
virtual void setIsStackBottom(bool isStackBottom) { virtual void setIsStackBottom(bool isStackBottom) {
} }
@ -96,7 +96,7 @@ private:
void updateControlsGeometry(); void updateControlsGeometry();
void refreshSearchField(bool shown); void refreshSearchField(bool shown);
virtual std::unique_ptr<ContentMemento> doCreateMemento() = 0; virtual std::shared_ptr<ContentMemento> doCreateMemento() = 0;
const not_null<Controller*> _controller; const not_null<Controller*> _controller;

View file

@ -123,7 +123,7 @@ PollData *AbstractController::poll() const {
} }
void AbstractController::showSection( void AbstractController::showSection(
std::unique_ptr<Window::SectionMemento> &&memento, std::shared_ptr<Window::SectionMemento> memento,
const Window::SectionShow &params) { const Window::SectionShow &params) {
return parentController()->showSection(std::move(memento), params); return parentController()->showSection(std::move(memento), params);
} }
@ -170,7 +170,7 @@ void Controller::setupMigrationViewer() {
const auto section = _section; const auto section = _section;
InvokeQueued(_widget, [=] { InvokeQueued(_widget, [=] {
window->showSection( window->showSection(
std::make_unique<Memento>(peer, section), std::make_shared<Memento>(peer, section),
Window::SectionShow( Window::SectionShow(
Window::SectionShow::Way::Backward, Window::SectionShow::Way::Backward,
anim::type::instant, anim::type::instant,
@ -261,7 +261,7 @@ void Controller::saveSearchState(not_null<ContentMemento*> memento) {
} }
void Controller::showSection( void Controller::showSection(
std::unique_ptr<Window::SectionMemento> &&memento, std::shared_ptr<Window::SectionMemento> memento,
const Window::SectionShow &params) { const Window::SectionShow &params) {
if (!_widget->showInternal(memento.get(), params)) { if (!_widget->showInternal(memento.get(), params)) {
AbstractController::showSection(std::move(memento), params); AbstractController::showSection(std::move(memento), params);

View file

@ -136,7 +136,7 @@ public:
virtual rpl::producer<QString> mediaSourceQueryValue() const; virtual rpl::producer<QString> mediaSourceQueryValue() const;
void showSection( void showSection(
std::unique_ptr<Window::SectionMemento> &&memento, std::shared_ptr<Window::SectionMemento> memento,
const Window::SectionShow &params = Window::SectionShow()) override; const Window::SectionShow &params = Window::SectionShow()) override;
void showBackFromStack( void showBackFromStack(
const Window::SectionShow &params = Window::SectionShow()) override; const Window::SectionShow &params = Window::SectionShow()) override;
@ -202,7 +202,7 @@ public:
void saveSearchState(not_null<ContentMemento*> memento); void saveSearchState(not_null<ContentMemento*> memento);
void showSection( void showSection(
std::unique_ptr<Window::SectionMemento> &&memento, std::shared_ptr<Window::SectionMemento> memento,
const Window::SectionShow &params = Window::SectionShow()) override; const Window::SectionShow &params = Window::SectionShow()) override;
void showBackFromStack( void showBackFromStack(
const Window::SectionShow &params = Window::SectionShow()) override; const Window::SectionShow &params = Window::SectionShow()) override;

View file

@ -106,7 +106,7 @@ void LayerWidget::parentResized() {
Ui::FocusPersister persister(this); Ui::FocusPersister persister(this);
restoreFloatPlayerDelegate(); restoreFloatPlayerDelegate();
auto memento = std::make_unique<MoveMemento>(std::move(_content)); auto memento = std::make_shared<MoveMemento>(std::move(_content));
// We want to call hideSpecialLayer synchronously to avoid glitches, // We want to call hideSpecialLayer synchronously to avoid glitches,
// but we can't destroy LayerStackWidget from its' resizeEvent, // but we can't destroy LayerStackWidget from its' resizeEvent,

View file

@ -47,41 +47,41 @@ Memento::Memento(not_null<PollData*> poll, FullMsgId contextId)
: Memento(DefaultStack(poll, contextId)) { : Memento(DefaultStack(poll, contextId)) {
} }
Memento::Memento(std::vector<std::unique_ptr<ContentMemento>> stack) Memento::Memento(std::vector<std::shared_ptr<ContentMemento>> stack)
: _stack(std::move(stack)) { : _stack(std::move(stack)) {
} }
std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack( std::vector<std::shared_ptr<ContentMemento>> Memento::DefaultStack(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Section section) { Section section) {
auto result = std::vector<std::unique_ptr<ContentMemento>>(); auto result = std::vector<std::shared_ptr<ContentMemento>>();
result.push_back(DefaultContent(peer, section)); result.push_back(DefaultContent(peer, section));
return result; return result;
} }
//std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack( // #feed //std::vector<std::shared_ptr<ContentMemento>> Memento::DefaultStack( // #feed
// not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
// Section section) { // Section section) {
// auto result = std::vector<std::unique_ptr<ContentMemento>>(); // auto result = std::vector<std::shared_ptr<ContentMemento>>();
// result.push_back(DefaultContent(feed, section)); // result.push_back(DefaultContent(feed, section));
// return result; // return result;
//} //}
// //
std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack( std::vector<std::shared_ptr<ContentMemento>> Memento::DefaultStack(
Settings::Tag settings, Settings::Tag settings,
Section section) { Section section) {
auto result = std::vector<std::unique_ptr<ContentMemento>>(); auto result = std::vector<std::shared_ptr<ContentMemento>>();
result.push_back(std::make_unique<Settings::Memento>( result.push_back(std::make_shared<Settings::Memento>(
settings.self, settings.self,
section.settingsType())); section.settingsType()));
return result; return result;
} }
std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack( std::vector<std::shared_ptr<ContentMemento>> Memento::DefaultStack(
not_null<PollData*> poll, not_null<PollData*> poll,
FullMsgId contextId) { FullMsgId contextId) {
auto result = std::vector<std::unique_ptr<ContentMemento>>(); auto result = std::vector<std::shared_ptr<ContentMemento>>();
result.push_back(std::make_unique<Polls::Memento>(poll, contextId)); result.push_back(std::make_shared<Polls::Memento>(poll, contextId));
return result; return result;
} }
@ -101,8 +101,8 @@ Section Memento::DefaultSection(not_null<PeerData*> peer) {
// return Section(Section::Type::Profile); // return Section(Section::Type::Profile);
//} //}
std::unique_ptr<Memento> Memento::Default(not_null<PeerData*> peer) { std::shared_ptr<Memento> Memento::Default(not_null<PeerData*> peer) {
return std::make_unique<Memento>(peer, DefaultSection(peer)); return std::make_shared<Memento>(peer, DefaultSection(peer));
} }
// // #feed // // #feed
//Memento Memento::Default(Dialogs::Key key) { //Memento Memento::Default(Dialogs::Key key) {
@ -112,7 +112,7 @@ std::unique_ptr<Memento> Memento::Default(not_null<PeerData*> peer) {
// return Memento(key.feed(), DefaultSection(key)); // return Memento(key.feed(), DefaultSection(key));
//} //}
std::unique_ptr<ContentMemento> Memento::DefaultContent( std::shared_ptr<ContentMemento> Memento::DefaultContent(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Section section) { Section section) {
if (auto to = peer->migrateTo()) { if (auto to = peer->migrateTo()) {
@ -123,32 +123,32 @@ std::unique_ptr<ContentMemento> Memento::DefaultContent(
switch (section.type()) { switch (section.type()) {
case Section::Type::Profile: case Section::Type::Profile:
return std::make_unique<Profile::Memento>( return std::make_shared<Profile::Memento>(
peer, peer,
migratedPeerId); migratedPeerId);
case Section::Type::Media: case Section::Type::Media:
return std::make_unique<Media::Memento>( return std::make_shared<Media::Memento>(
peer, peer,
migratedPeerId, migratedPeerId,
section.mediaType()); section.mediaType());
case Section::Type::CommonGroups: case Section::Type::CommonGroups:
return std::make_unique<CommonGroups::Memento>(peer->asUser()); return std::make_shared<CommonGroups::Memento>(peer->asUser());
case Section::Type::Members: case Section::Type::Members:
return std::make_unique<Members::Memento>( return std::make_shared<Members::Memento>(
peer, peer,
migratedPeerId); migratedPeerId);
} }
Unexpected("Wrong section type in Info::Memento::DefaultContent()"); Unexpected("Wrong section type in Info::Memento::DefaultContent()");
} }
// //
//std::unique_ptr<ContentMemento> Memento::DefaultContent( // #feed //std::shared_ptr<ContentMemento> Memento::DefaultContent( // #feed
// not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
// Section section) { // Section section) {
// switch (section.type()) { // switch (section.type()) {
// case Section::Type::Profile: // case Section::Type::Profile:
// return std::make_unique<FeedProfile::Memento>(feed); // return std::make_shared<FeedProfile::Memento>(feed);
// case Section::Type::Channels: // case Section::Type::Channels:
// return std::make_unique<Channels::Memento>(feed); // return std::make_shared<Channels::Memento>(feed);
// } // }
// Unexpected("Wrong feed section in Info::Memento::DefaultContent()"); // Unexpected("Wrong feed section in Info::Memento::DefaultContent()");
//} //}
@ -179,7 +179,7 @@ object_ptr<Ui::LayerWidget> Memento::createLayer(
return nullptr; return nullptr;
} }
std::vector<std::unique_ptr<ContentMemento>> Memento::takeStack() { std::vector<std::shared_ptr<ContentMemento>> Memento::takeStack() {
return std::move(_stack); return std::move(_stack);
} }

View file

@ -37,7 +37,7 @@ public:
//Memento(not_null<Data::Feed*> feed, Section section); // #feed //Memento(not_null<Data::Feed*> feed, Section section); // #feed
Memento(Settings::Tag settings, Section section); Memento(Settings::Tag settings, Section section);
Memento(not_null<PollData*> poll, FullMsgId contextId); Memento(not_null<PollData*> poll, FullMsgId contextId);
explicit Memento(std::vector<std::unique_ptr<ContentMemento>> stack); explicit Memento(std::vector<std::shared_ptr<ContentMemento>> stack);
object_ptr<Window::SectionWidget> createWidget( object_ptr<Window::SectionWidget> createWidget(
QWidget *parent, QWidget *parent,
@ -52,7 +52,7 @@ public:
int stackSize() const { int stackSize() const {
return int(_stack.size()); return int(_stack.size());
} }
std::vector<std::unique_ptr<ContentMemento>> takeStack(); std::vector<std::shared_ptr<ContentMemento>> takeStack();
not_null<ContentMemento*> content() { not_null<ContentMemento*> content() {
Expects(!_stack.empty()); Expects(!_stack.empty());
@ -62,33 +62,33 @@ public:
static Section DefaultSection(not_null<PeerData*> peer); static Section DefaultSection(not_null<PeerData*> peer);
//static Section DefaultSection(Dialogs::Key key); // #feed //static Section DefaultSection(Dialogs::Key key); // #feed
static std::unique_ptr<Memento> Default(not_null<PeerData*> peer); static std::shared_ptr<Memento> Default(not_null<PeerData*> peer);
//static Memento Default(Dialogs::Key key); // #feed //static Memento Default(Dialogs::Key key); // #feed
~Memento(); ~Memento();
private: private:
static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Section section); Section section);
//static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( // #feed //static std::vector<std::shared_ptr<ContentMemento>> DefaultStack( // #feed
// not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
// Section section); // Section section);
static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
Settings::Tag settings, Settings::Tag settings,
Section section); Section section);
static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( static std::vector<std::shared_ptr<ContentMemento>> DefaultStack(
not_null<PollData*> poll, not_null<PollData*> poll,
FullMsgId contextId); FullMsgId contextId);
//static std::unique_ptr<ContentMemento> DefaultContent( // #feed //static std::shared_ptr<ContentMemento> DefaultContent( // #feed
// not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
// Section section); // Section section);
static std::unique_ptr<ContentMemento> DefaultContent( static std::shared_ptr<ContentMemento> DefaultContent(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Section section); Section section);
std::vector<std::unique_ptr<ContentMemento>> _stack; std::vector<std::shared_ptr<ContentMemento>> _stack;
}; };

View file

@ -92,7 +92,7 @@ bool SectionWidget::showInternal(
return _content->showInternal(memento, params); return _content->showInternal(memento, params);
} }
std::unique_ptr<Window::SectionMemento> SectionWidget::createMemento() { std::shared_ptr<Window::SectionMemento> SectionWidget::createMemento() {
return _content->createMemento(); return _content->createMemento();
} }

View file

@ -48,7 +48,7 @@ public:
bool showInternal( bool showInternal(
not_null<Window::SectionMemento*> memento, not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params) override; const Window::SectionShow &params) override;
std::unique_ptr<Window::SectionMemento> createMemento() override; std::shared_ptr<Window::SectionMemento> createMemento() override;
object_ptr<Ui::LayerWidget> moveContentToLayer( object_ptr<Ui::LayerWidget> moveContentToLayer(
QRect bodyGeometry) override; QRect bodyGeometry) override;

View file

@ -50,8 +50,8 @@ const style::InfoTopBar &TopBarStyle(Wrap wrap) {
} // namespace } // namespace
struct WrapWidget::StackItem { struct WrapWidget::StackItem {
std::unique_ptr<ContentMemento> section; std::shared_ptr<ContentMemento> section;
// std::unique_ptr<ContentMemento> anotherTab; // std::shared_ptr<ContentMemento> anotherTab;
}; };
WrapWidget::WrapWidget( WrapWidget::WrapWidget(
@ -96,7 +96,7 @@ void WrapWidget::setupShortcuts() {
} }
void WrapWidget::restoreHistoryStack( void WrapWidget::restoreHistoryStack(
std::vector<std::unique_ptr<ContentMemento>> stack) { std::vector<std::shared_ptr<ContentMemento>> stack) {
Expects(!stack.empty()); Expects(!stack.empty());
Expects(!hasStackHistory()); Expects(!hasStackHistory());
@ -188,7 +188,7 @@ void WrapWidget::injectActivePeerProfile(not_null<PeerData*> peer) {
//} //}
void WrapWidget::injectActiveProfileMemento( void WrapWidget::injectActiveProfileMemento(
std::unique_ptr<ContentMemento> memento) { std::shared_ptr<ContentMemento> memento) {
auto injected = StackItem(); auto injected = StackItem();
injected.section = std::move(memento); injected.section = std::move(memento);
_historyStack.insert( _historyStack.insert(
@ -712,13 +712,13 @@ rpl::producer<SelectedItems> WrapWidget::selectedListValue() const {
// Was done for top level tabs support. // Was done for top level tabs support.
// //
//std::unique_ptr<ContentMemento> WrapWidget::createTabMemento( //std::shared_ptr<ContentMemento> WrapWidget::createTabMemento(
// Tab tab) { // Tab tab) {
// switch (tab) { // switch (tab) {
// case Tab::Profile: return std::make_unique<Profile::Memento>( // case Tab::Profile: return std::make_shared<Profile::Memento>(
// _controller->peerId(), // _controller->peerId(),
// _controller->migratedPeerId()); // _controller->migratedPeerId());
// case Tab::Media: return std::make_unique<Media::Memento>( // case Tab::Media: return std::make_shared<Media::Memento>(
// _controller->peerId(), // _controller->peerId(),
// _controller->migratedPeerId(), // _controller->migratedPeerId(),
// Media::Type::Photo); // Media::Type::Photo);
@ -884,8 +884,8 @@ void WrapWidget::highlightTopBar() {
} }
} }
std::unique_ptr<Window::SectionMemento> WrapWidget::createMemento() { std::shared_ptr<Window::SectionMemento> WrapWidget::createMemento() {
auto stack = std::vector<std::unique_ptr<ContentMemento>>(); auto stack = std::vector<std::shared_ptr<ContentMemento>>();
stack.reserve(_historyStack.size() + 1); stack.reserve(_historyStack.size() + 1);
for (auto &stackItem : base::take(_historyStack)) { for (auto &stackItem : base::take(_historyStack)) {
stack.push_back(std::move(stackItem.section)); stack.push_back(std::move(stackItem.section));
@ -895,7 +895,7 @@ std::unique_ptr<Window::SectionMemento> WrapWidget::createMemento() {
// We're not in valid state anymore and supposed to be destroyed. // We're not in valid state anymore and supposed to be destroyed.
_controller = nullptr; _controller = nullptr;
return std::make_unique<Memento>(std::move(stack)); return std::make_shared<Memento>(std::move(stack));
} }
rpl::producer<int> WrapWidget::desiredHeightValue() const { rpl::producer<int> WrapWidget::desiredHeightValue() const {

View file

@ -101,7 +101,7 @@ public:
not_null<Window::SectionMemento*> memento, not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params) override; const Window::SectionShow &params) override;
bool showBackFromStackInternal(const Window::SectionShow &params); bool showBackFromStackInternal(const Window::SectionShow &params);
std::unique_ptr<Window::SectionMemento> createMemento() override; std::shared_ptr<Window::SectionMemento> createMemento() override;
rpl::producer<int> desiredHeightValue() const override; rpl::producer<int> desiredHeightValue() const override;
@ -146,10 +146,10 @@ private:
void injectActivePeerProfile(not_null<PeerData*> peer); void injectActivePeerProfile(not_null<PeerData*> peer);
//void injectActiveFeedProfile(not_null<Data::Feed*> feed); // #feed //void injectActiveFeedProfile(not_null<Data::Feed*> feed); // #feed
void injectActiveProfileMemento( void injectActiveProfileMemento(
std::unique_ptr<ContentMemento> memento); std::shared_ptr<ContentMemento> memento);
void checkBeforeClose(Fn<void()> close); void checkBeforeClose(Fn<void()> close);
void restoreHistoryStack( void restoreHistoryStack(
std::vector<std::unique_ptr<ContentMemento>> stack); std::vector<std::shared_ptr<ContentMemento>> stack);
bool hasStackHistory() const { bool hasStackHistory() const {
return !_historyStack.empty(); return !_historyStack.empty();
} }
@ -178,7 +178,7 @@ private:
//void showTab(Tab tab); //void showTab(Tab tab);
void showContent(object_ptr<ContentWidget> content); void showContent(object_ptr<ContentWidget> content);
//std::unique_ptr<ContentMemento> createTabMemento(Tab tab); //std::shared_ptr<ContentMemento> createTabMemento(Tab tab);
object_ptr<ContentWidget> createContent( object_ptr<ContentWidget> createContent(
not_null<ContentMemento*> memento, not_null<ContentMemento*> memento,
not_null<Controller*> controller); not_null<Controller*> controller);
@ -212,7 +212,7 @@ private:
base::unique_qptr<Ui::DropdownMenu> _topBarMenu; base::unique_qptr<Ui::DropdownMenu> _topBarMenu;
// Tab _tab = Tab::Profile; // Tab _tab = Tab::Profile;
// std::unique_ptr<ContentMemento> _anotherTabMemento; // std::shared_ptr<ContentMemento> _anotherTabMemento;
std::vector<StackItem> _historyStack; std::vector<StackItem> _historyStack;
rpl::event_stream<rpl::producer<int>> _desiredHeights; rpl::event_stream<rpl::producer<int>> _desiredHeights;

View file

@ -92,7 +92,7 @@ inline auto AddButton(
tracker)->entity(); tracker)->entity();
result->addClickHandler([=] { result->addClickHandler([=] {
navigation->showSection( navigation->showSection(
std::make_unique<Info::Memento>(peer, Section(type))); std::make_shared<Info::Memento>(peer, Section(type)));
}); });
return result; return result;
}; };
@ -111,7 +111,7 @@ inline auto AddCommonGroupsButton(
tracker)->entity(); tracker)->entity();
result->addClickHandler([=] { result->addClickHandler([=] {
navigation->showSection( navigation->showSection(
std::make_unique<Info::Memento>(user, Section::Type::CommonGroups)); std::make_shared<Info::Memento>(user, Section::Type::CommonGroups));
}); });
return result; return result;
}; };

View file

@ -115,8 +115,8 @@ void Widget::setInternalState(
restoreState(memento); restoreState(memento);
} }
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::shared_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(controller()); auto result = std::make_shared<Memento>(controller());
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -103,7 +103,7 @@ private:
void saveState(not_null<Memento*> memento); void saveState(not_null<Memento*> memento);
void restoreState(not_null<Memento*> memento); void restoreState(not_null<Memento*> memento);
std::unique_ptr<ContentMemento> doCreateMemento() override; std::shared_ptr<ContentMemento> doCreateMemento() override;
InnerWidget *_inner = nullptr; InnerWidget *_inner = nullptr;

View file

@ -79,8 +79,8 @@ void Widget::setInternalState(
restoreState(memento); restoreState(memento);
} }
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::shared_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(controller()); auto result = std::make_shared<Memento>(controller());
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -60,7 +60,7 @@ private:
void saveState(not_null<Memento*> memento); void saveState(not_null<Memento*> memento);
void restoreState(not_null<Memento*> memento); void restoreState(not_null<Memento*> memento);
std::unique_ptr<ContentMemento> doCreateMemento() override; std::shared_ptr<ContentMemento> doCreateMemento() override;
Profile::Members *_inner = nullptr; Profile::Members *_inner = nullptr;

View file

@ -90,8 +90,8 @@ void Widget::setInternalState(
restoreState(memento); restoreState(memento);
} }
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::shared_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(poll(), contextId()); auto result = std::make_shared<Memento>(poll(), contextId());
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -60,7 +60,7 @@ private:
void saveState(not_null<Memento*> memento); void saveState(not_null<Memento*> memento);
void restoreState(not_null<Memento*> memento); void restoreState(not_null<Memento*> memento);
std::unique_ptr<ContentMemento> doCreateMemento() override; std::shared_ptr<ContentMemento> doCreateMemento() override;
not_null<InnerWidget*> _inner; not_null<InnerWidget*> _inner;

View file

@ -843,7 +843,7 @@ object_ptr<Ui::RpWidget> SetupChannelMembers(
lt_count_decimal, lt_count_decimal,
MembersCountValue(channel) | tr::to_count()); MembersCountValue(channel) | tr::to_count());
auto membersCallback = [=] { auto membersCallback = [=] {
controller->showSection(std::make_unique<Info::Memento>( controller->showSection(std::make_shared<Info::Memento>(
channel, channel,
Section::Type::Members)); Section::Type::Members));
}; };

View file

@ -82,7 +82,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
_cover->showSection( _cover->showSection(
) | rpl::start_with_next([=](Section section) { ) | rpl::start_with_next([=](Section section) {
_controller->showSection( _controller->showSection(
std::make_unique<Info::Memento>(_peer, section)); std::make_shared<Info::Memento>(_peer, section));
}, _cover->lifetime()); }, _cover->lifetime());
_cover->setOnlineCount(rpl::single(0)); _cover->setOnlineCount(rpl::single(0));
auto details = SetupDetails(_controller, parent, _peer); auto details = SetupDetails(_controller, parent, _peer);

View file

@ -342,14 +342,14 @@ void Members::showMembersWithSearch(bool withSearch) {
//if (!_searchShown) { //if (!_searchShown) {
// toggleSearch(); // toggleSearch();
//} //}
auto contentMemento = std::make_unique<Info::Members::Memento>( auto contentMemento = std::make_shared<Info::Members::Memento>(
_controller); _controller);
contentMemento->setState(saveState()); contentMemento->setState(saveState());
contentMemento->setSearchStartsFocused(withSearch); contentMemento->setSearchStartsFocused(withSearch);
auto mementoStack = std::vector<std::unique_ptr<ContentMemento>>(); auto mementoStack = std::vector<std::shared_ptr<ContentMemento>>();
mementoStack.push_back(std::move(contentMemento)); mementoStack.push_back(std::move(contentMemento));
_controller->showSection( _controller->showSection(
std::make_unique<Info::Memento>(std::move(mementoStack))); std::make_shared<Info::Memento>(std::move(mementoStack)));
} }
//void Members::toggleSearch(anim::type animated) { //void Members::toggleSearch(anim::type animated) {

View file

@ -99,8 +99,8 @@ void Widget::setInternalState(
restoreState(memento); restoreState(memento);
} }
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::shared_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(controller()); auto result = std::make_shared<Memento>(controller());
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -66,7 +66,7 @@ private:
void saveState(not_null<Memento*> memento); void saveState(not_null<Memento*> memento);
void restoreState(not_null<Memento*> memento); void restoreState(not_null<Memento*> memento);
std::unique_ptr<ContentMemento> doCreateMemento() override; std::shared_ptr<ContentMemento> doCreateMemento() override;
InnerWidget *_inner = nullptr; InnerWidget *_inner = nullptr;

View file

@ -95,8 +95,8 @@ rpl::producer<bool> Widget::desiredShadowVisibility() const {
: rpl::single(true); : rpl::single(true);
} }
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::shared_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(self(), _type); auto result = std::make_shared<Memento>(self(), _type);
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -72,7 +72,7 @@ private:
void saveState(not_null<Memento*> memento); void saveState(not_null<Memento*> memento);
void restoreState(not_null<Memento*> memento); void restoreState(not_null<Memento*> memento);
std::unique_ptr<ContentMemento> doCreateMemento() override; std::shared_ptr<ContentMemento> doCreateMemento() override;
not_null<UserData*> _self; not_null<UserData*> _self;
Type _type = Type(); Type _type = Type();

View file

@ -140,8 +140,8 @@ public:
} }
void setThirdSectionMemento( void setThirdSectionMemento(
std::unique_ptr<Window::SectionMemento> &&memento); std::shared_ptr<Window::SectionMemento> memento);
std::unique_ptr<Window::SectionMemento> takeThirdSectionMemento() { std::shared_ptr<Window::SectionMemento> takeThirdSectionMemento() {
return std::move(_thirdSectionMemento); return std::move(_thirdSectionMemento);
} }
@ -158,7 +158,7 @@ public:
private: private:
PeerData *_peer = nullptr; PeerData *_peer = nullptr;
QPointer<Window::SectionWidget> _thirdSectionWeak; QPointer<Window::SectionWidget> _thirdSectionWeak;
std::unique_ptr<Window::SectionMemento> _thirdSectionMemento; std::shared_ptr<Window::SectionMemento> _thirdSectionMemento;
}; };
@ -187,27 +187,27 @@ public:
class StackItemSection : public StackItem { class StackItemSection : public StackItem {
public: public:
StackItemSection( StackItemSection(
std::unique_ptr<Window::SectionMemento> &&memento); std::shared_ptr<Window::SectionMemento> memento);
StackItemType type() const override { StackItemType type() const override {
return SectionStackItem; return SectionStackItem;
} }
std::unique_ptr<Window::SectionMemento> takeMemento() { std::shared_ptr<Window::SectionMemento> takeMemento() {
return std::move(_memento); return std::move(_memento);
} }
private: private:
std::unique_ptr<Window::SectionMemento> _memento; std::shared_ptr<Window::SectionMemento> _memento;
}; };
void StackItem::setThirdSectionMemento( void StackItem::setThirdSectionMemento(
std::unique_ptr<Window::SectionMemento> &&memento) { std::shared_ptr<Window::SectionMemento> memento) {
_thirdSectionMemento = std::move(memento); _thirdSectionMemento = std::move(memento);
} }
StackItemSection::StackItemSection( StackItemSection::StackItemSection(
std::unique_ptr<Window::SectionMemento> &&memento) std::shared_ptr<Window::SectionMemento> memento)
: StackItem(nullptr) : StackItem(nullptr)
, _memento(std::move(memento)) { , _memento(std::move(memento)) {
} }
@ -1607,7 +1607,7 @@ void MainWidget::saveSectionInStack() {
} }
void MainWidget::showSection( void MainWidget::showSection(
std::unique_ptr<Window::SectionMemento> &&memento, std::shared_ptr<Window::SectionMemento> memento,
const SectionShow &params) { const SectionShow &params) {
if (_mainSection && _mainSection->showInternal( if (_mainSection && _mainSection->showInternal(
memento.get(), memento.get(),
@ -1626,11 +1626,8 @@ void MainWidget::showSection(
// return; // return;
} }
using MementoPtr = std::unique_ptr<Window::SectionMemento>;
const auto sharedMemento = std::make_shared<MementoPtr>(
std::move(memento));
if (preventsCloseSection( if (preventsCloseSection(
[=] { showSection(base::take(*sharedMemento), params); }, [=] { showSection(memento, params); },
params)) { params)) {
return; return;
} }
@ -1640,9 +1637,7 @@ void MainWidget::showSection(
// we need to update adaptive layout to Adaptive::ThirdColumn(). // we need to update adaptive layout to Adaptive::ThirdColumn().
updateColumnLayout(); updateColumnLayout();
showNewSection( showNewSection(std::move(memento), params);
std::move(*sharedMemento),
params);
} }
void MainWidget::updateColumnLayout() { void MainWidget::updateColumnLayout() {
@ -1737,7 +1732,7 @@ Window::SectionSlideParams MainWidget::prepareDialogsAnimation() {
} }
void MainWidget::showNewSection( void MainWidget::showNewSection(
std::unique_ptr<Window::SectionMemento> &&memento, std::shared_ptr<Window::SectionMemento> memento,
const SectionShow &params) { const SectionShow &params) {
using Column = Window::Column; using Column = Window::Column;
@ -2451,15 +2446,15 @@ bool MainWidget::saveThirdSectionToStackBack() const {
auto MainWidget::thirdSectionForCurrentMainSection( auto MainWidget::thirdSectionForCurrentMainSection(
Dialogs::Key key) Dialogs::Key key)
-> std::unique_ptr<Window::SectionMemento> { -> std::shared_ptr<Window::SectionMemento> {
if (_thirdSectionFromStack) { if (_thirdSectionFromStack) {
return std::move(_thirdSectionFromStack); return std::move(_thirdSectionFromStack);
} else if (const auto peer = key.peer()) { } else if (const auto peer = key.peer()) {
return std::make_unique<Info::Memento>( return std::make_shared<Info::Memento>(
peer, peer,
Info::Memento::DefaultSection(peer)); Info::Memento::DefaultSection(peer));
//} else if (const auto feed = key.feed()) { // #feed //} else if (const auto feed = key.feed()) { // #feed
// return std::make_unique<Info::Memento>( // return std::make_shared<Info::Memento>(
// feed, // feed,
// Info::Memento::DefaultSection(key)); // Info::Memento::DefaultSection(key));
} }

View file

@ -134,7 +134,7 @@ public:
int backgroundFromY() const; int backgroundFromY() const;
void showSection( void showSection(
std::unique_ptr<Window::SectionMemento> &&memento, std::shared_ptr<Window::SectionMemento> memento,
const SectionShow &params); const SectionShow &params);
void updateColumnLayout(); void updateColumnLayout();
bool stackIsEmpty() const; bool stackIsEmpty() const;
@ -256,7 +256,7 @@ private:
bool canWrite); bool canWrite);
[[nodiscard]] bool saveThirdSectionToStackBack() const; [[nodiscard]] bool saveThirdSectionToStackBack() const;
[[nodiscard]] auto thirdSectionForCurrentMainSection(Dialogs::Key key) [[nodiscard]] auto thirdSectionForCurrentMainSection(Dialogs::Key key)
-> std::unique_ptr<Window::SectionMemento>; -> std::shared_ptr<Window::SectionMemento>;
void setupConnectingWidget(); void setupConnectingWidget();
void createPlayer(); void createPlayer();
@ -276,7 +276,7 @@ private:
Window::SectionSlideParams prepareShowAnimation( Window::SectionSlideParams prepareShowAnimation(
bool willHaveTopBarShadow); bool willHaveTopBarShadow);
void showNewSection( void showNewSection(
std::unique_ptr<Window::SectionMemento> &&memento, std::shared_ptr<Window::SectionMemento> memento,
const SectionShow &params); const SectionShow &params);
void dropMainSection(Window::SectionWidget *widget); void dropMainSection(Window::SectionWidget *widget);
@ -353,7 +353,7 @@ private:
object_ptr<HistoryWidget> _history; object_ptr<HistoryWidget> _history;
object_ptr<Window::SectionWidget> _mainSection = { nullptr }; object_ptr<Window::SectionWidget> _mainSection = { nullptr };
object_ptr<Window::SectionWidget> _thirdSection = { nullptr }; object_ptr<Window::SectionWidget> _thirdSection = { nullptr };
std::unique_ptr<Window::SectionMemento> _thirdSectionFromStack; std::shared_ptr<Window::SectionMemento> _thirdSectionFromStack;
std::unique_ptr<Window::ConnectionState> _connecting; std::unique_ptr<Window::ConnectionState> _connecting;
base::weak_ptr<Calls::Call> _currentCall; base::weak_ptr<Calls::Call> _currentCall;

View file

@ -650,7 +650,7 @@ void Manager::openNotificationMessage(
Ui::showPeerHistory(history, messageId); Ui::showPeerHistory(history, messageId);
//} else if (messageFeed) { // #feed //} else if (messageFeed) { // #feed
// App::wnd()->sessionController()->showSection( // App::wnd()->sessionController()->showSection(
// std::make_unique<HistoryFeed::Memento>(messageFeed)); // std::make_shared<HistoryFeed::Memento>(messageFeed));
} else { } else {
Ui::showPeerHistory(history, ShowAtUnreadMsgId); Ui::showPeerHistory(history, ShowAtUnreadMsgId);
} }

View file

@ -70,7 +70,7 @@ void SectionWidget::showAnimated(
show(); show();
} }
std::unique_ptr<SectionMemento> SectionWidget::createMemento() { std::shared_ptr<SectionMemento> SectionWidget::createMemento() {
return nullptr; return nullptr;
} }

View file

@ -135,7 +135,7 @@ public:
// Create a memento of that section to store it in the history stack. // Create a memento of that section to store it in the history stack.
// This method may modify the section ("take" heavy items). // This method may modify the section ("take" heavy items).
virtual std::unique_ptr<SectionMemento> createMemento(); virtual std::shared_ptr<SectionMemento> createMemento();
void setInnerFocus() { void setInnerFocus() {
doSetInnerFocus(); doSetInnerFocus();

View file

@ -714,7 +714,7 @@ void Filler::addTogglesForArchive() {
// const auto controller = _controller; // const auto controller = _controller;
// const auto feed = _feed; // const auto feed = _feed;
// _addAction(tr::lng_context_view_feed_info(tr::now), [=] { // _addAction(tr::lng_context_view_feed_info(tr::now), [=] {
// controller->showSection(std::make_unique<Info::Memento>( // controller->showSection(std::make_shared<Info::Memento>(
// feed, // feed,
// Info::Section(Info::Section::Type::Profile))); // Info::Section(Info::Section::Type::Profile)));
// }); // });

View file

@ -253,12 +253,12 @@ void SessionNavigation::showRepliesForMessage(
const auto channelId = history->channelId(); const auto channelId = history->channelId();
//const auto item = _session->data().message(channelId, rootId); //const auto item = _session->data().message(channelId, rootId);
//if (!commentId && (!item || !item->repliesAreComments())) { //if (!commentId && (!item || !item->repliesAreComments())) {
// showSection(std::make_unique<HistoryView::RepliesMemento>(history, rootId)); // showSection(std::make_shared<HistoryView::RepliesMemento>(history, rootId));
// return; // return;
//} else if (const auto id = item ? item->commentsItemId() : FullMsgId()) { //} else if (const auto id = item ? item->commentsItemId() : FullMsgId()) {
// if (const auto commentsItem = _session->data().message(id)) { // if (const auto commentsItem = _session->data().message(id)) {
// showSection( // showSection(
// std::make_unique<HistoryView::RepliesMemento>(commentsItem)); // std::make_shared<HistoryView::RepliesMemento>(commentsItem));
// return; // return;
// } // }
//} //}
@ -314,7 +314,7 @@ void SessionNavigation::showRepliesForMessage(
post->setRepliesOutboxReadTill(readTill->v); post->setRepliesOutboxReadTill(readTill->v);
} }
} }
showSection(std::make_unique<HistoryView::RepliesMemento>( showSection(std::make_shared<HistoryView::RepliesMemento>(
item, item,
commentId)); commentId));
} }
@ -342,7 +342,7 @@ void SessionNavigation::showPeerInfo(
// Core::App().settings().setThirdSectionInfoEnabled(true); // Core::App().settings().setThirdSectionInfoEnabled(true);
// Core::App().saveSettingsDelayed(); // Core::App().saveSettingsDelayed();
//} //}
showSection(std::make_unique<Info::Memento>(peer), params); showSection(std::make_shared<Info::Memento>(peer), params);
} }
void SessionNavigation::showPeerInfo( void SessionNavigation::showPeerInfo(
@ -375,7 +375,7 @@ void SessionNavigation::showSettings(
Settings::Type type, Settings::Type type,
const SectionShow &params) { const SectionShow &params) {
showSection( showSection(
std::make_unique<Info::Memento>( std::make_shared<Info::Memento>(
Info::Settings::Tag{ _session->user() }, Info::Settings::Tag{ _session->user() },
Info::Section(type)), Info::Section(type)),
params); params);
@ -389,7 +389,7 @@ void SessionNavigation::showPollResults(
not_null<PollData*> poll, not_null<PollData*> poll,
FullMsgId contextId, FullMsgId contextId,
const SectionShow &params) { const SectionShow &params) {
showSection(std::make_unique<Info::Memento>(poll, contextId), params); showSection(std::make_shared<Info::Memento>(poll, contextId), params);
} }
SessionController::SessionController( SessionController::SessionController(
@ -640,9 +640,9 @@ bool SessionController::jumpToChatListEntry(Dialogs::RowDescriptor row) {
return true; return true;
//} else if (const auto feed = row.key.feed()) { // #feed //} else if (const auto feed = row.key.feed()) { // #feed
// if (const auto item = session().data().message(row.fullId)) { // if (const auto item = session().data().message(row.fullId)) {
// showSection(std::make_unique<HistoryFeed::Memento>(feed, item->position())); // showSection(std::make_shared<HistoryFeed::Memento>(feed, item->position()));
// } else { // } else {
// showSection(std::make_unique<HistoryFeed::Memento>(feed)); // showSection(std::make_shared<HistoryFeed::Memento>(feed));
// } // }
} }
return false; return false;
@ -1087,7 +1087,7 @@ void SessionController::showPeerHistory(
} }
void SessionController::showSection( void SessionController::showSection(
std::unique_ptr<SectionMemento> &&memento, std::shared_ptr<SectionMemento> memento,
const SectionShow &params) { const SectionShow &params) {
if (!params.thirdColumn && widget()->showSectionInExistingLayer( if (!params.thirdColumn && widget()->showSectionInExistingLayer(
memento.get(), memento.get(),

View file

@ -132,7 +132,7 @@ public:
Main::Session &session() const; Main::Session &session() const;
virtual void showSection( virtual void showSection(
std::unique_ptr<SectionMemento> &&memento, std::shared_ptr<SectionMemento> memento,
const SectionShow &params = SectionShow()) = 0; const SectionShow &params = SectionShow()) = 0;
virtual void showBackFromStack( virtual void showBackFromStack(
const SectionShow &params = SectionShow()) = 0; const SectionShow &params = SectionShow()) = 0;
@ -301,7 +301,7 @@ public:
bool confirmedLeaveOther = false); bool confirmedLeaveOther = false);
void showSection( void showSection(
std::unique_ptr<SectionMemento> &&memento, std::shared_ptr<SectionMemento> memento,
const SectionShow &params = SectionShow()) override; const SectionShow &params = SectionShow()) override;
void showBackFromStack( void showBackFromStack(
const SectionShow &params = SectionShow()) override; const SectionShow &params = SectionShow()) override;

@ -1 +1 @@
Subproject commit f98f0221416746f0beaf5a51e95674a90442c3d5 Subproject commit b95d2b4b378092daf3acb493515ff41a8e21f003

@ -1 +1 @@
Subproject commit a02c8923dc6d00bcb4f4c2b1470cd48e2743903a Subproject commit e08a0de35dd2d0bbf26d88d127ac7b80efb94150

2
cmake

@ -1 +1 @@
Subproject commit 1c2be0df28feb0c4629a1f37ccf7d23da2ff17c1 Subproject commit ceb5808939cf770c33be996ab3a1d38a998bf16d