简单的说:g_object_weak_ref让引用者有机会知道,引用的对象是否已经无效了,这可以防止野指针的出现。对于窗口对象,要模拟实现g_object_weak_ref的功能,其实有好几种方法:比如用GTK_IS_WIDGET判断窗口是否还有效、用g_object_set_data_full注册回调函数,或者注册GtkObject的destroy信号等。当然,只有g_object_weak_r...
简单的说:g_object_weak_ref让引用者有机会知道,引用的对象是否已经无效了,这可以防止野指针的出现。对于窗口对象,要模拟实现g_object_weak_ref的功能,其实有好几种方法:比如用GTK_IS_WIDGET判断窗口是否还有效、用g_object_set_data_full注册回调函数,或者注册GtkObject的destroy信号等。当然,只有g_object_weak_r...
self->last_focused_frame = self->frame2;g_object_weak_ref(G_OBJECT (self->frame2), ide_editor_view__focused_frame_weak_notify, self); }else{ g_object_weak_unref (G_OBJECT (self->frame2), ide_editor_view__focused_frame_weak_notify, self); self->last_focused_frame = self->frame...