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) {
using Command = Shortcuts::Command;
if (_controller->content()->selectingPeer()) {
if (_controller->selectingPeer()) {
return;
}
const auto row = _controller->activeChatEntryCurrent();

View File

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

View File

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

View File

@ -168,6 +168,15 @@ public:
[[nodiscard]] not_null<::MainWindow*> widget() 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
-> not_null<ChatHelpers::TabbedSelector*>;
void takeTabbedSelectorOwnershipFrom(not_null<QWidget*> parent);
@ -331,6 +340,7 @@ private:
base::Variable<bool> _dialogsListDisplayForced = { false };
std::deque<Dialogs::RowDescriptor> _chatEntryHistory;
int _chatEntryHistoryPosition = -1;
bool _selectingPeer = false;
rpl::variable<FilterId> _activeChatsFilter;