From 9ced914ce1348ceefa5f5d13041452cdac886d13 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 2 Feb 2024 14:50:09 +0600 Subject: [PATCH] Update crash fix --- source/ubl-settings-services.c | 45 ++++++++++++++++++++-------------- source/ubl-settings-services.h | 1 + 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/source/ubl-settings-services.c b/source/ubl-settings-services.c index 5946271..bb111a0 100644 --- a/source/ubl-settings-services.c +++ b/source/ubl-settings-services.c @@ -12,23 +12,25 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ } void on_config_local_load(GtkWidget *self,main_window *widgets){ - if (self){}; - yon_load_proceed(YON_CONFIG_LOCAL); - yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - g_thread_new("",(GThreadFunc)yon_interface_update,widgets); - main_config.load_mode=1; - textdomain(template_ui_LocaleName); - textdomain(LocaleName); + if (!main_config.update_thread_active){ + main_config.update_thread_active=1; + if (self){}; + yon_load_proceed(YON_CONFIG_LOCAL); + yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + g_thread_new("",(GThreadFunc)yon_interface_update,widgets); + main_config.load_mode=1; + } } void on_config_global_load(GtkWidget *self,main_window *widgets){ - if (self){}; - yon_load_proceed(YON_CONFIG_GLOBAL); - yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - g_thread_new("",(GThreadFunc)yon_interface_update,widgets); - main_config.load_mode=0; - textdomain(template_ui_LocaleName); - textdomain(LocaleName); + if (!main_config.update_thread_active){ + main_config.update_thread_active=1; + if (self){}; + yon_load_proceed(YON_CONFIG_GLOBAL); + yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + g_thread_new("",(GThreadFunc)yon_interface_update,widgets); + main_config.load_mode=0; + } } @@ -375,9 +377,11 @@ void *yon_unthreaded_config_load(void *widgets){ } void on_update(GtkWidget *self,main_window *widgets){ - if (self){} - yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - g_thread_new("",(GThreadFunc)yon_unthreaded_config_load,widgets); + if (!main_config.update_thread_active){ + if (self){} + yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + if (yon_unthreaded_config_load(widgets)){}; + } } void *yon_interface_update(main_window *widgets){ @@ -459,6 +463,7 @@ void *yon_interface_update(main_window *widgets){ } textdomain(LocaleName); gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->MainTree),GTK_TREE_MODEL(widgets->liststore2)); + main_config.update_thread_active=0; return NULL; } @@ -572,6 +577,7 @@ void config_init(){ main_config.lock_save_global=0; main_config.lock_save_local=0; main_config.load_mode=1; + main_config.update_thread_active=0; } void on_activate(GtkTreeView *self, main_window *widgets){ @@ -662,7 +668,10 @@ void yon_main_window_complete(main_window *widgets){ gtk_tree_view_set_search_entry(GTK_TREE_VIEW(widgets->MainTree),GTK_ENTRY(widgets->SearchEntry)); yon_load_proceed(YON_CONFIG_LOCAL); yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - g_thread_new("",(GThreadFunc)yon_interface_update,widgets); + if (!main_config.update_thread_active){ + main_config.update_thread_active=1; + g_thread_new("",(GThreadFunc)yon_interface_update,widgets); + } } int main(int argc, char *argv[]){ diff --git a/source/ubl-settings-services.h b/source/ubl-settings-services.h index aca45c8..4df1a05 100644 --- a/source/ubl-settings-services.h +++ b/source/ubl-settings-services.h @@ -67,6 +67,7 @@ typedef struct { GtkTreeModel *AutolaunchFilter; GtkTreeModel *StoppedFilter; GtkTreeModel *BlockedFilter; + int update_thread_active; } config;