From 275a0da980936b5e8e18e74d64cebfd83f617164 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 30 Aug 2024 10:14:46 +0600 Subject: [PATCH 01/15] Fixes --- source/ubinstall-gtk.c | 69 +++++++++++++++++++++++++++++++----------- source/ubinstall-gtk.h | 2 ++ 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 1a4451c..b9eeaeb 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -329,31 +329,39 @@ void yon_interface_update(main_window *widgets){ char *system_locale = config(locale_parameter); if (!yon_char_is_empty(system_locale)){ char *chosen_langs = ""; - for_iter(widgets->LanguagesList,&iter){ - char *cur=NULL, *render = NULL; - gtk_tree_model_get(GTK_TREE_MODEL(widgets->LanguagesList),&iter,1,&render,2,&cur,-1); - if (strstr(system_locale,cur)){ - gtk_list_store_set((widgets->LanguagesList),&iter,0,1,-1); - chosen_langs = yon_char_unite(chosen_langs,!yon_char_is_empty(chosen_langs)?";":"",render,NULL); + for_iter(widgets->LanguagesList,&iter){ + char *cur=NULL, *render = NULL; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->LanguagesList),&iter,1,&render,2,&cur,-1); + if (strstr(system_locale,cur)){ + gtk_list_store_set((widgets->LanguagesList),&iter,0,1,-1); + chosen_langs = yon_char_unite(chosen_langs,!yon_char_is_empty(chosen_langs)?";":"",render,NULL); + } else { + gtk_list_store_set((widgets->LanguagesList),&iter,0,0,-1); + } + } + if (!yon_char_is_empty(chosen_langs)){ + gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),chosen_langs); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),1); + free(chosen_langs); } else { - gtk_list_store_set((widgets->LanguagesList),&iter,0,0,-1); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); + gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),""); } - } - if (!yon_char_is_empty(chosen_langs)){ - gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),chosen_langs); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),1); - free(chosen_langs); - } else { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); - gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),""); - } // gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter)); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),""); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); + int langsize; + config_str lang = default_langs(&langsize); for_iter(widgets->LanguagesList,&iter){ - gtk_list_store_set((widgets->LanguagesList),&iter,0,0,-1); + char *cur; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->LanguagesList),&iter,2,&cur,-1); + if (lang&&yon_char_parsed_check_exist(lang,langsize,cur)>-1){ + gtk_list_store_set(widgets->LanguagesList,&iter,0,1,-1); + } else { + gtk_list_store_set(widgets->LanguagesList,&iter,0,0,-1); + } } // gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter)); } @@ -748,7 +756,7 @@ void on_language_window_accept(GtkWidget *,dictionary *dict){ gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),""); GtkTreeIter iter; int size; - config_str lang_parsed = yon_char_parsed_new(&size,"en_US.UTF-8","ru_RU.UTF-8",NULL); + config_str lang_parsed = default_langs(&size); char *final = ""; for_iter(widgets->LanguagesList,&iter){ @@ -828,6 +836,26 @@ void on_language_clicked(GtkWidget *, main_window *widgets){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DefaultCheck),1); } + int size; + int found=0; + int statusfound=0; + config_str langs = default_langs(&size); + GtkTreeIter iter; + for_iter(widgets->LanguagesList,&iter){ + char *cur; + int status; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->LanguagesList),&iter,0,&status,2,&cur,-1); + if (status){ + statusfound++; + if (yon_char_parsed_check_exist(langs,size,cur)>-1) + found++; + } + } + if ((found==size)&&statusfound==size){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DefaultCheck),1); + } + printf("%d == %d == %d\n",found,size,statusfound); + dictionary *dict=NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); @@ -2467,6 +2495,9 @@ main_window *yon_main_window_complete(){ gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->KeyboardImage),gdk_pixbuf_scale_simple(widgets->keyboard_original,600,400,GDK_INTERP_BILINEAR)); gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->SlidesImage),gdk_pixbuf_scale_simple(widgets->slides_original[0],600,400,GDK_INTERP_BILINEAR)); + int langsize; + config_str lang = default_langs(&langsize); + GtkTreeIter iter; gtk_list_store_clear(widgets->LanguagesList); parsed = yon_file_open(languages_path,&size); @@ -2481,6 +2512,8 @@ main_window *yon_main_window_complete(){ yon_char_parsed_free(cur,cur_size); } yon_char_parsed_free(parsed,size); + if (lang) + yon_char_parsed_free(lang,langsize); parsed = yon_dir_get_contents(zone_path,&size); for (int i=0;i Date: Fri, 30 Aug 2024 10:37:53 +0600 Subject: [PATCH 02/15] Removed printf functions --- source/ubinstall-gtk.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index b9eeaeb..36c2173 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -854,7 +854,6 @@ void on_language_clicked(GtkWidget *, main_window *widgets){ if ((found==size)&&statusfound==size){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DefaultCheck),1); } - printf("%d == %d == %d\n",found,size,statusfound); dictionary *dict=NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); @@ -1777,7 +1776,6 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ yon_debug_output("Install state: %s\n",yon_char_from_int(main_config.install_complete)); if (!main_config.install_complete){ gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); - printf("still deactivated\n"); gtk_widget_set_sensitive(widgets->CancelInstallButton,0); gtk_widget_set_sensitive(widgets->NextButton,0); gtk_widget_set_sensitive(widgets->BackButton,0); From 4bca9c7d7b0f7533e7870dd4e1b4b814ab80f992 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 30 Aug 2024 11:30:06 +0600 Subject: [PATCH 03/15] Added warning window before exiting installer --- source/ubinstall-gtk.c | 65 +++++++++++++++++++------------------ source/ubl-strings.h | 6 +++- ubinstall-gtk-warning.glade | 32 ++++++++++-------- ubinstall-gtk.pot | 9 +++++ ubinstall-gtk_ru.po | 9 +++++ 5 files changed, 75 insertions(+), 46 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 36c2173..1533896 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -2185,36 +2185,39 @@ void on_gparted_open(){ yon_launch_app_with_arguments(open_gparted_command,NULL); } -// gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets); -// void on_exit_accepted(GtkWidget *,main_window *widgets); -// void on_exit_accepted(GtkWidget *,main_window *widgets){ -// if (main_config.install_thread){ -// pthread_cancel((pthread_t)main_config.install_thread); -// } -// main_config.exit_accepted=1; -// g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"destroy",widgets->MainWindow,NULL); -// } - -// gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ -// if (!main_config.exit_accepted){ -// if (widgets){}; -// confirmation_window *window = malloc(sizeof(confirmation_window)); -// GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_confirmation); -// window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); -// window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); -// window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); -// g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_exit_accepted),widgets); -// g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); -// gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->MainWindow)); -// gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); -// gtk_window_set_icon_name(GTK_WINDOW(window->Window),icon_path); -// gtk_widget_show(window->Window); - -// return 1; -// } - -// return 0; -// } +gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets); + +void on_exit_accepted(GtkWidget *,main_window *widgets); +void on_exit_accepted(GtkWidget *,main_window *widgets){ + if (main_config.install_thread){ + pthread_cancel((pthread_t)main_config.install_thread); + } + main_config.exit_accepted=1; + g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event",widgets->MainWindow,NULL); + gtk_widget_destroy(widgets->MainWindow); +} + +gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ + if (!main_config.exit_accepted){ + if (widgets){}; + confirmation_window *window = malloc(sizeof(confirmation_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_confirmation); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_exit_accepted),widgets); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->MainWindow)); + gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); + gtk_window_set_icon_name(GTK_WINDOW(window->Window),icon_path); + gtk_widget_show(window->Window); + + + return 1; + } + + return 0; +} /**yon_main_window_complete(main_window *widgets) * [EN] @@ -2389,7 +2392,7 @@ main_window *yon_main_window_complete(){ widgets->SameFSTypeSensitiveCheck = yon_gtk_builder_get_widget(builder,"SameFSTypeSensitiveCheck"); widgets->SameLabelSensitiveCheck = yon_gtk_builder_get_widget(builder,"SameLabelSensitiveCheck"); - // g_signal_connect(G_OBJECT(widgets->MainWindow),"delete-event",G_CALLBACK(on_yon_exit),widgets); + g_signal_connect(G_OBJECT(widgets->MainWindow),"delete-event",G_CALLBACK(on_yon_exit),widgets); GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2"); gtk_style_context_add_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemmiddle"); gtk_style_context_remove_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemtop"); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 357d8a7..c25745b 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -181,4 +181,8 @@ #define ADD_LAYOUT_LABEL _("Add layouts") #define REMOVE_LAYOUT_LABEL _("Remove layout") -#define CONFIGURATION_LABEL _("System configuration...") \ No newline at end of file +#define CONFIGURATION_LABEL _("System configuration...") + +#define WARNING_TITLE_LABEL _("Warning") + +#define WARNING_TEXT_LABEL _("Are you sure want to exit and\ninterrupt installation process?") \ No newline at end of file diff --git a/ubinstall-gtk-warning.glade b/ubinstall-gtk-warning.glade index 704a8d9..cf113d5 100644 --- a/ubinstall-gtk-warning.glade +++ b/ubinstall-gtk-warning.glade @@ -1,13 +1,25 @@ - + + + + True + False + com.ublinux.libublsettingsui-gtk3.cancel-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.accept-symbolic + - 450 - 250 + 350 + 150 False False - 450 + True + 300 dialog-question-symbolic @@ -52,8 +64,10 @@ True False center + 15 Are you sure want to exit and interrupt installation process? + 0 @@ -133,14 +147,4 @@ interrupt installation process? - - True - False - com.ublinux.libublsettingsui-gtk3.cancel-symbolic - - - True - False - com.ublinux.libublsettingsui-gtk3.accept-symbolic - diff --git a/ubinstall-gtk.pot b/ubinstall-gtk.pot index be35c77..98031f6 100644 --- a/ubinstall-gtk.pot +++ b/ubinstall-gtk.pot @@ -628,6 +628,15 @@ msgstr "" msgid "Remove layout" msgstr "" +msgid "Warning" +msgstr "" + +msgid "Accept" +msgstr "" + +msgid "Are you sure want to exit and\ninterrupt installation process?" +msgstr "" + msgid "English, U.S.A.; Russian, Russia" msgstr "" diff --git a/ubinstall-gtk_ru.po b/ubinstall-gtk_ru.po index 85fa027..36ae6c3 100644 --- a/ubinstall-gtk_ru.po +++ b/ubinstall-gtk_ru.po @@ -641,6 +641,15 @@ msgstr "Добавить раскладки" msgid "Remove layout" msgstr "Удалить раскладку" +msgid "Warning" +msgstr "Внимание" + +msgid "Accept" +msgstr "Принять" + +msgid "Are you sure want to exit and\ninterrupt installation process?" +msgstr "Вы уверены, что хотите закрыть программу и\nпрервать процесс установки?" + #: source/ubl-strings.h:140 msgid "Read installation log" msgstr "Открыть лог установки" From c645df015b67e79c6d264148de11120ed7f48f40 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 30 Aug 2024 11:56:42 +0600 Subject: [PATCH 04/15] fixed exit warning window cancel button --- source/ubinstall-gtk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 1533896..48a46cf 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -2207,6 +2207,7 @@ gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_exit_accepted),widgets); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->MainWindow)); gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); gtk_window_set_icon_name(GTK_WINDOW(window->Window),icon_path); From 60bdcdee3ea6d89cd52c53ae4c54f5b2e3efbfdb Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 30 Aug 2024 14:33:51 +0600 Subject: [PATCH 05/15] Fix for installation completion title label text --- ubinstall-gtk.glade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index ea6e2da..46c852e 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -2623,7 +2623,7 @@ and help you install UBLinux on your computer True False True - ublinux-install + auto True @@ -2686,7 +2686,7 @@ and help you install UBLinux on your computer True False - Completion + Installation completion From fc236083832974be542bb85ad2abee3dff293847 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 2 Sep 2024 11:19:11 +0600 Subject: [PATCH 06/15] Test fix for free size field --- source/ubinstall-gtk.c | 57 +++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 48a46cf..8625e99 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -2078,14 +2078,33 @@ void on_separate_installation_changed(GtkWidget *self, main_window *widgets){ json_object_object_get_ex(device, "fstype", &fstype); json_object_object_get_ex(device, "fsused", &fsused); - float free_space=0; + double free_space=0; char *free_space_string=""; if (size&&fsused){ - free_space = atof(json_object_get_string(size))-atof(json_object_get_string(fsused)); - free_space_string = yon_char_append(yon_char_from_float(free_space)," "); - free_space_string[strlen(free_space_string)-1]=json_object_get_string(size)[strlen(json_object_get_string(size))-1]; + char *fsused_str = (char*)json_object_get_string(fsused); + double fsused_kbytes = atof(fsused_str); + for (int i=0;i1024;sz=sz+1){ + free_space=free_space/1024; + } + if (sz==-1) { + sz=0; + free_space=free_space/1024; + } + free_space_string = yon_char_append(yon_char_from_double(free_space)," "); + free_space_string[strlen(free_space_string)-1]=*(yon_size_get_mod(sz)); } - // gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),0.0); gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin)),0.0); gtk_list_store_append(widgets->PartitionsList,&iter); gtk_list_store_set(widgets->PartitionsList,&iter,0,json_object_get_string(path),1,json_object_get_string(size),2,free_space_string,3,json_object_get_string(fstype),-1); @@ -2125,12 +2144,32 @@ void on_near_installation_device_changed(GtkWidget *self, main_window *widgets){ json_object_object_get_ex(device, "fstype", &fstype); json_object_object_get_ex(device, "fsused", &fsused); - float free_space=0; + double free_space=0; char *free_space_string=""; if (size&&fsused){ - free_space = atof(json_object_get_string(size))-atof(json_object_get_string(fsused)); - free_space_string = yon_char_append(yon_char_from_float(free_space)," "); - free_space_string[strlen(free_space_string)-1]=json_object_get_string(size)[strlen(json_object_get_string(size))-1]; + char *fsused_str = (char*)json_object_get_string(fsused); + double fsused_kbytes = atof(fsused_str); + for (int i=0;i1024;sz=sz+1){ + free_space=free_space/1024; + } + if (sz==-1) { + sz=0; + free_space=free_space/1024; + } + free_space_string = yon_char_append(yon_char_from_double(free_space)," "); + free_space_string[strlen(free_space_string)-1]=*(yon_size_get_mod(sz)); } // gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),0.0); gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin)),0.0); From ad8e3d41c0061c18d1557cfe74d8514e01321d2c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 2 Sep 2024 11:19:33 +0600 Subject: [PATCH 07/15] Fixed keyboard page image size --- ubinstall-gtk.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index 46c852e..619a9b5 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -1897,7 +1897,7 @@ and help you install UBLinux on your computer - False + True True 1 From 0bd36829acdcd939af9c8708e25b1b1185fa6265 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 4 Sep 2024 12:14:43 +0600 Subject: [PATCH 08/15] Test added new flag --- source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a3e0cae..2437b12 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -95,7 +95,7 @@ add_definitions(-DVTE_INCLUDE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ -Wformat -Werror=format-security \ - -fstack-clash-protection -fcf-protection") + -fstack-clash-protection -fcf-protection -fsanitize=address") string(FIND "${CMAKE_CXX_FLAGS}" "-D_FORTIFY_SOURCE" FORTIFY_FOUND) From bdb401caeadedb166d3eda27ca0fcda8a2a0b43d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 4 Sep 2024 12:34:13 +0600 Subject: [PATCH 09/15] Temporary add of LeakSanitizer flags for build --- source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 2437b12..b60df14 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -95,7 +95,7 @@ add_definitions(-DVTE_INCLUDE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ -Wformat -Werror=format-security \ - -fstack-clash-protection -fcf-protection -fsanitize=address") + -fstack-clash-protection -fcf-protection -fsanitize=address -fno-omit-frame-pointer") string(FIND "${CMAKE_CXX_FLAGS}" "-D_FORTIFY_SOURCE" FORTIFY_FOUND) From 54382354895b9048dfbca24d99397ac9779c9c79 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 5 Sep 2024 17:47:50 +0600 Subject: [PATCH 10/15] Leaks fixes --- source/ubinstall-gtk.c | 58 +++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 8625e99..7ce380a 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -355,14 +355,16 @@ void yon_interface_update(main_window *widgets){ int langsize; config_str lang = default_langs(&langsize); for_iter(widgets->LanguagesList,&iter){ - char *cur; + char *cur=NULL; gtk_tree_model_get(GTK_TREE_MODEL(widgets->LanguagesList),&iter,2,&cur,-1); if (lang&&yon_char_parsed_check_exist(lang,langsize,cur)>-1){ gtk_list_store_set(widgets->LanguagesList,&iter,0,1,-1); } else { gtk_list_store_set(widgets->LanguagesList,&iter,0,0,-1); } + if (cur) free(cur); } + if (langsize) yon_char_parsed_free(lang,langsize); // gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter)); } @@ -921,7 +923,7 @@ int yon_image_resize_from_container(GtkImage *target, GdkPixbuf *pixbuf_unscaled GdkPixbuf *scaledPixBuf = gdk_pixbuf_scale_simple(pixbuf_unscaled, newImageWidth, newImgHeight, GDK_INTERP_BILINEAR); gtk_image_set_from_pixbuf(target, scaledPixBuf); - g_object_unref(scaledPixBuf); // Освобождаем память, занятую скалированным изображением + g_object_unref(scaledPixBuf); return 1; } @@ -1048,10 +1050,10 @@ gboolean yon_installation_progress_update(void *data) { yon_char_parsed_free(parsed, size); } - yon_char_parsed_free(text, size); free(current_copy); free(percentage); } + yon_char_parsed_free(text, size); } if (main_config.install_thread) { @@ -1986,8 +1988,10 @@ void on_region_changed(GtkComboBox *self, main_window *widgets){ for (int i=0;iZoneCombo),parsed[i],_(parsed[i])); } + if (size) yon_char_parsed_free(parsed,size); gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ZoneCombo),0); } + free(active); } void on_locale_changed(GtkWidget *,main_window *); @@ -2226,13 +2230,18 @@ void on_gparted_open(){ gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets); -void on_exit_accepted(GtkWidget *,main_window *widgets); -void on_exit_accepted(GtkWidget *,main_window *widgets){ +void on_exit_accepted(GtkWidget *,dictionary *dict); +void on_exit_accepted(GtkWidget *,dictionary *dict){ + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + confirmation_window *window = yon_dictionary_get_data(dict->first->next,confirmation_window*); if (main_config.install_thread){ pthread_cancel((pthread_t)main_config.install_thread); } main_config.exit_accepted=1; g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event",widgets->MainWindow,NULL); + free(window); + yon_dictionary_free_all(dict,NULL); + free(dict); gtk_widget_destroy(widgets->MainWindow); } @@ -2244,7 +2253,10 @@ gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); - g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_exit_accepted),widgets); + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_exit_accepted),dict); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->MainWindow)); @@ -2532,9 +2544,15 @@ main_window *yon_main_window_complete(){ int width = gdk_pixbuf_get_width(widgets->regions_original); int height = gdk_pixbuf_get_height(widgets->regions_original); widgets->region_height_mult = (float)height/width; - gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->RegionImage),gdk_pixbuf_scale_simple(widgets->regions_original,600,400,GDK_INTERP_BILINEAR)); - gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->KeyboardImage),gdk_pixbuf_scale_simple(widgets->keyboard_original,600,400,GDK_INTERP_BILINEAR)); - gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->SlidesImage),gdk_pixbuf_scale_simple(widgets->slides_original[0],600,400,GDK_INTERP_BILINEAR)); + GdkPixbuf *pix = gdk_pixbuf_scale_simple(widgets->regions_original,600,400,GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->RegionImage),pix); + g_object_unref(pix); + pix = gdk_pixbuf_scale_simple(widgets->keyboard_original,600,400,GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->KeyboardImage),pix); + g_object_unref(pix); + pix = gdk_pixbuf_scale_simple(widgets->slides_original[0],600,400,GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->SlidesImage),pix); + g_object_unref(pix); int langsize; config_str lang = default_langs(&langsize); @@ -2579,11 +2597,14 @@ main_window *yon_main_window_complete(){ gtk_tree_store_append(widgets->LayoutList,&iter,NULL); gtk_tree_store_set(widgets->LayoutList,&iter,0,layout[0],1,_(layout[1]),2,1,-1); yon_char_parsed_free(layout,layout_size); - layout = yon_config_load(get_layouts_local_command(layout_id),&layout_size); + char *command = get_layouts_local_command(layout_id); + config_str layout_local = yon_config_load(command,&layout_size); + free(command); + free(layout_id); for (int j=0;jLayoutList,&itar,&iter); gtk_tree_store_set(widgets->LayoutList,&itar,0,layouts_parsed[0],1,_(layouts_parsed[1]),2,1,3,0,-1); @@ -2593,7 +2614,7 @@ main_window *yon_main_window_complete(){ if (layout_size==-1) { gtk_tree_store_set(widgets->LayoutList,&iter,2,1,-1); } - yon_char_parsed_free(layout,layout_size); + yon_char_parsed_free(layout_local,layout_size); } } yon_char_parsed_free(parsed,size); @@ -2603,6 +2624,7 @@ main_window *yon_main_window_complete(){ struct json_object *root; struct json_object *blockdevices; root = json_tokener_parse(string); + free(string); json_object_object_get_ex(root, "blockdevices", &blockdevices); for (long unsigned int i = 0; i < json_object_array_length(blockdevices); i++) { struct json_object *device = json_object_array_get_idx(blockdevices, i); @@ -2616,6 +2638,7 @@ main_window *yon_main_window_complete(){ gtk_list_store_append(widgets->DevicesList,&iter); gtk_list_store_set(widgets->DevicesList,&iter,0,json_object_get_string(path),1,json_object_get_string(model),2,json_object_get_string(serial),3,json_object_get_string(size),4,json_object_get_string(vendor),-1); + } yon_char_parsed_free(parsed,size); } @@ -2627,8 +2650,10 @@ main_window *yon_main_window_complete(){ if (module_size){ gtk_list_store_append(widgets->AdditionalSoftwareList,&iter); gtk_list_store_set(widgets->AdditionalSoftwareList,&iter,0,1,1,module_parsed[0],3,module_parsed[1],-1); //2,module_parsed[2] + yon_char_parsed_free(module_parsed,module_size); } } + if (size) yon_char_parsed_free(parsed,size); config_str models = yon_config_load(get_models_command,&size); for (int i=0;iKeyboardModelCombo),models[i],_(models[i+1])); } + if (size) yon_char_parsed_free(models,size); gtk_builder_connect_signals(builder,NULL); yon_load_proceed(YON_CONFIG_DEFAULT); yon_interface_update(widgets); @@ -2724,12 +2750,14 @@ int main(int argc, char *argv[]){ main_window *widgets = NULL; widgets = yon_main_window_complete(); yon_window_config_setup(GTK_WINDOW(widgets->MainWindow)); - - yon_window_config_load(config_path); + char *window_config_path = config_path; + yon_window_config_load(window_config_path); + free(window_config_path); GtkCssProvider *css=gtk_css_provider_new(); gtk_css_provider_load_from_resource(css,CssPath); gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), -1); gtk_main(); + free(widgets); } \ No newline at end of file From fcf076bc89a6e192bb2b545e2e971d46309c81a5 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 5 Sep 2024 18:04:55 +0600 Subject: [PATCH 11/15] Test fix for freezing while install configuration is proceeded --- source/ubinstall-gtk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 7ce380a..243f8d8 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -1763,6 +1763,7 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); } if (gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress))>0.9){ + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),CONFIGURATION_LABEL); pthread_t tid; pthread_create(&tid,NULL,on_setup_system_configuration,widgets); From aa252493898ecf5feabb88517c19e104ac965a02 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 6 Sep 2024 10:55:02 +0600 Subject: [PATCH 12/15] Test debug messages for crash localising --- source/ubinstall-gtk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 243f8d8..3c1a4a5 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -1209,6 +1209,7 @@ void *on_install_success(main_window *widgets){ void *on_setup_system_configuration(void *data); void *on_setup_system_configuration(void * data){ + yon_debug_output("$s\n","Entered thread"); main_window *widgets = (main_window*)data; if (widgets){}; int size; @@ -1759,15 +1760,17 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ } if (!main_config.configure_mode){ + yon_debug_output("$s\n","Entered saving"); if (!main_config.install_complete){ gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); } if (gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress))>0.9){ + yon_debug_output("$s\n","Entered saving before installation done"); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),CONFIGURATION_LABEL); pthread_t tid; - pthread_create(&tid,NULL,on_setup_system_configuration,widgets); yon_debug_output("%s\n","installation ending configuration startup"); + pthread_create(&tid,NULL,on_setup_system_configuration,widgets); } else { pthread_t tid; pthread_create(&tid,NULL,on_save_system_configuration,widgets); From 2905c6ab5c77f81738bcf8ef650e6752cbb814fe Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 6 Sep 2024 11:01:37 +0600 Subject: [PATCH 13/15] test fix for crash, test debug messages --- source/ubinstall-gtk.c | 19 +++++++++++++++++-- source/ubinstall-gtk.h | 4 +++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 3c1a4a5..3f1f3da 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -994,24 +994,32 @@ void *on_config_save(void *data){ fclose(file); char *command = save_config_command(yon_char_parsed_to_string(parameters,size," ")); yon_char_parsed_free(parameters,size); + yon_debug_output("$s\n","Entered installation"); if (system(yon_debug_output("%s\n",command))){ - gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALL_ERROR); + yon_debug_output("$s\n","Entered installation failed"); + + g_thread_new("success func",(GThreadFunc)on_install_error,widgets); free(command); main_config.config_save_thread=NULL; main_config.install_thread=0; main_config.install_complete=1; + yon_debug_output("$s\n","Exit installation"); pthread_exit(NULL); return 0; }; + yon_debug_output("$s\n","Entered installation success"); free(command); main_config.install_thread=0; main_config.install_complete=1; yon_debug_output("Install set to: %s\n",yon_char_from_int(main_config.install_complete)); yon_debug_output("Save state: %s\n",yon_char_from_int(main_config.save_done)); if (main_config.save_done){ - gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETION); + yon_debug_output("$s\n","Entered installation page change"); + g_thread_new("success func",(GThreadFunc)on_install_success,widgets); } main_config.config_save_thread=NULL; + + yon_debug_output("$s\n","Exit installation"); pthread_exit(NULL); } @@ -1207,6 +1215,13 @@ void *on_install_success(main_window *widgets){ return NULL; } +void *on_install_error(main_window *widgets){ + gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),""); + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALL_ERROR); + + return NULL; +} + void *on_setup_system_configuration(void *data); void *on_setup_system_configuration(void * data){ yon_debug_output("$s\n","Entered thread"); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 7689db5..64f0799 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -467,4 +467,6 @@ void on_autohostname_sensitiveness_check(GtkWidget *, main_window *widgets); void on_autohostname_check(GtkWidget *, main_window *widgets); void on_hostname_entry_changed (GtkWidget *, main_window *widgets); -void *on_install_success(main_window *widgets); \ No newline at end of file +void *on_install_success(main_window *widgets); + +void *on_install_error(main_window *widgets); \ No newline at end of file From 499e1ce78a9d0f0a14a10b9fbb84af05061d2179 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 6 Sep 2024 11:22:19 +0600 Subject: [PATCH 14/15] Test added new debg messages --- source/ubinstall-gtk.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 3f1f3da..161aeb5 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -994,32 +994,32 @@ void *on_config_save(void *data){ fclose(file); char *command = save_config_command(yon_char_parsed_to_string(parameters,size," ")); yon_char_parsed_free(parameters,size); - yon_debug_output("$s\n","Entered installation"); + yon_debug_output("%s\n","Entered installation"); if (system(yon_debug_output("%s\n",command))){ - yon_debug_output("$s\n","Entered installation failed"); + yon_debug_output("%s\n","Entered installation failed"); g_thread_new("success func",(GThreadFunc)on_install_error,widgets); free(command); main_config.config_save_thread=NULL; main_config.install_thread=0; main_config.install_complete=1; - yon_debug_output("$s\n","Exit installation"); + yon_debug_output("%s\n","Exit installation"); pthread_exit(NULL); return 0; }; - yon_debug_output("$s\n","Entered installation success"); + yon_debug_output("%s\n","Entered installation success"); free(command); main_config.install_thread=0; main_config.install_complete=1; yon_debug_output("Install set to: %s\n",yon_char_from_int(main_config.install_complete)); yon_debug_output("Save state: %s\n",yon_char_from_int(main_config.save_done)); if (main_config.save_done){ - yon_debug_output("$s\n","Entered installation page change"); + yon_debug_output("%s\n","Entered installation page change"); g_thread_new("success func",(GThreadFunc)on_install_success,widgets); } main_config.config_save_thread=NULL; - yon_debug_output("$s\n","Exit installation"); + yon_debug_output("%s\n","Exit installation"); pthread_exit(NULL); } @@ -1152,6 +1152,7 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ } break; case YON_PAGE_COMPLETION:{ + yon_debug_output("%s\n","Enter completion"); yon_switch_page_render(widgets,7); gtk_widget_set_sensitive(widgets->BackButton,0); gtk_widget_hide(gtk_widget_get_parent(widgets->PackageInstallationProgress)); @@ -1159,13 +1160,16 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ gtk_widget_hide(widgets->PackageInstallationLabel); gtk_widget_set_sensitive(widgets->NextButton,1); gtk_widget_set_sensitive(widgets->CancelInstallButton,1); + yon_debug_output("%s\n","Done widgets"); main_config.install_complete=0; main_config.save_done=0; + yon_debug_output("%s\n","Done variables"); textdomain(LocaleName); gtk_button_set_label(GTK_BUTTON(widgets->NextButton),RESTART_LABEL); gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),EXIT_LABEL); gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))), "com.ublinux.ubinstall-gtk.sync-symbolic",GTK_ICON_SIZE_BUTTON); + yon_debug_output("%s\n","Done labels and button icon"); } break; @@ -1224,7 +1228,7 @@ void *on_install_error(main_window *widgets){ void *on_setup_system_configuration(void *data); void *on_setup_system_configuration(void * data){ - yon_debug_output("$s\n","Entered thread"); + yon_debug_output("%s\n","Entered thread"); main_window *widgets = (main_window*)data; if (widgets){}; int size; @@ -1246,7 +1250,7 @@ void *on_setup_system_configuration(void * data){ if (all_parameters){ char *parameter_string = yon_char_parsed_to_string(all_parameters,size," "); char *command = set_user_config_command(parameter_string); - if (system(yon_debug_output("$s\n",command))){}; + if (system(yon_debug_output("%s\n",command))){}; yon_char_parsed_free(all_parameters,size); free(command); if (parameter_string) free(parameter_string); @@ -1775,12 +1779,12 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ } if (!main_config.configure_mode){ - yon_debug_output("$s\n","Entered saving"); + yon_debug_output("%s\n","Entered saving"); if (!main_config.install_complete){ gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); } if (gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress))>0.9){ - yon_debug_output("$s\n","Entered saving before installation done"); + yon_debug_output("%s\n","Entered saving before installation done"); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),CONFIGURATION_LABEL); pthread_t tid; From 623977f6536b328c4791dc114c8bf0d0c496ea1b Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 6 Sep 2024 11:43:04 +0600 Subject: [PATCH 15/15] test fix for crash --- source/ubinstall-gtk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 161aeb5..0539b52 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -1167,8 +1167,8 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ textdomain(LocaleName); gtk_button_set_label(GTK_BUTTON(widgets->NextButton),RESTART_LABEL); gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),EXIT_LABEL); - gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))), - "com.ublinux.ubinstall-gtk.sync-symbolic",GTK_ICON_SIZE_BUTTON); + // gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))), + // "com.ublinux.ubinstall-gtk.sync-symbolic",GTK_ICON_SIZE_BUTTON); yon_debug_output("%s\n","Done labels and button icon"); } break;