From e41216ab75115b509180cfedadf1ff21cbee1f20 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 15 Oct 2024 08:18:16 +0300 Subject: [PATCH] use shared pointer for page id string --- src/app/browser/window/tab.rs | 2 +- src/app/browser/window/tab/item.rs | 6 +++--- src/app/browser/window/tab/item/page.rs | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index d54271ed..f55e29e1 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -26,7 +26,7 @@ pub struct Tab { action_tab_page_navigation_reload: Arc, action_update: Arc, // Dynamically allocated reference index - index: Arc>>>, + index: Arc, Arc>>>, // GTK widget: Arc, } diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 3d4ebe8a..c31e7e25 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -17,7 +17,7 @@ use std::sync::Arc; pub struct Item { // Auto-generated unique item ID // useful as widget name in GTK actions callback - id: GString, + id: Arc, // Components page: Arc, widget: Arc, @@ -39,7 +39,7 @@ impl Item { is_selected: bool, ) -> Arc { // Generate unique ID for new page components - let id = uuid_string_random(); + let id = Arc::new(uuid_string_random()); // Init components let page = Page::new_arc( @@ -201,7 +201,7 @@ impl Item { } // Getters - pub fn id(&self) -> GString { + pub fn id(&self) -> Arc { self.id.clone() } diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index 75ce64b2..be8fb4e7 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -27,6 +27,7 @@ use sqlite::Transaction; use std::{cell::RefCell, path::Path, sync::Arc}; pub struct Page { + id: Arc, // Actions action_page_open: Arc, action_tab_page_navigation_reload: Arc, @@ -43,7 +44,7 @@ pub struct Page { impl Page { // Construct pub fn new_arc( - id: GString, + id: Arc, action_tab_open: Arc, action_tab_page_navigation_base: Arc, action_tab_page_navigation_history_back: Arc, @@ -102,6 +103,7 @@ impl Page { // Return activated structure Arc::new(Self { + id, // Actions action_page_open, action_tab_page_navigation_reload,