From ea3aab4d68ee9c510eed8ffb578a581687a7a9ea Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 11 Dec 2024 17:26:33 +0200 Subject: [PATCH] use shared reference for tab item id --- src/app/browser/window/tab.rs | 5 +++-- src/app/browser/window/tab/item.rs | 4 ++-- src/app/browser/window/tab/item/page.rs | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index 4affeb17..f62ff85b 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -25,7 +25,7 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc}; pub struct Tab { profile: Rc, actions: (Rc, Rc), - index: Rc>>>, + index: Rc, Rc>>>, pub widget: Rc, } @@ -33,7 +33,8 @@ impl Tab { // Construct pub fn new(profile: Rc, action: (Rc, Rc)) -> Self { // Init empty HashMap index - let index: Rc>>> = Rc::new(RefCell::new(HashMap::new())); + let index: Rc, Rc>>> = + Rc::new(RefCell::new(HashMap::new())); // Init context menu let menu = Menu::new(action.1.clone()); diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 701a495f..40a8be7c 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -24,7 +24,7 @@ use std::rc::Rc; pub struct Item { // Auto-generated unique item ID // useful as widget name in GTK actions callback - pub id: GString, + pub id: Rc, // Components pub page: Rc, pub widget: Rc, @@ -42,7 +42,7 @@ impl Item { let (position, request, is_pinned, is_selected, is_attention, is_load) = options; // Generate unique ID for new page components - let id = uuid_string_random(); + let id = Rc::new(uuid_string_random()); // Init components diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index 3d4e8939..eeb1ccfb 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -36,7 +36,7 @@ use sqlite::Transaction; use std::{rc::Rc, time::Duration}; pub struct Page { - id: GString, + id: Rc, profile: Rc, // Actions browser_action: Rc, @@ -54,7 +54,7 @@ impl Page { // Constructors pub fn new( - id: GString, + id: Rc, profile: Rc, action: (Rc, Rc, Rc), ) -> Self {