Fixed crash while continiously closing windows between calling many status_box_spawn commands

pull/18/head
parent e3c0f7db86
commit daa7f9603e

@ -30,7 +30,7 @@ endif()
# -O2 -pipe -fno-plt -fexceptions \
# -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
# -fstack-clash-protection -fcf-protection")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
add_library(${PROJECT_NAME} SHARED
${PROJECT_NAME}.c
${PROJECT_NAME}.h)

@ -730,17 +730,16 @@ static char *yon_status_thread_id=NULL;
void _yon_ubl_status_box_timed_remove(struct temp_statusbox *statusstruct){
sleep(statusstruct->times);
if (status_thread_busy){
if (statusstruct->revealer){
gtk_revealer_set_reveal_child(GTK_REVEALER(statusstruct->revealer),0);
sleep(1);
gtk_widget_destroy(statusstruct->revealer);
}
status_thread_busy=0;
}
void __yon_ubl_status_box_destroyed(){
status_thread_busy=0;
void __yon_ubl_status_box_destroyed(GtkWidget *self,struct temp_statusbox *statusstruct){
statusstruct->revealer=NULL;
}
void yon_status_box_destroyed(){
@ -751,7 +750,7 @@ void yon_status_box_destroyed(){
}
int yon_ubl_status_box_spawn_infinite(GtkContainer *container, char *status_id, char *display_text, BACKGROUND_IMAGE_TYPE type){
if (!status_thread_busy){
if (!gtk_container_get_children(container)){
if (yon_status_thread_id){
if (!strcmp(yon_status_thread_id,status_id)){
return 0;
@ -762,7 +761,6 @@ int yon_ubl_status_box_spawn_infinite(GtkContainer *container, char *status_id,
for (int i=0;i<g_list_length(list);i++){
gtk_widget_destroy((GtkWidget*)g_list_nth_data(list,i));
}
status_thread_busy=0;
}
yon_status_thread_id = yon_char_new(status_id);
@ -780,7 +778,6 @@ int yon_ubl_status_box_spawn_infinite(GtkContainer *container, char *status_id,
gtk_widget_show_all(revealer);
gtk_revealer_set_reveal_child(GTK_REVEALER(revealer),1);
g_signal_connect(G_OBJECT(revealer),"destroy", G_CALLBACK(__yon_ubl_status_box_destroyed),NULL);
gtk_widget_set_margin_bottom(label,9);
gtk_widget_set_margin_top(label,9);
@ -802,6 +799,7 @@ int yon_ubl_status_box_spawn_infinite(GtkContainer *container, char *status_id,
if (display_text)
gtk_label_set_text(GTK_LABEL(label),display_text);
struct temp_statusbox *statusstruct = malloc(sizeof(struct temp_statusbox));
g_signal_connect(G_OBJECT(revealer),"destroy", G_CALLBACK(__yon_ubl_status_box_destroyed),statusstruct);
statusstruct->revealer = revealer;
}
}
@ -829,7 +827,7 @@ int yon_ubl_status_box_despawn_infinite(GtkContainer *container){
}
void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type){
if (!status_thread_busy){
if (!gtk_container_get_children(container)){
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
GtkWidget *revealer = gtk_revealer_new();
GtkWidget *label = gtk_label_new("");
@ -843,7 +841,6 @@ void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int ti
gtk_widget_show_all(revealer);
gtk_revealer_set_reveal_child(GTK_REVEALER(revealer),1);
g_signal_connect(G_OBJECT(revealer),"destroy", G_CALLBACK(__yon_ubl_status_box_destroyed),NULL);
gtk_widget_set_margin_bottom(label,9);
gtk_widget_set_margin_top(label,9);
@ -868,8 +865,8 @@ void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int ti
struct temp_statusbox *statusstruct = malloc(sizeof(struct temp_statusbox));
statusstruct->revealer = revealer;
statusstruct->times = timeout;
g_signal_connect(G_OBJECT(revealer),"destroy", G_CALLBACK(__yon_ubl_status_box_destroyed),statusstruct);
GThread *thread = g_thread_new("StatusThread",(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct);
status_thread_busy=1;
}
}

Loading…
Cancel
Save