From a949c5e28715a16ec0dcaf0c36743740406e0549 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 26 Sep 2018 16:06:30 +0300 Subject: [PATCH] Fix crash in theme applying. --- Telegram/SourceFiles/window/themes/window_theme.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/window/themes/window_theme.cpp b/Telegram/SourceFiles/window/themes/window_theme.cpp index accddc511..c991e6aa8 100644 --- a/Telegram/SourceFiles/window/themes/window_theme.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme.cpp @@ -909,7 +909,11 @@ void KeepApplied() { if (!AreTestingTheme()) { return; } else if (instance->applying.overrideKeep) { - instance->applying.overrideKeep(); + // This callback will be destroyed while running. + // And it won't be able to safely access captures after that. + // So we save it on stack for the time while it is running. + const auto saved = base::take(instance->applying.overrideKeep); + saved(); return; } const auto path = instance->applying.pathAbsolute;