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

View File

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