RE: [java-gnome-hackers] g_object_ref
Brought to you by:
afcowie
From: Jeffrey M. <Jef...@Br...> - 2003-06-24 15:58:40
|
I do not like the unref() approach so I would vote for the finalise() approach. Since this could be a sizable change I vote to make this a post 0.8 item. -Jeff -----Original Message----- From: Mark Howard [mailto:mh...@ti...] Sent: Tuesday, June 24, 2003 11:20 AM To: jav...@li... Subject: [java-gnome-hackers] g_object_ref Hi, Looking back at my old program, I'm finding an old problem again. When GtkContainer.remove( widget ) is called, Gtk will destroy the widget if it was the last item to own a reference to it. However, the java object for the widget will still exist and can be passed to (say) add methods. In some cases, it is desirable to remove widgets temporarily and then readd the, The native solution to this problem is to call g_object_ref() to create a reference to the object and then call g_object_unref() when it is no longer required. We could add these methods, but it is not very Java-like - It would certainly allow memory leaks to be added to programs and also would cause confusion. Instead, I think we should call g_object_ref() whenever a Java object is constructed pointing to native GObjects. Then we need to call g_object_unref when the user has finished with the Java object; The only way I can think of doing this is either have a finaliser and an explicit unref() method, or use PhantomReferences Are there any better ways to do this? -- .''`. Mark Howard : :' : `. `' http://www.tildemh.com `- mh...@de... | mh...@ti... | mh...@ca... ------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php _______________________________________________ java-gnome-hackers mailing list jav...@li... https://lists.sourceforge.net/lists/listinfo/java-gnome-hackers |