gtk_container_remove移除容器內(nèi)組件
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
為了移除后還可以繼續(xù)使用組件,使用g_object_ref增加對(duì)象的引用計(jì)數(shù)文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-662142.html
g_object_ref ()
gpointer g_object_ref (gpointer object);
Increases the reference count of object.
與之對(duì)應(yīng)的是g_object_unref,減少對(duì)象引用計(jì)數(shù),釋放對(duì)象文章來(lái)源地址http://www.zghlxwxcb.cn/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).
到了這里,關(guān)于GTK防止gtk_container_remove移除組件后被銷毀的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!