- 论坛徽章:
- 0
|
我是在线程里面设置列表控件里面的值的。
线程代码如下:- void thread_proc(void)
- {
- GtkListStore *list_store;
- GtkTreeModel *list_model;
- GtkTreeIter iter;
- gchar *str_data;
- gboolean flg_valid;
- gchar str_ppid_file[255] = {0};
- while(flg_thread_run)
- {
- sleep(16);
- gdk_threads_enter();
- // ==== list_info = gtk_tree_view_new(); =======
- list_model = gtk_tree_view_get_model(GTK_TREE_VIEW(list_info));
- list_store = GTK_LIST_STORE(list_model);
- flg_valid = gtk_tree_model_get_iter_first(list_model,&iter);
- while(flg_valid)
- {
- gtk_tree_model_get(list_model,&iter,LIST_COL_STATE,&str_data,-1);
- //如果状态不为空
- if(strcmp(str_data,"") != 0 && gtk_list_store_iter_is_valid(list_store,&iter) == TRUE)
- {
- goto next_iter;
- }
-
- g_free(str_data);
- if(!gtk_list_store_iter_is_valid(list_store,&iter))break;
- gtk_tree_model_get(list_model,&iter,LIST_COL_PPID,&str_data,-1);
- memset((char*)str_ppid_file,0,255);
- sprintf((char*)str_ppid_file,"%s%s%s",appconfig.log_sourcepath,str_data,appconfig.logname_filter);
- if(!file_exists((const gchar*)str_ppid_file)) goto next_iter;
- gboolean flg_test_state = check_test_log((const gchar*)str_ppid_file,(const gchar*)str_data);
- gchar str_tp_ver[50];
- strcpy((char*)str_tp_ver,(char*)get_tp_ver((const gchar*)str_ppid_file,(gchar*)str_data));
- if(str_tp_ver == NULL) goto next_iter;
-
- gchar *sxml = create_test_xml(flg_test_state,(const gchar*)str_data,(const gchar*)str_tp_ver);
- if(sxml == NULL) goto next_iter;
- if(!backup_log_file((const gchar*)appconfig.log_sourcepath,(const gchar*)appconfig.log_backuppath,str_data)) goto next_iter;
- g_free(str_data);
- str_data = upload_to_mes((const gchar*)sxml);
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- //gtk_list_store_set(list_store,&iter,LIST_COL_STATE,str_data);//段错误
- gtk_list_store_set_value(list_store,&iter,LIST_COL_STATE,(GValue*)"OK");//段错误
- gtk_list_store_set_value(list_store,&iter,LIST_COL_STATE,(GValue*)str_data);//段错误
- g_free(sxml);
- ////////////////////////////////////////////////////////////////////////////////////////////////////////
- next_iter:
- flg_valid = gtk_tree_model_iter_next(list_model,&iter);
- g_free(str_data);
- }
- gdk_threads_leave();
- }
- //gdk_threads_leave();
- }
复制代码 |
|