Re: RecentInfo



On 7/25/06, Jonathon Jongsma <jonathon jongsma gmail com> wrote:
I'm trying to use the list of recent items, i.e.:
  std::vector<Glib::RefPtr<Gtk::RecentInfo> > info_list =
m_refRecentManager->get_items();

But when I compile this, it complains that RecentInfo doesn't have
reference() and unreference() functions.  I'm assuming that most
things managed by RefPtr get their reference() and unreference()
functions through inheritance from Glib::Object or something, but what
about things that are not GObject-based types?

I added the following lines to get it to compile
  _WRAP_METHOD(void reference() const, gtk_recent_info_ref)
  _WRAP_METHOD(void unreference() const, gtk_recent_info_unref)

Is there a better way to do this or should I commit the lines above?

Looking into this further, when I do add these methods 'manually' I'm
getting a segfault with the following backtrace (using valgrind since
it demangled it nicely for me):

==26318== Process terminating with default action of signal 11 (SIGSEGV)
==26318==  General Protection Fault
==26318==    at 0x6FF1B60: g_type_check_instance_is_a (gtype.c:3113)
==26318==    by 0x6FDA852: g_object_get_qdata (gobject.c:1781)
==26318==    by 0x5420EBD: Glib::wrap_auto(_GObject*, bool) (wrap.cc:133)
==26318==    by 0x408976:
Glib::ListHandle<Glib::RefPtr<Gtk::RecentInfo>,
Glib::Container_Helpers::TypeTraits<Glib::RefPtr<Gtk::RecentInfo> >
::operator std::vector<Glib::RefPtr<Gtk::RecentInfo>,
std::allocator<Glib::RefPtr<Gtk::RecentInfo> >
<Glib::RefPtr<Gtk::RecentInfo> >() const
(containerhandle_shared.h:218)
==26318==    by 0x40736F: ExampleWindow::ExampleWindow() (examplewindow.cc:94)
==26318==    by 0x408AD7: main (main.cc:26)

Digging into the ListHandle TypeTraits stuff, I notice that there's
the following specialization for ListHandles that hold a RefPtr type:

/** Partial specialization for pointers to const GObject instances.
* @ingroup ContHelpers
* The C++ type is always a Glib::RefPtr<>.
*/
template <class T>
struct TypeTraits< Glib::RefPtr<const T> >
{
...
}

So it seems like it's making  an assumption that T is a GObject type,
which eventually leads to calling g_object_get_qdata(), which is
invalid for a non GObject type.

So what's the best way to solve this?  Create a new specialization for
RefPtr managed types that aren't GObject types?  Use something
different than Glib::RefPtr to manage the returned RecentInfo objects?
Is there anything else similar to this in gtkmm already (i.e. a type
that is managed with Glib::RefPtr but isn't a GObject type and is used
with a ListHandle)?

Any input would be appreciated.
--
jonner



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]