From 75afb7b38967cf2e43dfe15a06c8b32088dc01cd Mon Sep 17 00:00:00 2001 From: YanTheKaller Date: Wed, 11 Sep 2024 17:57:47 +0600 Subject: [PATCH] Test fix for crash --- source/ubinstall-gtk.c | 94 +++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 6af7f89..890e45d 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -982,6 +982,8 @@ char* yon_debug_output(char *pattern,char*text){ return text; } +void *on_setup_system_configuration(void *data); + void *on_config_save(void *data); void *on_config_save(void *data){ main_window *widgets = (main_window*)data; @@ -1013,9 +1015,11 @@ void *on_config_save(void *data){ 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){ + if (!main_config.save_done){ yon_debug_output("%s\n","Entered installation page change"); - g_thread_new("success func",(GThreadFunc)on_install_success,widgets); + pthread_t tid; + pthread_create(&tid,NULL,on_setup_system_configuration,widgets); + // g_thread_new("success func",(GThreadFunc)on_install_success,widgets); } main_config.config_save_thread=NULL; @@ -1096,14 +1100,14 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ } break; case YON_PAGE_REGION: { - // yon_image_resize_from_container(GTK_IMAGE(widgets->RegionImage), widgets->regions_original); + yon_image_resize_from_container(GTK_IMAGE(widgets->RegionImage), widgets->regions_original); yon_switch_page_render(widgets,4); } break; case YON_PAGE_KEYBOARD: { yon_switch_page_render(widgets,5); - // yon_image_resize_from_container(GTK_IMAGE(widgets->KeyboardImage), widgets->keyboard_original); + yon_image_resize_from_container(GTK_IMAGE(widgets->KeyboardImage), widgets->keyboard_original); } break; case YON_PAGE_OS_COMPONENTS: @@ -1123,7 +1127,7 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ main_config.progress_thread = gdk_threads_add_timeout(500,(GSourceFunc)yon_installation_progress_update,widgets); if (!main_config.slider_thread&&!main_config.configure_mode) - // main_config.slider_thread = g_timeout_add(5000,(GSourceFunc)on_image_slide,widgets); + main_config.slider_thread = g_timeout_add(5000,(GSourceFunc)on_image_slide,widgets); gtk_widget_show(gtk_widget_get_parent(widgets->InstallationProgress)); } break; @@ -1168,8 +1172,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; @@ -1227,7 +1231,6 @@ void *on_install_error(main_window *widgets){ return NULL; } -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; @@ -1673,17 +1676,19 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ case YON_PAGE_USERS:{ //users if (yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(widgets->UserNameEntry)))||!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->UsernameSensitiveCheck))){ - yon_config_remove_by_key(user_gecos_parameter); + // yon_config_remove_by_key(user_gecos_parameter); } else { char *username = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->UserNameEntry)); - yon_config_register(user_gecos_parameter,user_gecos_parameter_command,username); + if (username){}; + // yon_config_register(user_gecos_parameter,user_gecos_parameter_command,username); } if (yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(widgets->LoginEntry)))||!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->LoginSensitiveCheck))){ - yon_config_remove_by_key(user_name_parameter); + // yon_config_remove_by_key(user_name_parameter); } else { char *login = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->LoginEntry)); - yon_config_register(user_name_parameter,user_name_parameter_command,login); + if (login){}; + // yon_config_register(user_name_parameter,user_name_parameter_command,login); } @@ -1695,15 +1700,16 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ return; } else { char *password = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->PasswordEntry)); + if (password){}; - yon_config_register(user_password_parameter,user_password_parameter_command,password); + // yon_config_register(user_password_parameter,user_password_parameter_command,password); } } else { - yon_config_remove_by_key(user_password_parameter); + // yon_config_remove_by_key(user_password_parameter); } }else { - yon_config_remove_by_key(user_password_parameter); + // yon_config_remove_by_key(user_password_parameter); } @@ -1715,38 +1721,41 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ return; } else { char *root_password = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->AdminPasswordEntry)); - yon_config_register(root_password_parameter,root_password_parameter_command,root_password); + if (root_password){}; + // yon_config_register(root_password_parameter,root_password_parameter_command,root_password); } } else { - yon_config_remove_by_key(root_password_parameter); + // yon_config_remove_by_key(root_password_parameter); } } else { - yon_config_remove_by_key(root_password_parameter); + // yon_config_remove_by_key(root_password_parameter); } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck))){ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck))){ - yon_config_register(hostname_parameter,hostname_parameter_command,"auto"); + // yon_config_register(hostname_parameter,hostname_parameter_command,"auto"); } else { if (!yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(widgets->HotnameEntry)))){ char *hostname = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->HotnameEntry)); - yon_config_register(hostname_parameter,hostname_parameter_command,hostname); + if (hostname){}; + // yon_config_register(hostname_parameter,hostname_parameter_command,hostname); } else { - yon_config_remove_by_key(hostname_parameter); + // yon_config_remove_by_key(hostname_parameter); } } } else { - yon_config_remove_by_key(hostname_parameter); + // yon_config_remove_by_key(hostname_parameter); } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutologinSensitiveCheck))){ char *autologin = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutologinCheck))?"yes":"no"; - yon_config_register(autologin_parameter,autologin_parameter_command,autologin); + if (autologin){}; + // yon_config_register(autologin_parameter,autologin_parameter_command,autologin); } else { - yon_config_remove_by_key(autologin_parameter); + // yon_config_remove_by_key(autologin_parameter); } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->LayoutSensitiveCheck))){ @@ -1763,9 +1772,10 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ } } if (!yon_char_is_empty(locales)){ - yon_config_register(xkblayout_parameter,xkblayout_parameter_command,locales); + printf("%s\n",locales); + // yon_config_register(xkblayout_parameter,xkblayout_parameter_command,locales); } else { - yon_config_remove_by_key(xkblayout_parameter); + // yon_config_remove_by_key(xkblayout_parameter); } } } else { @@ -1774,37 +1784,28 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->LayoutBindingCombo))&>k_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->OptionsSensitiveCheck))){ char *options = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->LayoutBindingCombo)); - yon_config_register(xkboptions_parameter,xkboptions_parameter_command,options); + if (options){}; + // yon_config_register(xkboptions_parameter,xkboptions_parameter_command,options); } else { yon_config_remove_by_key(xkboptions_parameter); } 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){ + if (main_config.install_complete){ 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; yon_debug_output("%s\n","installation ending configuration startup"); + pthread_t tid; pthread_create(&tid,NULL,on_setup_system_configuration,widgets); - } else { - // pthread_t tid; - // pthread_create(&tid,NULL,on_save_system_configuration,widgets); - yon_debug_output("%s\n","installation process configuration startup"); - } - main_config.save_done=1; - yon_debug_output("Save changed to: %s\n",yon_char_from_int(main_config.save_done)); - 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); gtk_widget_set_sensitive(widgets->CancelInstallButton,0); gtk_widget_set_sensitive(widgets->NextButton,0); gtk_widget_set_sensitive(widgets->BackButton,0); + main_config.save_done=1; + } + if (!main_config.install_complete){ + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); } } else { gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_CONFIGURE_END); @@ -2492,7 +2493,7 @@ main_window *yon_main_window_complete(){ g_signal_connect(G_OBJECT(widgets->GpartedNearButton),"clicked",G_CALLBACK(on_gparted_open),NULL); g_signal_connect(G_OBJECT(widgets->Notebook),"switch-page",G_CALLBACK(on_page_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->MainWindow),"check-resize",G_CALLBACK(on_region_resized),widgets); + g_signal_connect(G_OBJECT(widgets->MainWindow),"check-resize",G_CALLBACK(on_region_resized),widgets); g_signal_connect(G_OBJECT(widgets->BackButton),"clicked",G_CALLBACK(on_page_navigation_clicked),widgets); g_signal_connect(G_OBJECT(widgets->NextButton),"clicked",G_CALLBACK(on_page_navigation_clicked),widgets); g_signal_connect(G_OBJECT(widgets->CancelInstallButton),"clicked",G_CALLBACK(on_page_navigation_clicked),widgets); @@ -2548,7 +2549,8 @@ main_window *yon_main_window_complete(){ gtk_window_set_icon_name(GTK_WINDOW(widgets->MainWindow),icon_path); int size; - config_str parsed = yon_file_open(licence_path,&size); + config_str parsed = NULL; + parsed = yon_file_open(licence_path,&size); if (size){ char *licence = yon_char_parsed_to_string(parsed,size,""); gtk_label_set_text(GTK_LABEL(widgets->LicenceLabel),licence); @@ -2564,7 +2566,7 @@ main_window *yon_main_window_complete(){ for (int i=1;islides_original = g_list_prepend(widgets->slides_original,gdk_pixbuf_new_from_resource(slides[i-1],NULL)); } - widgets->slides_original = (widgets->slides_original); + widgets->slides_original = g_list_reverse(widgets->slides_original); yon_char_parsed_free(slides,size); int width = gdk_pixbuf_get_width(widgets->regions_original); int height = gdk_pixbuf_get_height(widgets->regions_original);