mirror of https://github.com/procxx/kepka.git
Fix possible crash with invalidated views.
This commit is contained in:
parent
321f5d879d
commit
61700577d0
|
@ -139,6 +139,10 @@ HistoryInner::HistoryInner(
|
||||||
) | rpl::start_with_next(
|
) | rpl::start_with_next(
|
||||||
[this](auto item) { itemRemoved(item); },
|
[this](auto item) { itemRemoved(item); },
|
||||||
lifetime());
|
lifetime());
|
||||||
|
Auth().data().itemViewRefreshRequest(
|
||||||
|
) | rpl::start_with_next([this](auto item) {
|
||||||
|
refreshView(item);
|
||||||
|
}, lifetime());
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
Auth().data().historyUnloaded(),
|
Auth().data().historyUnloaded(),
|
||||||
Auth().data().historyCleared()
|
Auth().data().historyCleared()
|
||||||
|
@ -1212,9 +1216,29 @@ void HistoryInner::itemRemoved(not_null<const HistoryItem*> item) {
|
||||||
_dragSelTo = nullptr;
|
_dragSelTo = nullptr;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
if (_scrollDateLastItem && _scrollDateLastItem->data() == item) {
|
||||||
|
_scrollDateLastItem = nullptr;
|
||||||
|
}
|
||||||
mouseActionUpdate();
|
mouseActionUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryInner::refreshView(not_null<HistoryItem*> item) {
|
||||||
|
const auto dragSelFrom = (_dragSelFrom && _dragSelFrom->data() == item);
|
||||||
|
const auto dragSelTo = (_dragSelTo && _dragSelTo->data() == item);
|
||||||
|
const auto scrollDateLastItem = (_scrollDateLastItem
|
||||||
|
&& _scrollDateLastItem->data() == item);
|
||||||
|
item->refreshMainView();
|
||||||
|
if (dragSelFrom) {
|
||||||
|
_dragSelFrom = item->mainView();
|
||||||
|
}
|
||||||
|
if (dragSelTo) {
|
||||||
|
_dragSelTo = item->mainView();
|
||||||
|
}
|
||||||
|
if (scrollDateLastItem) {
|
||||||
|
_scrollDateLastItem = item->mainView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryInner::mouseActionFinish(
|
void HistoryInner::mouseActionFinish(
|
||||||
const QPoint &screenPos,
|
const QPoint &screenPos,
|
||||||
Qt::MouseButton button) {
|
Qt::MouseButton button) {
|
||||||
|
|
|
@ -213,6 +213,7 @@ private:
|
||||||
void toggleFavedSticker(not_null<DocumentData*> document);
|
void toggleFavedSticker(not_null<DocumentData*> document);
|
||||||
|
|
||||||
void itemRemoved(not_null<const HistoryItem*> item);
|
void itemRemoved(not_null<const HistoryItem*> item);
|
||||||
|
void refreshView(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
void touchResetSpeed();
|
void touchResetSpeed();
|
||||||
void touchUpdateSpeed();
|
void touchUpdateSpeed();
|
||||||
|
|
|
@ -573,10 +573,6 @@ HistoryWidget::HistoryWidget(
|
||||||
updateHistoryGeometry();
|
updateHistoryGeometry();
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
Auth().data().itemViewRefreshRequest(
|
|
||||||
) | rpl::start_with_next([this](auto item) {
|
|
||||||
item->refreshMainView();
|
|
||||||
}, lifetime());
|
|
||||||
Auth().data().animationPlayInlineRequest(
|
Auth().data().animationPlayInlineRequest(
|
||||||
) | rpl::start_with_next([this](auto item) {
|
) | rpl::start_with_next([this](auto item) {
|
||||||
if (const auto view = item->mainView()) {
|
if (const auto view = item->mainView()) {
|
||||||
|
|
Loading…
Reference in New Issue