Fix crash in topic jump ripple animation.

Fixes #25500.
This commit is contained in:
John Preston 2022-12-29 17:48:33 +04:00
parent 1ef0791bc6
commit 567216f41f
6 changed files with 32 additions and 5 deletions

View file

@ -252,6 +252,10 @@ Row::Row(Key key, int index, int top) : _id(key), _top(top), _index(index) {
} }
} }
Row::~Row() {
clearTopicJumpRipple();
}
void Row::recountHeight(float64 narrowRatio) { void Row::recountHeight(float64 narrowRatio) {
if (const auto history = _id.history()) { if (const auto history = _id.history()) {
_height = history->isForum() _height = history->isForum()
@ -487,6 +491,11 @@ void Row::stopLastRipple() {
} }
} }
void Row::clearRipple() {
BasicRow::clearRipple();
clearTopicJumpRipple();
}
void Row::addTopicJumpRipple( void Row::addTopicJumpRipple(
QPoint origin, QPoint origin,
not_null<Ui::TopicJumpCache*> topicJumpCache, not_null<Ui::TopicJumpCache*> topicJumpCache,
@ -503,10 +512,15 @@ void Row::addTopicJumpRipple(
} }
void Row::clearTopicJumpRipple() { void Row::clearTopicJumpRipple() {
if (_topicJumpRipple) { if (!_topicJumpRipple) {
clearRipple(); return;
_topicJumpRipple = 0;
} }
const auto history = this->history();
const auto view = history ? &history->lastItemDialogsView() : nullptr;
if (view) {
view->clearRipple();
}
_topicJumpRipple = 0;
} }
bool Row::topicJumpRipple() const { bool Row::topicJumpRipple() const {

View file

@ -53,11 +53,11 @@ public:
void addRipple(QPoint origin, QSize size, Fn<void()> updateCallback); void addRipple(QPoint origin, QSize size, Fn<void()> updateCallback);
virtual void stopLastRipple(); virtual void stopLastRipple();
virtual void clearRipple();
void addRippleWithMask( void addRippleWithMask(
QPoint origin, QPoint origin,
QImage mask, QImage mask,
Fn<void()> updateCallback); Fn<void()> updateCallback);
void clearRipple();
void paintRipple( void paintRipple(
QPainter &p, QPainter &p,
@ -82,6 +82,7 @@ public:
explicit Row(std::nullptr_t) { explicit Row(std::nullptr_t) {
} }
Row(Key key, int index, int top); Row(Key key, int index, int top);
~Row();
[[nodiscard]] int top() const { [[nodiscard]] int top() const {
return _top; return _top;
@ -105,6 +106,7 @@ public:
[[nodiscard]] bool lookupIsInTopicJump(int x, int y) const; [[nodiscard]] bool lookupIsInTopicJump(int x, int y) const;
void stopLastRipple() override; void stopLastRipple() override;
void clearRipple() override;
void addTopicJumpRipple( void addTopicJumpRipple(
QPoint origin, QPoint origin,
not_null<Ui::TopicJumpCache*> topicJumpCache, not_null<Ui::TopicJumpCache*> topicJumpCache,

View file

@ -227,6 +227,12 @@ void MessageView::stopLastRipple() {
} }
} }
void MessageView::clearRipple() {
if (_topics) {
_topics->clearRipple();
}
}
int MessageView::countWidth() const { int MessageView::countWidth() const {
auto result = 0; auto result = 0;
if (!_senderCache.isEmpty()) { if (!_senderCache.isEmpty()) {

View file

@ -73,6 +73,7 @@ public:
not_null<TopicJumpCache*> topicJumpCache, not_null<TopicJumpCache*> topicJumpCache,
Fn<void()> updateCallback); Fn<void()> updateCallback);
void stopLastRipple(); void stopLastRipple();
void clearRipple();
private: private:
struct LoadingContext; struct LoadingContext;

View file

@ -187,6 +187,10 @@ void TopicsView::stopLastRipple() {
} }
} }
void TopicsView::clearRipple() {
_ripple = nullptr;
}
void TopicsView::paintRipple( void TopicsView::paintRipple(
QPainter &p, QPainter &p,
int x, int x,

View file

@ -89,8 +89,8 @@ public:
int y, int y,
int outerWidth, int outerWidth,
const QColor *colorOverride) const; const QColor *colorOverride) const;
void clearRipple();
void stopLastRipple(); void stopLastRipple();
void clearRipple();
[[nodiscard]] rpl::lifetime &lifetime() { [[nodiscard]] rpl::lifetime &lifetime() {
return _lifetime; return _lifetime;