GNOME Bugzilla – Bug 126721
can not access elements of TreeView::get_columns()const
Last modified: 2004-12-22 21:47:04 UTC
Since I can not dereference the list elements, the get_columns()const is of little value: #include <gtkmm/treeview.h> typedef Glib::ListHandle<const Gtk::TreeViewColumn*> list_t; void f() { list_t *l=0; for (list_t::const_iterator x=l->begin();x!=l->end();++x) *x; } --------- # g++ -c x.cc `pkg-config --cflags gtkmm-2.0` /usr/include/gtkmm-2.0/glibmm/containerhandle_shared.h: In static member function `static const T* Glib::Container_Helpers::TypeTraits<const T*>::to_cpp_type(typename T::BaseObjectType*) [with T = Gtk::TreeViewColumn] ': /usr/include/gtkmm-2.0/glibmm/listhandle.h:227: instantiated from `typename Tr ::CppType Glib::Container_Helpers::ListHandleIterator<Tr>::operator*() const [wi th Tr = Glib::Container_Helpers::TypeTraits<const Gtk::TreeViewColumn*>]' x.cc:8: instantiated from here /usr/include/gtkmm-2.0/glibmm/containerhandle_shared.h:162: error: invalid conversion from `const GtkTreeViewColumn*' to `GtkTreeViewColumn*' /usr/include/gtkmm-2.0/glibmm/containerhandle_shared.h:162: error: initializing argument 1 of `Gtk::TreeViewColumn* Glib::wrap(GtkTreeViewColumn*, bool)' # pkg-config --modversion gtkmm-2.0 2.2.8
Please see: http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch03s05.html and http://www.gtkmm.org/gtkmm2/docs/reference/html/classGlib_1_1ListHandle.html If this is still a problem after using a non-intermediate C++ container, please reopen this bug.
Sorry, I was not explicit enough. The problem is that this TreeView member Glib::ListHandle<const TreeViewColumn*> get_columns() const; returns exactly the type which causes the for loop to fail compiling. So my problem is not with ListHandle per se (though the bug might lie here) but with exactly the type get_columns returns. I can't access any member of this ListHandle (due to constness errors). The program above was the minimal code showing the problem (I did never say that this is reasonable code).
Created attachment 21385 [details] More elaborate test case which makes clear what I originally intended to do
I don't get it - you are still using ListHandle in your test case. Do you have a snippet of test case that use std::list or std::vector instead? Maybe you're helping me to find the solution, but I don't see the problem yet.
I think maybe you uploaded the wrong test case by mistake.
I want is to access columns of a const TreeView. But even if I use a std::list to access the elements (I did not know that this was transparently possible neither do I see any benefits now) the error stays the same: /usr/include/gtkmm-2.0/glibmm/containerhandle_shared.h:162: error: invalid conversion from `const GtkTreeViewColumn*' to `GtkTreeViewColumn*' /usr/include/gtkmm-2.0/glibmm/containerhandle_shared.h:162: error: initializing argument 1 of `Gtk::TreeViewColumn* Glib::wrap(GtkTreeViewColumn*, bool)' ------ Sample program modified by: -typedef Glib::ListHandle<const Gtk::TreeViewColumn*> list_t; +#include <list> +typedef std::list<const Gtk::TreeViewColumn*> list_t; (do I need to reattach it?)
Created attachment 21524 [details] Program which uses std::list for accessing treeview columns (only 1 line changed)
Thanks. Hopefully we can do something about this for 2.4.
Fixed for 2.4 in cvs, including a fix in glibmm. Thanks. I fixed similar methods too.
*** Bug 138578 has been marked as a duplicate of this bug. ***
*** Bug 138581 has been marked as a duplicate of this bug. ***