Check value of "sidebar-page" key
Papers crashes when previously removed "bookmarks" sidebar is set as default in "sidebar-page" key. Checking whether the value of "sidebar-page" is among expected values avoids the crash. Related: RHEL-74354
This commit is contained in:
parent
12bea78bee
commit
6814f7e5f8
98
papers-47.0-check-sidebar-page.patch
Normal file
98
papers-47.0-check-sidebar-page.patch
Normal file
@ -0,0 +1,98 @@
|
||||
From 4de71d6b8276fb82c8ccbe1ed5ed8ca69bf2d612 Mon Sep 17 00:00:00 2001
|
||||
From: Marek Kasik <mkasik@redhat.com>
|
||||
Date: Tue, 28 Jan 2025 15:58:19 +0100
|
||||
Subject: [PATCH] shell: Check value of "sidebar-page" key
|
||||
|
||||
Papers crashes when previously removed "bookmarks" sidebar is set as default
|
||||
in "sidebar-page" key.
|
||||
Checking whether the value of "sidebar-page" is among expected values avoids
|
||||
the crash.
|
||||
---
|
||||
shell/src/sidebar.rs | 56 +++++++++++++++++++++++++++-----------------
|
||||
1 file changed, 34 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/shell/src/sidebar.rs b/shell/src/sidebar.rs
|
||||
index 476548835..394278a9a 100644
|
||||
--- a/shell/src/sidebar.rs
|
||||
+++ b/shell/src/sidebar.rs
|
||||
@@ -114,25 +114,46 @@ mod imp {
|
||||
self.stack.visible_child_name().map(|gs| gs.to_string())
|
||||
}
|
||||
|
||||
+ fn set_visible_child_default(&self) {
|
||||
+ let Some(document) = self.document() else {
|
||||
+ return;
|
||||
+ };
|
||||
+ if self
|
||||
+ .stack
|
||||
+ .child_by_name("links")
|
||||
+ .unwrap()
|
||||
+ .dynamic_cast_ref::<PpsSidebarPage>()
|
||||
+ .unwrap()
|
||||
+ .support_document(&document)
|
||||
+ {
|
||||
+ self.stack.set_visible_child_name("links");
|
||||
+ } else {
|
||||
+ self.stack.set_visible_child_name("thumbnails");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
fn set_visible_child_name(&self, name: Option<String>) {
|
||||
let Some(document) = self.document() else {
|
||||
return;
|
||||
};
|
||||
let Some(name) = name else {
|
||||
- if self
|
||||
- .stack
|
||||
- .child_by_name("links")
|
||||
- .unwrap()
|
||||
- .dynamic_cast_ref::<PpsSidebarPage>()
|
||||
- .unwrap()
|
||||
- .support_document(&document)
|
||||
- {
|
||||
- self.stack.set_visible_child_name("links");
|
||||
- } else {
|
||||
- self.stack.set_visible_child_name("thumbnails");
|
||||
- }
|
||||
+ self.set_visible_child_default();
|
||||
return;
|
||||
};
|
||||
+
|
||||
+ if ![
|
||||
+ "annotations",
|
||||
+ "attachments",
|
||||
+ "layers",
|
||||
+ "links",
|
||||
+ "thumbnails",
|
||||
+ ]
|
||||
+ .contains(&name.as_str())
|
||||
+ {
|
||||
+ self.set_visible_child_default();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
let page = self.stack.child_by_name(&name).unwrap();
|
||||
|
||||
if page
|
||||
@@ -141,17 +162,8 @@ mod imp {
|
||||
.support_document(&document)
|
||||
{
|
||||
self.stack.set_visible_child(&page);
|
||||
- } else if self
|
||||
- .stack
|
||||
- .child_by_name("links")
|
||||
- .unwrap()
|
||||
- .dynamic_cast_ref::<PpsSidebarPage>()
|
||||
- .unwrap()
|
||||
- .support_document(&document)
|
||||
- {
|
||||
- self.stack.set_visible_child_name("links");
|
||||
} else {
|
||||
- self.stack.set_visible_child_name("thumbnails");
|
||||
+ self.set_visible_child_default();
|
||||
}
|
||||
}
|
||||
}
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@ -42,6 +42,9 @@ Source1: papers-%{commit}-vendor.tar.xz
|
||||
# Patch to make Papers build with snapshot
|
||||
Patch: papers-47.0-snapshot-5de8d26c.patch
|
||||
|
||||
# Patch to avoid crash when sidebar-page has unexpected value
|
||||
Patch: papers-47.0-check-sidebar-page.patch
|
||||
|
||||
# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
|
||||
ExcludeArch: %{ix86}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user