Create a function which safely initializes GTK once

This is only available in test code, and it allows GUI component tests to run without having to worry about double-initializing GTK
This commit is contained in:
Savanni D'Gerinel 2024-01-30 08:46:10 -05:00
parent f8d66bbb69
commit 63107e72c0
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,10 @@
use std::sync::Once;
static INITIALIZED: Once = Once::new();
pub fn gtk_init() {
INITIALIZED.call_once(|| {
eprintln!("initializing GTK");
let _ = gtk::init();
});
}

View File

@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License along with Fit
mod app;
mod app_window;
mod components;
#[cfg(test)]
mod gtk_init;
mod types;
mod view_models;
mod views;