gpt4 book ai didi

gtk - 销毁 GtkBuilder 会销毁所有创建的小部件吗?

转载 作者:行者123 更新时间:2023-12-04 06:55:20 28 4
gpt4 key购买 nike

关于 GtkBuilder 的问题。
当我们取消引用构建器指针时,它是否会破坏构建器创建的所有屏幕/小部件?

if( builder_ptr )
g_object_unref(G_OBJECT(builder_ptr));

假设我们使用 Glade/XML 创建了一个屏幕,其中包含 2-3 个顶级窗口
gtk_builder_add_from_file(builder_ptr, "Test.glade", &error )

并生成了 GtkBuilder 指针(如上),所以在删除这个指针后它会删除创建的窗口还是我们需要手动删除这些窗口?

谢谢,
聚丙烯。

最佳答案

来自 documentation :

A GtkBuilder holds a reference to all objects that it has constructed and drops these references when it is finalized. This finalization can cause the destruction of non-widget objects or widgets which are not contained in a toplevel window. For toplevel windows constructed by a builder, it is the responsibility of the user to call gtk_widget_destroy() to get rid of them and all the widgets they contain.



所以,不,GtkBuilder 不会为你做这件事,你必须自己做。

关于gtk - 销毁 GtkBuilder 会销毁所有创建的小部件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2622791/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com