Fixed infinite attempts to draw foreground in userpic builder.

This commit is contained in:
23rd 2024-09-30 17:57:23 +03:00 committed by John Preston
parent 1ee53ee0c1
commit e29c6d2f23

View file

@ -185,11 +185,14 @@ void EmojiUserpic::result(int size, Fn<void(UserpicBuilder::Result)> done) {
auto background = GenerateGradient(Size(size), _colors, false); auto background = GenerateGradient(Size(size), _colors, false);
{ {
constexpr auto kAttemptsToDrawFirstFrame = 3000;
auto attempts = 0;
auto p = QPainter(&background); auto p = QPainter(&background);
while (true) { while (attempts < kAttemptsToDrawFirstFrame) {
if (painter->paintForeground(p)) { if (painter->paintForeground(p)) {
break; break;
} }
attempts++;
} }
} }
if (*_playOnce && document) { if (*_playOnce && document) {