pluginlist: avoid mulitple init

Allow only one initialization of the plugin
list.
This commit is contained in:
Stéphane Cerveau 2021-12-17 12:50:28 +01:00
parent ee6b57dfae
commit 41b5beee26
2 changed files with 53 additions and 45 deletions

View file

@ -24,6 +24,7 @@ use gtk::{
AboutDialog, Application, ApplicationWindow, Builder, Button, FileChooserAction,
FileChooserDialog, PopoverMenu, ResponseType, Statusbar, Viewport,
};
use once_cell::unsync::OnceCell;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::{Rc, Weak};
@ -40,6 +41,7 @@ pub struct GPSAppInner {
pub graphview: RefCell<GraphView>,
pub builder: Builder,
pub pipeline: RefCell<Pipeline>,
pub plugin_list_initialized: OnceCell<bool>,
}
// This represents our main application window.
@ -82,6 +84,7 @@ impl GPSApp {
graphview: RefCell::new(GraphView::new()),
builder,
pipeline: RefCell::new(pipeline),
plugin_list_initialized: OnceCell::new(),
}));
Ok(app)
}

View file

@ -62,6 +62,7 @@ pub fn display_plugin_list(app: &GPSApp, elements: &[ElementInfo]) {
.object("dialog-plugin-list")
.expect("Couldn't get window");
if app.plugin_list_initialized.get().is_none() {
dialog.set_title(Some("Plugin list"));
dialog.set_default_size(640, 480);
@ -118,6 +119,10 @@ pub fn display_plugin_list(app: &GPSApp, elements: &[ElementInfo]) {
}
}),
);
app.plugin_list_initialized
.set(true)
.expect("Should never happen");
}
dialog.show();
}