GLib-CRITICAL **: Source ID XXX was not found when attempting to remove it
I made a treeview with a treestore as model. The window is shown as expected, but when I click in the "+" to expand the items, I get this message:
GLib-CRITICAL **: Source ID 221 was not found when attempting to remove it
Here is my code:
#include <gtk/gtk.h>
/* compile with: */
/* gcc main.c -o boxy `pkg-config --cflags --libs gtk+-2.0` */
typedef struct {
GtkWidget *toplevel;
GtkWidget *treeview;
} Widgets;
enum { ITEM_PARENT, ITEM_CHILD };
typedef struct {
gint tipo;
gint id;
gchar *nombre;
gint cantidad;
} Lista;
void addColumn (GtkTreeView *tv, const gchar* title, gint pos) {
GtkCellRenderer *tmp;
tmp = gtk_cell_renderer_text_new ();
g_object_set (tmp, "editable", TRUE, "editable-set", TRUE, NULL);
gtk_tree_view_insert_column_with_attributes (tv, -1, title, tmp, "text", pos, NULL);
}
void setupTree (GtkTreeView *tv) {
const Lista lista[] = {
{ITEM_PARENT, 125, "Superman", 2},
{ITEM_CHILD, 23, "Batman", 1},
{ITEM_CHILD, 7, "Hulk", 5},
{ITEM_PARENT, 65, "Iron Man", 2},
{-1, -1, NULL, -1}
};
GtkTreeStore *model;
GtkTreeIter last;
gint pos;
model = gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT);
addColumn (tv, "ID", 0);
addColumn (tv, "Nombre", 1);
addColumn (tv, "Cantidad", 2);
for (pos = 0; lista[pos].tipo != -1; pos++) {
GtkTreeIter iter;
if (lista[pos].tipo == ITEM_PARENT) {
gtk_tree_store_append (model, &iter, NULL);
last = iter;
} else if (lista[pos].tipo == ITEM_CHILD) {
gtk_tree_store_append (model, &iter, &last);
}
gtk_tree_store_set (model, &iter, 0, lista[pos].id, 1, lista[pos].nombre, 2, lista[pos].cantidad, -1);
}
gtk_tree_view_set_model (tv, GTK_TREE_MODEL (model));
g_object_unref (model);
}
int main (int argc, char *argv[]) {
Widgets *ptr;
GtkWidget *scroll;
gtk_init (&argc, &argv);
ptr = g_slice_new0(Widgets);
ptr->toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_OUT);
ptr->treeview = gtk_tree_view_new ();
setupTree (GTK_TREE_VIEW (ptr->treeview));
g_signal_connect (ptr->toplevel, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_container_set_border_width (GTK_CONTAINER (ptr->toplevel), 10);
gtk_container_add (GTK_CONTAINER (scroll), ptr->treeview);
gtk_container_add (GTK_CONTAINER (ptr->toplevel), scroll);
gtk_widget_show_all (ptr->toplevel);
gtk_main ();
g_slice_free (Widgets, ptr);
return 0;
}
Any ideas?
이것은 당신 코드의 버그도 아니고 충돌도 아닙니다.사실 이건 단지 경고일 뿐입니다g_source_remove()gtk의 일부인 코드에서 이미 연결이 끊어진 특정 이벤트 핸들러의 연결을 끊기 위해 호출되었습니다.
The warning itself was introduced in glib 2.39, in this commit, and seems like only arch linux users are affected by it because other distros haven't updated yet.
대부분의 경우 이것은 완전히 무해하며 성가신 것일 뿐입니다.만약 그것이 a로 시작한다면 볼만한 가치가 있을지도 모릅니다.g_source_remove()자신의 코드로 전화하세요.
Set a breakpoint on g_log to find what's causing it:
(gdb) break g_log
Breakpoint 1 at 0x7ffff5ea5a70
(gdb) c
Continuing.
Breakpoint 1, 0x00007ffff5ea5a70 in g_log () from /usr/lib/libglib-2.0.so.0
(gdb) bt
#0 0x00007ffff5ea5a70 in g_log () from /usr/lib/libglib-2.0.so.0
#1 0x00007ffff5e9d9dc in g_source_remove () from /usr/lib/libglib-2.0.so.0
#2 0x00007ffff79bd0f5 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#3 0x00007ffff79cc1a4 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#4 0x00007ffff79cda66 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#5 0x00007ffff78d7435 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#6 0x00007ffff616e3d8 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#7 0x00007ffff617fb1b in ?? () from /usr/lib/libgobject-2.0.so.0
#8 0x00007ffff6187719 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#9 0x00007ffff6187d02 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#10 0x00007ffff79e6fe4 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#11 0x00007ffff78d5be4 in gtk_propagate_event () from /usr/lib/libgtk-x11-2.0.so.0
#12 0x00007ffff78d5f9b in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
#13 0x00007ffff75519cc in ?? () from /usr/lib/libgdk-x11-2.0.so.0
#14 0x00007ffff5e9eb84 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#15 0x00007ffff5e9edc8 in ?? () from /usr/lib/libglib-2.0.so.0
#16 0x00007ffff5e9f08a in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#17 0x00007ffff78d5087 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#18 0x000000000040152f in main ()
The backtrace goes all the way from gtk_main to g_log without passing a single time through your code, so this probably affects any gtk program with a treeview.
ReferenceURL : https://stackoverflow.com/questions/23199699/glib-critical-source-id-xxx-was-not-found-when-attempting-to-remove-it
'codememo' 카테고리의 다른 글
| AngularJS 단순 "Hello, world" 작동 안 함 (0) | 2023.09.25 |
|---|---|
| C# 앱에서 엑셀에 사진을 삽입하는 방법? (0) | 2023.09.25 |
| Jquery get input array 필드 (0) | 2023.09.25 |
| Oracle SQL Developer에서 상대 경로별로 스크립트 실행 (0) | 2023.09.20 |
| WooCommerce 3에서 상품 가격을 표시하기 (0) | 2023.09.20 |