imagePage: Show specific error for out of memory
Part-of: <https://gitlab.gnome.org/GNOME/loupe/-/merge_requests/435>
This commit is contained in:
parent
9bd68cd8dd
commit
b33943fbe2
3 changed files with 16 additions and 5 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -915,7 +915,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "glycin"
|
||||
version = "2.0.0-alpha"
|
||||
source = "git+https://gitlab.gnome.org/sophie-h/glycin#d54af1730281c21982846d6729c22dc21265cb0d"
|
||||
source = "git+https://gitlab.gnome.org/sophie-h/glycin#dba036d37a7991215222b68f3527b4740f10953b"
|
||||
dependencies = [
|
||||
"async-fs",
|
||||
"async-io",
|
||||
|
|
@ -946,7 +946,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "glycin-utils"
|
||||
version = "2.0.0-alpha"
|
||||
source = "git+https://gitlab.gnome.org/sophie-h/glycin#d54af1730281c21982846d6729c22dc21265cb0d"
|
||||
source = "git+https://gitlab.gnome.org/sophie-h/glycin#dba036d37a7991215222b68f3527b4740f10953b"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"gufo-common",
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ pub enum DecoderError {
|
|||
UnsupportedFormat,
|
||||
/// No glycin-loaders installed
|
||||
NoLoadersConfigured,
|
||||
/// Memory limit exceeded
|
||||
OutOfMemory,
|
||||
#[default]
|
||||
None,
|
||||
}
|
||||
|
|
@ -118,6 +120,9 @@ impl UpdateSender {
|
|||
update_sender.send(DecoderUpdate::SpecificError(
|
||||
DecoderError::UnsupportedFormat,
|
||||
));
|
||||
}
|
||||
if err.is_out_of_memory() {
|
||||
update_sender.send(DecoderUpdate::SpecificError(DecoderError::OutOfMemory));
|
||||
} else if matches!(err.error(), glycin::Error::NoLoadersConfigured(_)) {
|
||||
update_sender.send(DecoderUpdate::SpecificError(
|
||||
DecoderError::NoLoadersConfigured,
|
||||
|
|
|
|||
|
|
@ -261,9 +261,15 @@ impl LpImagePage {
|
|||
}
|
||||
));
|
||||
|
||||
imp.error_page.set_description(Some(&gettext(
|
||||
"Either the image file is corrupted or it contains unsupported elements.",
|
||||
)));
|
||||
if image.specific_error() == DecoderError::OutOfMemory {
|
||||
imp.error_page.set_description(Some(&gettext(
|
||||
"There is not enough free memory available to load this image.",
|
||||
)));
|
||||
} else {
|
||||
imp.error_page.set_description(Some(&gettext(
|
||||
"Either the image file is corrupted or it contains unsupported elements.",
|
||||
)));
|
||||
}
|
||||
|
||||
imp.error_more_info.set_visible(true);
|
||||
imp.stack.set_visible_child(&*imp.error_page);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue