Fixed crash in bot keyboard replacement. 0.9.41 version.

After username resolve bots always opens conversation, not profile.
This commit is contained in:
John Preston 2016-04-12 01:34:29 +03:00
parent 9cbdc6e95e
commit af014b3c14
3 changed files with 15 additions and 1 deletions

View File

@ -2348,6 +2348,13 @@ QString BotKeyboard::tooltipText() const {
return QString();
}
void BotKeyboard::onParentScrolled() {
// Holding scrollarea can fire scrolled() event from a resize() call before
// the resizeEvent() is called, which prepares _impl for updateSelected() call.
// Calling updateSelecteD() without delay causes _impl->getState() before _impl->resize().
QMetaObject::invokeMethod(this, "updateSelected", Qt::QueuedConnection);
}
void BotKeyboard::updateSelected() {
PopupTooltip::Show(1000, this);
@ -2810,7 +2817,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
_kbScroll.setWidget(&_keyboard);
_kbScroll.hide();
connect(&_kbScroll, SIGNAL(scrolled()), &_keyboard, SLOT(updateSelected()));
connect(&_kbScroll, SIGNAL(scrolled()), &_keyboard, SLOT(onParentScrolled()));
updateScrollColors();

View File

@ -347,6 +347,10 @@ public:
public slots:
void onParentScrolled();
private slots:
void updateSelected();
private:

View File

@ -3734,6 +3734,9 @@ void MainWidget::usernameResolveDone(QPair<MsgId, QString> msgIdAndStartToken, c
if (peer->isUser() && peer->asUser()->botInfo && !peer->asUser()->botInfo->cantJoinGroups && !startToken.isEmpty()) {
peer->asUser()->botInfo->startGroupToken = startToken;
Ui::showLayer(new ContactsBox(peer->asUser()));
} else if (peer->isUser() && peer->asUser()->botInfo) {
// Always open bot chats, even from mention links.
Ui::showPeerHistoryAsync(peer->id, ShowAtUnreadMsgId);
} else {
showPeerProfile(peer);
}