1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:07:34 +00:00

ImageViewer: Disable image actions when there is no image

Previously some actions like Rotate/Flip/Set as Desktop Wallpaper would
make the application crash if no image was loaded. Now image actions are
enabled/disabled based on whether an image has been loaded or not.
This commit is contained in:
DragonAlex98 2021-05-16 10:01:29 +02:00 committed by Linus Groh
parent 400d3ddb08
commit bce119036a
3 changed files with 29 additions and 2 deletions

View file

@ -32,6 +32,8 @@ ViewWidget::~ViewWidget()
void ViewWidget::clear()
{
m_bitmap = nullptr;
if (on_image_change)
on_image_change(m_bitmap);
m_path = {};
reset_view();
@ -255,6 +257,8 @@ void ViewWidget::load_from_file(const String& path)
m_decoded_image = decoded_image_or_error.release_value();
m_bitmap = m_decoded_image->frames[0].bitmap;
if (on_image_change)
on_image_change(m_bitmap);
if (m_decoded_image->is_animated && m_decoded_image->frames.size() > 1) {
const auto& first_frame = m_decoded_image->frames[0];