我有一个非常小的应用程序,只有一个GtkFileChooserButton可以精确读取此代码

#include <gtk/gtk.h>

static void activate_main_window(GtkApplication *app, gpointer user_data) {
    GtkWidget *main_window = gtk_application_window_new(app);
    GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    GtkWidget *file_chooser = gtk_file_chooser_button_new("test",
        GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);

    gtk_container_add(GTK_CONTAINER(box),
        file_chooser);
    gtk_container_add(GTK_CONTAINER(main_window),
        box);

    gtk_widget_show_all(main_window);
}

int main(int argc, char **argv) {
    GtkApplication *app = gtk_application_new(NULL,
        G_APPLICATION_FLAGS_NONE);
    g_signal_connect(app, "activate", G_CALLBACK(activate_main_window), NULL);

    g_application_run(G_APPLICATION(app), argc, argv);
    g_object_unref(app);

    return 0;
}


问题来了:每当我单击按钮并从中选择一个文件夹时,我的代码就会在控制台中始终出现以下错误:

(test:16359): Gtk-CRITICAL **: gtk_tree_model_filter_get_value: assertion `GTK_TREE_MODEL_FILTER (model)->priv->stamp == iter->stamp' failed

(test:16359): GLib-GObject-WARNING **: gtype.c:4239: type id `0' is invalid

(test:16359): GLib-GObject-WARNING **: can't peek value table for type `<invalid>' which is not currently referenced


我最初在一个更大的项目中遇到了这个问题,考虑到这一事实,我认为这可能是导致该问题的另一个错误。因此,我编写了这小段代码,看看是否可以重现,但不幸的是,我可以。

是我现在看不到的东西,还是KDE和GTK集成的错误?我在Fedora 19下使用KDE 4.11.5。

编辑:

gdb backtrace输出:

Program received signal SIGSEGV, Segmentation fault.
0x0000003b392706b5 in gtk_tree_model_get_valist (tree_model=tree_model@entry=0x8aa170, iter=iter@entry=0x7fffffffd630, var_args=var_args@entry=0x7fffffffd4d8) at gtktreemodel.c:1765
1765          G_VALUE_LCOPY (&value, var_args, 0, &error);
(gdb) backtrace
#0  0x0000003b392706b5 in gtk_tree_model_get_valist (tree_model=tree_model@entry=0x8aa170, iter=iter@entry=0x7fffffffd630, var_args=var_args@entry=0x7fffffffd4d8) at gtktreemodel.c:1765
#1  0x0000003b392709cc in gtk_tree_model_get (tree_model=0x8aa170, iter=0x7fffffffd630) at gtktreemodel.c:1727
#2  0x0000003b39134670 in combo_box_row_separator_func (model=<optimized out>, iter=<optimized out>, user_data=<optimized out>) at gtkfilechooserbutton.c:2388
#3  0x0000003b390ecfb5 in tree_column_row_is_sensitive     (combo_box=combo_box@entry=0x67e220, iter=iter@entry=0x7fffffffd630) at gtkcombobox.c:2188
#4  0x0000003b390f24f2 in gtk_combo_box_list_button_released (widget=widget@entry=0x7211f0, event=0x929030, data=data@entry=0x67e220) at gtkcombobox.c:3753
#5  0x0000003b3918b33c in _gtk_marshal_BOOLEAN__BOXED (closure=0x7480d0, return_value=0x7fffffffd7a0, n_param_values=<optimized out>, param_values=0x7fffffffd850,
invocation_hint=<optimized out>, marshal_data=<optimized out>) at gtkmarshalers.c:85
#6  0x00000032f920fa28 in g_closure_invoke (closure=0x7480d0, return_value=return_value@entry=0x7fffffffd7a0, n_param_values=2,
param_values=param_values@entry=0x7fffffffd850, invocation_hint=invocation_hint@entry=0x7fffffffd7f0) at gclosure.c:777
#7  0x00000032f9220a1d in signal_emit_unlocked_R (node=node@entry=0x61d240, detail=detail@entry=0, instance=instance@entry=0x7211f0,
emission_return=emission_return@entry=0x7fffffffd920, instance_and_params=instance_and_params@entry=0x7fffffffd850) at gsignal.c:3584
#8  0x00000032f9228422 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7fffffffd9e8)
at gsignal.c:3338
#9  0x00000032f9228a32 in g_signal_emit (instance=instance@entry=0x7211f0, signal_id=<optimized out>, detail=detail@entry=0) at gsignal.c:3384
#10 0x0000003b392ab724 in gtk_widget_event_internal (widget=widget@entry=0x7211f0, event=event@entry=0x929030) at gtkwidget.c:6721
#11 0x0000003b392ab9f9 in gtk_widget_event (widget=widget@entry=0x7211f0, event=event@entry=0x929030) at gtkwidget.c:6378
#12 0x0000003b3918977c in propagate_event_up (topmost=<optimized out>, event=<optimized out>, widget=0x7211f0) at gtkmain.c:2393
#13 propagate_event (widget=<optimized out>, event=0x929030, captured=<optimized out>, topmost=0x0) at gtkmain.c:2501
#14 0x0000003b3918b015 in gtk_main_do_event (event=0x929030) at gtkmain.c:1716
#15 0x0000003b38c4e9d2 in gdk_event_source_dispatch (source=source@entry=0x654ab0, callback=<optimized out>, user_data=<optimized out>) at gdkeventsource.c:364
#16 0x00000032f8e47dc6 in g_main_dispatch (context=0x61c400) at gmain.c:3054
#17 g_main_context_dispatch (context=context@entry=0x61c400) at gmain.c:3630
#18 0x00000032f8e48118 in g_main_context_iterate (context=context@entry=0x61c400, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3701
#19 0x00000032f8e481bc in g_main_context_iteration (context=0x61c400, context@entry=0x0, may_block=may_block@entry=1) at gmain.c:3762
#20 0x00000032fe0966c4 in g_application_run (application=0x618030, argc=<optimized out>, argv=0x7fffffffde38) at gapplication.c:1623
#21 0x0000000000400c41 in main (argc=1, argv=0x7fffffffde38) at test.c:22

最佳答案

事实证明,这确实是GTK中的错误。我发现至少有两个错误报告[1] [2]解决了我所面临的问题。

幸运的是,在创建GtkFileChooserButton时,我可以通过设置默认文件夹来解决此问题。

[1] https://bugzilla.gnome.org/show_bug.cgi?id=729651
[2] https://bugs.kde.org/show_bug.cgi?id=326424

关于c - GtkFileChooserButton中的SIGSEGV,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23820093/

10-11 03:38