Fix crash in quiz explanation with spoilers.

This commit is contained in:
John Preston 2022-10-04 09:14:42 +04:00
parent d15173e09d
commit f167cdad6f
5 changed files with 21 additions and 3 deletions

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_view_top_toast.h"
#include "ui/toast/toast.h"
#include "core/ui_integration.h"
#include "styles/style_chat.h"
namespace HistoryView {
@ -27,8 +28,15 @@ InfoTooltip::InfoTooltip() = default;
void InfoTooltip::show(
not_null<QWidget*> parent,
not_null<Main::Session*> session,
const TextWithEntities &text,
Fn<void()> hiddenCallback) {
const auto context = [=](not_null<QWidget*> toast) {
return Core::MarkedTextContext{
.session = session,
.customEmojiRepaint = [=] { toast->update(); },
};
};
hide(anim::type::normal);
_topToast = Ui::Toast::Show(parent, Ui::Toast::Config{
.text = text,
@ -37,6 +45,7 @@ void InfoTooltip::show(
.multiline = true,
.dark = true,
.slideSide = RectPart::Top,
.textContext = context,
});
if (const auto strong = _topToast.get()) {
if (hiddenCallback) {

View File

@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/weak_ptr.h"
namespace Main {
class Session;
} // namespace Main
namespace Ui::Toast {
class Instance;
} // namespace Ui::Toast
@ -21,6 +25,7 @@ public:
void show(
not_null<QWidget*> parent,
not_null<Main::Session*> session,
const TextWithEntities &text,
Fn<void()> hiddenCallback);
void hide(anim::type animated);

View File

@ -6765,7 +6765,11 @@ bool HistoryWidget::sendExistingPhoto(
void HistoryWidget::showInfoTooltip(
const TextWithEntities &text,
Fn<void()> hiddenCallback) {
_topToast.show(_scroll.data(), text, std::move(hiddenCallback));
_topToast.show(
_scroll.data(),
&session(),
text,
std::move(hiddenCallback));
}
void HistoryWidget::showPremiumStickerTooltip(

View File

@ -1456,7 +1456,7 @@ void ListWidget::elementShowTooltip(
const TextWithEntities &text,
Fn<void()> hiddenCallback) {
// Under the parent is supposed to be a scroll widget.
_topToast.show(parentWidget(), text, hiddenCallback);
_topToast.show(parentWidget(), &session(), text, hiddenCallback);
}
bool ListWidget::elementAnimationsPaused() {

@ -1 +1 @@
Subproject commit 89ae115a878feb9e07fe7423fcf123397eba5966
Subproject commit eafd7dc818433ec435c2862bb91b7e3c7f65336b