mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Version 2.4: Fix crash in typing animations.
This commit is contained in:
parent
4e366dc86e
commit
11e03a181d
3 changed files with 25 additions and 2 deletions
|
@ -880,7 +880,20 @@ HistoryView::SendActionPainter *Session::lookupSendActionPainter(
|
|||
return nullptr;
|
||||
}
|
||||
const auto j = i->second.find(rootId);
|
||||
return (j == end(i->second)) ? nullptr : j->second.lock().get();
|
||||
if (j == end(i->second)) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto result = j->second.lock();
|
||||
if (!result) {
|
||||
i->second.erase(j);
|
||||
if (i->second.empty()) {
|
||||
_sendActionPainters.erase(i);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
crl::on_main([copy = result] {
|
||||
});
|
||||
return result.get();
|
||||
}
|
||||
|
||||
void Session::registerSendAction(
|
||||
|
@ -959,7 +972,7 @@ bool Session::sendActionsAnimationCallback(crl::time now) {
|
|||
const auto sendAction = lookupSendActionPainter(
|
||||
i->first.first,
|
||||
i->first.second);
|
||||
if (sendAction->updateNeedsAnimating(now)) {
|
||||
if (sendAction && sendAction->updateNeedsAnimating(now)) {
|
||||
++i;
|
||||
} else {
|
||||
i = _sendActions.erase(i);
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
#include "main/main_session.h"
|
||||
#include "history/history.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/effects/animations.h"
|
||||
|
@ -35,6 +36,7 @@ constexpr auto kStatusShowClientsidePlayGame = 10000;
|
|||
|
||||
SendActionPainter::SendActionPainter(not_null<History*> history)
|
||||
: _history(history)
|
||||
, _weak(&_history->session())
|
||||
, _sendActionText(st::dialogsTextWidthMin) {
|
||||
}
|
||||
|
||||
|
@ -131,6 +133,9 @@ bool SendActionPainter::paint(
|
|||
}
|
||||
|
||||
bool SendActionPainter::updateNeedsAnimating(crl::time now, bool force) {
|
||||
if (!_weak) {
|
||||
return false;
|
||||
}
|
||||
auto changed = force;
|
||||
for (auto i = begin(_typing); i != end(_typing);) {
|
||||
if (now >= i->second) {
|
||||
|
|
|
@ -12,6 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
class UserData;
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Api {
|
||||
enum class SendProgressType;
|
||||
struct SendProgress;
|
||||
|
@ -42,6 +46,7 @@ public:
|
|||
|
||||
private:
|
||||
const not_null<History*> _history;
|
||||
const base::weak_ptr<Main::Session> _weak;
|
||||
base::flat_map<not_null<UserData*>, crl::time> _typing;
|
||||
base::flat_map<not_null<UserData*>, Api::SendProgress> _sendActions;
|
||||
QString _sendActionString;
|
||||
|
|
Loading…
Add table
Reference in a new issue