aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Gif.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Gif.cpp b/src/Gif.cpp
index 5b83158..f87b0ab 100644
--- a/src/Gif.cpp
+++ b/src/Gif.cpp
@@ -134,7 +134,12 @@ namespace dchat
void Gif::draw(sf::RenderTarget &target)
{
- double frameDeltaCs = (double)frameTimer.getElapsedTime().asMilliseconds() * 0.1; // Centisecond
+ double timeElapsedMilli = (double)frameTimer.getElapsedTime().asMilliseconds();
+ // If gif is not redrawn for a while, then we want to reset it; otherwise the decoding loop will take too long time.
+ // This means that if gif is not visible for a while and then it becomes visible, the gif will reset instead of trying to process several seconds of frames
+ if(timeElapsedMilli > 3000)
+ timeElapsedMilli = 0;
+ double frameDeltaCs = timeElapsedMilli * 0.1; // Centisecond
frameTimer.restart();
timeElapsedCs += frameDeltaCs;