macos, fix input crash

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-06-05 12:54:49 +08:00
parent 3459ec722b
commit 10176d9b2c
4 changed files with 18 additions and 7 deletions

View File

@@ -321,7 +321,7 @@ pub fn uninstall_plugin(id: &str, called_by_ui: bool) {
}
}
if is_server() {
if super::is_server_running() {
super::plugins::unload_plugin(&id);
}
}

View File

@@ -42,8 +42,6 @@ static PLUGIN_SOURCE_LOCAL_DIR: &str = "plugins";
pub use config::{ManagerConfig, PeerConfig, SharedConfig};
use crate::common::is_server;
/// Common plugin return.
///
/// [Note]
@@ -96,8 +94,12 @@ impl PluginReturn {
}
}
fn is_server_running() -> bool {
crate::common::is_server() || crate::common::is_server_running()
}
pub fn init() {
if !is_server() {
if !is_server_running() {
std::thread::spawn(move || manager::start_ipc());
} else {
if let Err(e) = remove_uninstalled() {

View File

@@ -371,7 +371,7 @@ fn load_plugin_path(path: &str) -> ResultType<()> {
PLUGIN_INFO.write().unwrap().insert(id.clone(), plugin_info);
let init_info = serde_json::to_string(&InitInfo {
is_server: crate::common::is_server(),
is_server: super::is_server_running(),
})?;
let init_data = InitData {
version: str_to_cstr_ret(crate::VERSION),
@@ -389,7 +389,7 @@ fn load_plugin_path(path: &str) -> ResultType<()> {
log::error!("Failed to init plugin '{}', {}", desc.meta().id, e);
}
if is_server() {
if super::is_server_running() {
super::config::ManagerConfig::add_plugin(&desc.meta().id)?;
}