在子线程中调用函数,显示一个含有view的窗口,程序报错。但是,在主线程(main函数)里面调用的话,不报错!介是问什么啊!!!!求解!!!!
和这个类似,把gtk_text_view_new插入面板报错。http://zhidao.baidu.com/question/262205672.html
但是,我的没有线程调用新函数并没有使用公有数据,因此不存在使用lock的情况。希望大牛们帮帮我啊!
子线程调用代码如下:
gdk_threads_enter(); //省略若干判断.........
else if(memchr(buf,'4',1)){//这是我的一个判断条件而已
struct msg_chat *msg;
msg = (struct msg_chat *)malloc(sizeof(struct msg_chat));
msg = (struct msg_chat *)buf;
printf(" logined from : %s \n",msg->to);
chat_window_init("asdfasdfasdf");
}
void chat_window_init(char *username){
...省略部分代码
window_chat ->p_text = gtk_text_view_new();
gtk_text_view_set_editable ((GtkTextView *)window_chat ->p_text,FALSE);
gtk_container_add(GTK_CONTAINER(window_chat ->p_view),window_chat ->p_text);
gtk_box_pack_start(GTK_BOX(window_chat ->p_vbox),window_chat ->p_view,TRUE,TRUE,5);
...
}
linux终端报错如下:
(client:7472): Gtk-CRITICAL **: gtk_text_attributes_ref: assertion `values != NULL' failed
(client:7472): Gtk-CRITICAL **: gtk_text_attributes_ref: assertion `values != NULL' failed
(client:7472): Pango-CRITICAL **: pango_layout_new: assertion `context != NULL' failed
段错误
谢谢各位大牛解答,不胜感激!