Re: boost::shared_ptr<T> and Gtk::TreeModelColumn<T>
- From: Paul Davis <paul linuxaudiosystems com>
- To: Murray Cumming <murrayc murrayc com>
- Cc: gtkmm-list gnome org
- Subject: Re: boost::shared_ptr<T> and Gtk::TreeModelColumn<T>
- Date: Tue, 19 Sep 2006 16:12:19 -0400
On Mon, 2006-09-18 at 23:08 +0200, Murray Cumming wrote:
> On Mon, 2006-09-18 at 16:26 -0400, Paul Davis wrote:
> > any opinions on the best way to have:
> >
> > Gtk::TreeModelColumn<boost::shared_ptr<T> >
> >
> > at the moment, g++ appears to pick the void* partial specialization of
> > TreeModelColumn,
>
> Are you sure that there is void* partial specialization? What exactly
> does it look like?
well, gdb let me know that this was going on, and the stack trace showed
we were in Value<void*> ... not really a partial specialization.
> > which leads to problems later (glib complains that the
> > object is not actually a G_TYPE_POINTER etc). i have considered
> > implementing another partial specialization, but I am not sure it will
> > solve the issue. any thoughts?
>
> It works for RefPtr and for other random types. TreeModelColumn should
> generate a custom gtype (via Glib::Value) to identify the type inside
> TreeView so you shouldn't get that warning theoretically.
>
> A little test case might help us figure it out. You could try it with
> just a shared_ptr<int>, for instance.
i did that. it compiles but does not run. changing the shared_ptr<int>
back to just int corrects all issues. the behaviour is different than i
previously described, probably or possibly because of different versions
of gtkmm. i tried this code with 2.8 and got lots of errors of the form:
unable to set property `text' of type `gchar array' from value of
type 'glibmm__CustomBoxed_N5boost10shared_ptrIiEE'
--p
#include <boost/shared_ptr.hpp>
#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <gtkmm/treeview.h>
#include <gtkmm/liststore.h>
using namespace Gtk;
using namespace std;
int
main (int argc, char* argv[])
{
Main app (&argc, &argv);
Window win;
TreeView view;
struct Columns : public TreeModel::ColumnRecord {
Columns () {
add (first);
add (second);
}
TreeModelColumn<bool> first;
TreeModelColumn<boost::shared_ptr<int> > second;
};
Columns columns;
Glib::RefPtr<ListStore> model = ListStore::create (columns);
view.set_model (model);
view.append_column ("A", columns.first);
view.append_column ("B", columns.second);
view.set_headers_visible (true);
view.set_size_request (100, -1);
win.add (view);
win.show_all ();
for (int i = 0; i < 20; ++i) {
TreeModel::Row child = *(model->append());
child[columns.first] = i%2;
child[columns.second] = boost::shared_ptr<int> (new int (i));
}
app.run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]