GNOME Bugzilla – Bug 529533
Warning about wrapping unwrapped implementation types (e.g. GHalMount)
Last modified: 2008-06-24 10:42:10 UTC
When I run the following program, I get the following output: (process:11780): glibmm-WARNING **: failed to wrap type of 'GHalMount' Mounts 1 You will get this warning once for each mount that is found, so if you have 0 mounts, you won't see the warning. You may need to insert a cdrom or something to get a GHalMount to appear, I'm not sure. ================ Test case =============== #include <iostream> #include <ostream> #include <vector> #include <giomm.h> int main() { Gio::init(); using namespace Glib; using namespace Gio; RefPtr<VolumeMonitor> monitor = VolumeMonitor::get(); std::vector<RefPtr<Mount> > mounts = monitor->get_mounts(); std::cout << "Mounts " << mounts.size() << '\n'; }
The backtrace when the warning is printed: (gdb) bt
+ Trace 195943
We might need to implement a TypeTraits< Glib::RefPtr<Gio::Mount> > (and use it in the return type for get_mounts()) to ensure that it calls the wrap(GMount*, bool) function rather than a generic wrap(GObject*) function. That way, it would call wrap_auto_interface() instead of wrap_auto(). wrap_auto_interface() can wrap implementations of interfaces even if the implementor type is unknown. A generic wrap(GObject*) function can't know which type (an implemented interface or an implementing type) we want.
Created attachment 109795 [details] [review] [PATCH] * gio/src/mount.hg: Add a TypeTraits implementation for Glib::RefPtr<Gio::Mount> so that we can wrap implementor types that don't have a wrapper (e.g. GHalMount in gvfs). Fixes bug #529533 --- ChangeLog | 6 ++++++ gio/src/mount.hg | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-)
The previous patch seems to fix things for me, does it look ok to you, murray? Are we going to need to this for Gio::Volume, Gio::Drive, Gio::File, etc?
It looks like we'll have to do this for Volume and Drive, but not File. The TypeTraits are only used when trying to construct a list of objects, right? And giomm doesn't have any api which returns a list of files (the closest is a FileEnumerator object), so if my understanding of TypeTraits is correct, we don't really need one for File at the moment.
Yes, that works for me. Thanks for making the patch. However, I think this patch is slightly more obvious. I don't like using wrap_auto_interface() directly. Yes, I think we'll need this for the other interfaces when used in a ListHandle. The C functions for these didn't work in jhbuild for me at the time so, of course, everything that's not tested doesn't work.
Created attachment 109810 [details] [review] glibmm_mount_traits2.patch
Ah, OK. Yours looks cleaner than mine. I still don't have a great understanding of how the whole wrap system works. I'll add TypeTraits for Drive and Volume similar to your patch above and commit it.
fixed in trunk.
*** Bug 539560 has been marked as a duplicate of this bug. ***
*** Bug 535675 has been marked as a duplicate of this bug. ***
Note that this is now in a glibmm 2.16.x tarball.
*** Bug 539895 has been marked as a duplicate of this bug. ***