From e514312f842bd4b5912f500351449b5826563d9b Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 8 Oct 2024 06:20:46 +0300 Subject: [PATCH] use arc on construct --- src/app/browser/window/tab.rs | 4 ++-- src/app/browser/window/tab/item.rs | 14 +++++++------- src/app/browser/window/tab/item/page.rs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index a92d3be5..2412f0e8 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -91,7 +91,7 @@ impl Tab { is_initially_current: bool, ) -> Arc { // Init new tab item - let item = Arc::new(Item::new( + let item = Item::new( page_navigation_request_text.clone(), is_initially_current, // Actions @@ -100,7 +100,7 @@ impl Tab { self.action_tab_page_navigation_history_forward.clone(), self.action_tab_page_navigation_reload.clone(), self.action_update.clone(), - )); + ); // Register dynamically created tab components in the HashMap index self.index.borrow_mut().insert(item.id(), item.clone()); diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 5c535def..859777b4 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -38,14 +38,14 @@ impl Item { action_tab_page_navigation_history_forward: Arc, action_tab_page_navigation_reload: Arc, action_update: Arc, - ) -> Self { + ) -> Arc { // Generate unique ID for new page components let id = uuid_string_random(); // Init components let label = Label::new(id.clone(), false); - let page = Arc::new(Page::new( + let page = Page::new( id.clone(), page_navigation_request_text.clone(), action_tab_page_navigation_base.clone(), @@ -53,15 +53,15 @@ impl Item { action_tab_page_navigation_history_forward.clone(), action_tab_page_navigation_reload.clone(), action_update.clone(), - )); + ); // Return struct - Self { + Arc::new(Self { id, is_initially_current, label, page, - } + }) } // Actions @@ -142,7 +142,7 @@ impl Item { Ok(records) => { for record in records { // Construct new item object - let item = Arc::new(Item::new( + let item = Item::new( None, record.is_initially_current, // Actions @@ -151,7 +151,7 @@ impl Item { action_tab_page_navigation_history_forward.clone(), action_tab_page_navigation_reload.clone(), action_update.clone(), - )); + ); // Delegate restore action to the item childs item.label.restore(transaction, &record.id)?; diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index 419b8a16..ca3b8ec4 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -44,7 +44,7 @@ impl Page { action_tab_page_navigation_history_forward: Arc, action_tab_page_navigation_reload: Arc, action_update: Arc, - ) -> Page { + ) -> Arc { // Init actions let action_page_open = Arc::new(SimpleAction::new( "open", @@ -102,7 +102,7 @@ impl Page { }); // Return activated structure - Self { + Arc::new(Self { // GTK widget, // Actions @@ -114,7 +114,7 @@ impl Page { navigation, // Extras meta, - } + }) } // Actions