GtkExpander无意中崩溃了

时间:2017-05-25 13:19:09

标签: c gtk gtk3

在以下使用GTK3编译的示例中,当我在输入字段中单击时,GtkExpander会无意中崩溃。

#include <gtk/gtk.h>

static void destroy (GtkWidget *widget, gpointer data)
{
    gtk_main_quit ();
}

int main( int   argc,
          char *argv[] )
{
    gtk_init (&argc, &argv);

    GtkWidget *entry;
    entry = gtk_entry_new ();

    GtkWidget *expander;
    expander = gtk_expander_new ("test");
    gtk_expander_set_expanded (GTK_EXPANDER(expander), TRUE);
    gtk_container_add (GTK_CONTAINER(expander), entry);

    GtkWidget *window;
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_container_add (GTK_CONTAINER(window), expander);
    g_signal_connect (window, "destroy", G_CALLBACK (destroy), NULL);
    gtk_widget_show_all (window);

    gtk_main ();
    return 0;
}

但是,如果GtkExpander在gtk_widget_show_all()之后展开,那么不会崩溃,即:

    gtk_widget_show_all (window);
    gtk_expander_set_expanded (GTK_EXPANDER(expander), TRUE);

gtk_widget_show_all()之前展开小部件有什么问题?

1 个答案:

答案 0 :(得分:0)