mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 14:19:48 +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:
parent
bce119036a
commit
47ec5cf340
Notes:
sideshowbarker
2024-07-18 18:02:12 +09:00
Author: https://github.com/DragonAlex98
Commit: 47ec5cf340
Pull-request: https://github.com/SerenityOS/serenity/pull/7168
Reviewed-by: https://github.com/linusg
1 changed files with 4 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue