GtkWidget(GtkWindow, GtkButton, GtkComboBox等等)在new了之后,在程序退出时,该怎么释放内存?是否用gtk_widget_destroy释放?但调用这个函数会出错,抛出GTK_IS_WIDGET(widget)的assert出错。 下面是一个测试的程序,在gtk_widget_destroy 时出错,请问是怎么回事?
int main( int argc,
char *argv[] )
{
gtk_init (&argc, &argv);
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);
GtkWidget *button = gtk_button_new_with_label("button");
gtk_container_add(GTK_CONTAINER(window), button);
gtk_widget_show_all(window);
gtk_main ();
gtk_widget_destroy(button);
gtk_widget_destroy(window);
return 0;
}