1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

ImageViewer: Stop animation timer when deleting/changing image

Previously deleting an animated image wouldn't make the animation timer
stop. This resulted in the animation still running in the ViewWidget.

Moreover the timer wasn't stopped when loading different images, which
led to high CPU usage when going from an animated image to a
non-animated one.
This commit is contained in:
DragonAlex98 2021-05-16 16:43:11 +02:00 committed by Linus Groh
parent bce119036a
commit 47ec5cf340

View file

@ -31,6 +31,8 @@ ViewWidget::~ViewWidget()
void ViewWidget::clear()
{
m_timer->stop();
m_decoded_image.clear();
m_bitmap = nullptr;
if (on_image_change)
on_image_change(m_bitmap);
@ -265,6 +267,8 @@ void ViewWidget::load_from_file(const String& path)
m_timer->set_interval(first_frame.duration);
m_timer->on_timeout = [this] { animate(); };
m_timer->start();
} else {
m_timer->stop();
}
m_path = path;