Re: TreeView Question: how does one use TreeModelColumn<enum MyEnum>



Aren't the values declared in your enum Checksum_t in reality just a list of integers? Maybe I'm just dense here, but since that is the case, why not just declare your Gtk::TreeModelColumn as a data type int? I *do* know that the following won't even compile:

enum Checksum_t    {NONE, ADLER32, CRC32, MD5};
Checksum_t ADLER32 = 20;		// int to enum conversions are illegal and will not compile

I'm guessing that your segmentation fault happens because you've managed, by by passing Checksum_t to the Gtk::TreeModelColumn template, to fool the compiler into compiling a statement of code that attempts int to enum conversion. As I said before, I'm probably just dense and don't understand what you're trying to accomplish.

Bob Caryl
Here's what I would like to do:
-------------------------------------------------------
enum Checksum_t    {NONE, ADLER32, CRC32, MD5};

class C_Columns : public Gtk::TreeModel::ColumnRecord {
public:
  Gtk::TreeModelColumn<Checksum_t> m_chksum_type;
  C_Columns(){
     add(m_chksum_type);
  };
 };
-----------------------------------------------------------------------
I run into a segfault when I try to assign a value e.g.
C_Columns Columns;
Checksum_t val = ADLER32;
Glib::RefPtr<Gtk::TreeStore> refSelectedTreeStore;
refSelectedTreeStore.clear();
refSelectedTreeStore = Gtk::TreeStore::create(Columns);
const Gtk::TreeIter & row_iter = refSelectedTreeStore->append();
(*row_iter)[Columns.m_chksum_type] = val; // segfault
---------------------------------------------------------------------
gdb tells me the bad news
from /usr/include/glibmm-2.4/glibmm/value_custom.h:237:

template <class T> inline
void Value<T>::set(const typename Value<T>::CppType& data)
{
  // Assume the value is already default-initialized.  See
value_init_func().
=>  *static_cast<T*>(gobject_.data[0].v_pointer) = data;
}

(gdb) print gobject_
$1 = {g_type = 0, data = {{v_int = 0, v_uint = 0, v_long = 0, v_ulong =
0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer =
0x0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0,
v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
--------------------------------------------------------------------
I.e., the underlying gobject_'s data[] vector hasn't been initialized
(value_init_func() probably hasn't been called).

Enumeration types are the only data types I've difficulty with: all the
other usual built-in C-types are fine, as are "proper" C++ objects.

I'm running a default CentOS 4.3 installation, gtkmm-2.4, gcc 3.4.5.
Does anyone have any suggestions?

Thanks!

Ed Leaver
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




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