From a920c53d5641ce8f70ccb81dba04f7ba01c5b4ea Mon Sep 17 00:00:00 2001 From: Cyrix126 Date: Wed, 11 Dec 2024 21:56:53 +0100 Subject: [PATCH] fix: high cpu usage when moving mouse on Tab with service ready Check if the program is running outside of Gupaxx only if the user wants to start it. Do not check at all times. --- src/app/panels/bottom.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/panels/bottom.rs b/src/app/panels/bottom.rs index 826b19d..07d3bae 100644 --- a/src/app/panels/bottom.rs +++ b/src/app/panels/bottom.rs @@ -12,7 +12,7 @@ use crate::utils::constants::*; use crate::utils::errors::{ErrorButtons, ErrorFerris}; use crate::utils::regex::Regexes; use egui::*; -use log::debug; +use log::{debug, error}; use crate::app::Tab; use crate::helper::ProcessState::*; @@ -300,6 +300,16 @@ impl crate::app::App { .on_disabled_hover_text(text_err) .clicked() { + // check if process is running outside of Gupaxx, warn about it and do not start it. + if process_running(name) { + error!("Process already running outside: {}", name); + self.error_state.set( + PROCESS_OUTSIDE, + ErrorFerris::Error, + ErrorButtons::Okay, + ); + return; + } let _ = self.og.lock().unwrap().update_absolute_path(); let _ = self.state.update_absolute_path(); // start process @@ -550,13 +560,8 @@ impl crate::app::App { }); } pub fn start_ready(&self, state: &ProcessStateGui) -> Result<(), String> { - // check if process running outside - let name = state.name; - - if process_running(name) { - return Err(format!("Error: {}", PROCESS_OUTSIDE)); - } // custom check and var + let name = state.name; let path = match name { ProcessName::Node => { // check path of DB valid, empty valid.