mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
fix: possible crash
This commit is contained in:
@@ -1395,14 +1395,15 @@ void AddRegistrationOrCreationButton(const not_null<Window::SessionController*>
|
|||||||
fitLabelToButton(registrationDateButton, idInfo.subtext, rightSkip);
|
fitLabelToButton(registrationDateButton, idInfo.subtext, rightSkip);
|
||||||
registrationDateButton->setClickedCallback([=, show = controller->uiShow()]
|
registrationDateButton->setClickedCallback([=, show = controller->uiShow()]
|
||||||
{
|
{
|
||||||
|
const auto weak = QPointer<Ui::IconButton>(registrationDateButton);
|
||||||
getRegistrationDate(
|
getRegistrationDate(
|
||||||
peer,
|
peer,
|
||||||
[=](const TextWithEntities &result)
|
[=](const TextWithEntities &result)
|
||||||
{
|
{
|
||||||
if (result.empty()) {
|
if (result.empty() || !weak) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto parent = registrationDateButton->window();
|
const auto parent = weak->window();
|
||||||
const auto tooltip = Ui::CreateChild<Ui::ImportantTooltip>(
|
const auto tooltip = Ui::CreateChild<Ui::ImportantTooltip>(
|
||||||
parent,
|
parent,
|
||||||
Ui::MakeNiceTooltipLabel(
|
Ui::MakeNiceTooltipLabel(
|
||||||
@@ -1415,8 +1416,8 @@ void AddRegistrationOrCreationButton(const not_null<Window::SessionController*>
|
|||||||
|
|
||||||
const auto geometry = Ui::MapFrom(
|
const auto geometry = Ui::MapFrom(
|
||||||
parent,
|
parent,
|
||||||
registrationDateButton,
|
weak.data(),
|
||||||
registrationDateButton->rect());
|
weak->rect());
|
||||||
const auto countPosition = [=](QSize size)
|
const auto countPosition = [=](QSize size)
|
||||||
{
|
{
|
||||||
const auto left = geometry.x()
|
const auto left = geometry.x()
|
||||||
@@ -1429,22 +1430,22 @@ void AddRegistrationOrCreationButton(const not_null<Window::SessionController*>
|
|||||||
};
|
};
|
||||||
tooltip->pointAt(geometry, RectPart::Top, countPosition);
|
tooltip->pointAt(geometry, RectPart::Top, countPosition);
|
||||||
|
|
||||||
const auto weak = QPointer(tooltip);
|
const auto weakTooltip = QPointer(tooltip);
|
||||||
tooltip->setHiddenCallback([weak]
|
tooltip->setHiddenCallback([weakTooltip]
|
||||||
{
|
{
|
||||||
if (weak) {
|
if (weakTooltip) {
|
||||||
weak->deleteLater();
|
weakTooltip->deleteLater();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
base::install_event_filter(
|
base::install_event_filter(
|
||||||
tooltip,
|
tooltip,
|
||||||
qApp,
|
qApp,
|
||||||
[weak](not_null<QEvent*> e)
|
[weakTooltip](not_null<QEvent*> e)
|
||||||
{
|
{
|
||||||
if (e->type() == QEvent::MouseButtonPress) {
|
if (e->type() == QEvent::MouseButtonPress) {
|
||||||
if (weak) {
|
if (weakTooltip) {
|
||||||
weak->toggleAnimated(false);
|
weakTooltip->toggleAnimated(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return base::EventFilterResult::Continue;
|
return base::EventFilterResult::Continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user