make arc pointer on construct

This commit is contained in:
yggverse 2024-09-25 22:52:16 +03:00
parent b4d1e4eadc
commit 597e472154
2 changed files with 6 additions and 4 deletions

View File

@ -10,6 +10,8 @@ use gtk::{
Align, Box, Orientation, Align, Box, Orientation,
}; };
use std::sync::Arc;
pub struct Label { pub struct Label {
// Components // Components
pin: Pin, pin: Pin,
@ -21,7 +23,7 @@ pub struct Label {
impl Label { impl Label {
// Construct // Construct
pub fn new(name: GString, is_pinned: bool) -> Label { pub fn new(name: GString, is_pinned: bool) -> Arc<Label> {
// Components // Components
let pin = Pin::new(is_pinned); let pin = Pin::new(is_pinned);
let title = Title::new(); let title = Title::new();
@ -37,7 +39,7 @@ impl Label {
widget.append(title.widget()); widget.append(title.widget());
// Result // Result
Self { pin, title, widget } Arc::new(Self { pin, title, widget })
} }
// Actions // Actions

View File

@ -57,8 +57,8 @@ impl Tab {
let id = uuid_string_random(); let id = uuid_string_random();
// Init new tab components // Init new tab components
let label = Arc::new(Label::new(id.clone(), false)); let label = Label::new(id.clone(), false);
let page = Arc::new(Page::new(id.clone())); let page = Page::new(id.clone());
// Register dynamically created tab components in the HashMap index // Register dynamically created tab components in the HashMap index
self.labels.borrow_mut().insert(id.clone(), label.clone()); self.labels.borrow_mut().insert(id.clone(), label.clone());