gtk_container_remove移除容器内组件
gtk_container_remove ()
void gtk_container_remove (GtkContainer *container,
GtkWidget *widget);
Removes widget from container. widget must be inside container. Note that container will own a reference to widget, and that this may be the last reference held; so removing a widget from its container can destroy that widget. If you want to use widget again, you need to add a reference to it while it's not inside a container, using g_object_ref(). If you don't want to use widget again it's usually more efficient to simply destroy it directly using gtk_widget_destroy() since this will remove it from the container and help break any circular reference count cycles.
container :
a GtkContainer
widget :
a current child of container
为了移除后还可以继续使用组件,使用g_object_ref增加对象的引用计数文章来源:https://www.toymoban.com/news/detail-662142.html
g_object_ref ()
gpointer g_object_ref (gpointer object);
Increases the reference count of object.
与之对应的是g_object_unref,减少对象引用计数,释放对象文章来源地址https://www.toymoban.com/news/detail-662142.html
g_object_unref ()
void g_object_unref (gpointer object);
Decreases the reference count of object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).
到了这里,关于GTK防止gtk_container_remove移除组件后被销毁的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!