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:
parent
400d3ddb08
commit
bce119036a
3 changed files with 29 additions and 2 deletions
|
@ -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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue