diff options
author | DragonAlex98 <alessandro.antinori@studenti.unicam.it> | 2021-05-16 16:43:11 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-16 16:22:21 +0100 |
commit | 47ec5cf3400768c66ec4ef2fcc1350e898450e53 (patch) | |
tree | dd4ef12a327309e0ad24359d48bd59f4d8949ea4 /Userland/Applications/ImageViewer/ViewWidget.cpp | |
parent | bce119036a51b6fedc8aa50e47c13535c8a7ba73 (diff) | |
download | serenity-47ec5cf3400768c66ec4ef2fcc1350e898450e53.zip |
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.
Diffstat (limited to 'Userland/Applications/ImageViewer/ViewWidget.cpp')
-rw-r--r-- | Userland/Applications/ImageViewer/ViewWidget.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index 9ffbc3fe8c..59e6da99db 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -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; |