Fix crash in MainWidget setup with audio player.

This commit is contained in:
John Preston 2020-06-30 19:05:12 +04:00
parent 3c028590b1
commit 7d0eb3ba8e
4 changed files with 22 additions and 7 deletions

View file

@ -3016,7 +3016,7 @@ void InnerWidget::setupShortcuts() {
}) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) { }) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
using Command = Shortcuts::Command; using Command = Shortcuts::Command;
if (_controller->content()->selectingPeer()) { if (_controller->selectingPeer()) {
return; return;
} }
const auto row = _controller->activeChatEntryCurrent(); const auto row = _controller->activeChatEntryCurrent();

View file

@ -212,7 +212,7 @@ Widget::Widget(
}); });
_inner->chosenRow( _inner->chosenRow(
) | rpl::start_with_next([=](const ChosenRow &row) { ) | rpl::start_with_next([=](const ChosenRow &row) {
const auto openSearchResult = !controller->content()->selectingPeer() const auto openSearchResult = !controller->selectingPeer()
&& row.filteredRow; && row.filteredRow;
if (const auto history = row.key.history()) { if (const auto history = row.key.history()) {
controller->content()->choosePeer( controller->content()->choosePeer(
@ -701,7 +701,7 @@ void Widget::escape() {
} else if (controller()->activeChatsFilterCurrent()) { } else if (controller()->activeChatsFilterCurrent()) {
controller()->setActiveChatsFilter(FilterId(0)); controller()->setActiveChatsFilter(FilterId(0));
} }
} else if (!_searchInChat && !controller()->content()->selectingPeer()) { } else if (!_searchInChat && !controller()->selectingPeer()) {
if (controller()->activeChatEntryCurrent().key) { if (controller()->activeChatEntryCurrent().key) {
emit cancelled(); emit cancelled();
} }
@ -1260,7 +1260,7 @@ void Widget::peopleFailed(const RPCError &error, mtpRequestId requestId) {
void Widget::dragEnterEvent(QDragEnterEvent *e) { void Widget::dragEnterEvent(QDragEnterEvent *e) {
using namespace Storage; using namespace Storage;
if (controller()->content()->selectingPeer()) { if (controller()->selectingPeer()) {
return; return;
} }
@ -1609,7 +1609,7 @@ void Widget::updateControlsGeometry() {
} }
void Widget::updateForwardBar() { void Widget::updateForwardBar() {
auto selecting = controller()->content()->selectingPeer(); auto selecting = controller()->selectingPeer();
auto oneColumnSelecting = (Adaptive::OneColumn() && selecting); auto oneColumnSelecting = (Adaptive::OneColumn() && selecting);
if (!oneColumnSelecting == !_forwardCancel) { if (!oneColumnSelecting == !_forwardCancel) {
return; return;
@ -1752,7 +1752,7 @@ bool Widget::onCancelSearch() {
void Widget::onCancelSearchInChat() { void Widget::onCancelSearchInChat() {
cancelSearchRequest(); cancelSearchRequest();
if (_searchInChat) { if (_searchInChat) {
if (Adaptive::OneColumn() && !controller()->content()->selectingPeer()) { if (Adaptive::OneColumn() && !controller()->selectingPeer()) {
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
@ -1767,7 +1767,7 @@ void Widget::onCancelSearchInChat() {
_filter->clear(); _filter->clear();
_filter->updatePlaceholder(); _filter->updatePlaceholder();
applyFilterUpdate(); applyFilterUpdate();
if (!Adaptive::OneColumn() && !controller()->content()->selectingPeer()) { if (!Adaptive::OneColumn() && !controller()->selectingPeer()) {
emit cancelled(); emit cancelled();
} }
} }

View file

@ -612,6 +612,8 @@ void MainWidget::clearHider(not_null<Window::HistoryHider*> instance) {
return; return;
} }
_hider.release(); _hider.release();
controller()->setSelectingPeer(false);
if (Adaptive::OneColumn()) { if (Adaptive::OneColumn()) {
if (_mainSection || (_history->peer() && _history->peer()->id)) { if (_mainSection || (_history->peer() && _history->peer()->id)) {
auto animationParams = ([=] { auto animationParams = ([=] {
@ -637,6 +639,8 @@ void MainWidget::hiderLayer(base::unique_qptr<Window::HistoryHider> hider) {
} }
_hider = std::move(hider); _hider = std::move(hider);
controller()->setSelectingPeer(true);
_hider->setParent(this); _hider->setParent(this);
_hider->hidden( _hider->hidden(
@ -1407,6 +1411,7 @@ void MainWidget::ui_showPeerHistory(
if (_hider) { if (_hider) {
_hider->startHide(); _hider->startHide();
_hider.release(); _hider.release();
controller()->setSelectingPeer(false);
} }
auto animatedShow = [&] { auto animatedShow = [&] {

View file

@ -168,6 +168,15 @@ public:
[[nodiscard]] not_null<::MainWindow*> widget() const; [[nodiscard]] not_null<::MainWindow*> widget() const;
[[nodiscard]] not_null<MainWidget*> content() const; [[nodiscard]] not_null<MainWidget*> content() const;
// We need access to this from MainWidget::MainWidget, where
// we can't call content() yet.
void setSelectingPeer(bool selecting) {
_selectingPeer = selecting;
}
[[nodiscard]] bool selectingPeer() const {
return _selectingPeer;
}
[[nodiscard]] auto tabbedSelector() const [[nodiscard]] auto tabbedSelector() const
-> not_null<ChatHelpers::TabbedSelector*>; -> not_null<ChatHelpers::TabbedSelector*>;
void takeTabbedSelectorOwnershipFrom(not_null<QWidget*> parent); void takeTabbedSelectorOwnershipFrom(not_null<QWidget*> parent);
@ -331,6 +340,7 @@ private:
base::Variable<bool> _dialogsListDisplayForced = { false }; base::Variable<bool> _dialogsListDisplayForced = { false };
std::deque<Dialogs::RowDescriptor> _chatEntryHistory; std::deque<Dialogs::RowDescriptor> _chatEntryHistory;
int _chatEntryHistoryPosition = -1; int _chatEntryHistoryPosition = -1;
bool _selectingPeer = false;
rpl::variable<FilterId> _activeChatsFilter; rpl::variable<FilterId> _activeChatsFilter;