2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Fix crash in HistoryWidget.

This commit is contained in:
John Preston
2017-12-09 22:20:10 +04:00
parent 677dbd5d6e
commit 6d62673e9e
2 changed files with 23 additions and 18 deletions

View File

@@ -92,6 +92,7 @@ constexpr auto kSkipRepaintWhileScrollMs = 100;
constexpr auto kShowMembersDropdownTimeoutMs = 300;
constexpr auto kDisplayEditTimeWarningMs = 300 * 1000;
constexpr auto kFullDayInMs = 86400 * 1000;
constexpr auto kCancelTypingActionTimeout = TimeMs(5000);
ApiWrap::RequestMessageDataCallback replyEditMessageDataCallback() {
return [](ChannelData *channel, MsgId msgId) {
@@ -448,6 +449,7 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
, _attachDragDocument(this)
, _attachDragPhoto(this)
, _fileLoader(this, FileLoaderQueueStopTimeout)
, _sendActionStopTimer([this] { cancelTypingAction(); })
, _topShadow(this) {
setAcceptDrops(true);
@@ -475,7 +477,6 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
connect(_tabbedSelector, SIGNAL(stickerSelected(DocumentData*)), this, SLOT(onStickerSend(DocumentData*)));
connect(_tabbedSelector, SIGNAL(photoSelected(PhotoData*)), this, SLOT(onPhotoSend(PhotoData*)));
connect(_tabbedSelector, SIGNAL(inlineResultSelected(InlineBots::Result*,UserData*)), this, SLOT(onInlineResultSend(InlineBots::Result*,UserData*)));
connect(&_sendActionStopTimer, SIGNAL(timeout()), this, SLOT(onCancelSendAction()));
connect(&_previewTimer, SIGNAL(timeout()), this, SLOT(onPreviewTimeout()));
connect(Media::Capture::instance(), SIGNAL(error()), this, SLOT(onRecordError()));
connect(Media::Capture::instance(), SIGNAL(updated(quint16,qint32)), this, SLOT(onRecordUpdate(quint16,qint32)));
@@ -490,8 +491,6 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
_scrollTimer.setSingleShot(false);
_sendActionStopTimer.setSingleShot(true);
_highlightTimer.setCallback([this] { updateHighlightedMessage(); });
_membersDropdownShowTimer.setSingleShot(true);
@@ -1191,8 +1190,11 @@ void HistoryWidget::cancelSendAction(
}
}
void HistoryWidget::onCancelSendAction() {
cancelSendAction(_history, SendAction::Type::Typing);
void HistoryWidget::cancelTypingAction() {
if (_history) {
cancelSendAction(_history, SendAction::Type::Typing);
}
_sendActionStopTimer.cancel();
}
void HistoryWidget::updateSendAction(
@@ -1231,7 +1233,9 @@ void HistoryWidget::updateSendAction(
action),
rpcDone(&HistoryWidget::sendActionDone));
_sendActionRequests.insert(key, requestId);
if (type == Type::Typing) _sendActionStopTimer.start(5000);
if (type == Type::Typing) {
_sendActionStopTimer.callOnce(kCancelTypingActionTimeout);
}
}
}
}
@@ -1627,6 +1631,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
return;
}
updateSendAction(_history, SendAction::Type::Typing, -1);
cancelTypingAction();
}
if (!cAutoPlayGif()) {