TreeView - Drag and Drop - Gtk-CRITICAL on drop



Hi,

I've got a problem with one of my applications, it uses a treeview
component, I have tried to implement a drag and drop concept for this
treeview. I have followed the tutorial of Gtkmm's website, but I have got a
problem when I execute my application and I do a drag and drop in this
treeview, when I drop the row I receive :

(main:5585): Gtk-CRITICAL **: gtk_tree_store_get_value: assertion
`iter->stamp == GTK_TREE_STORE (tree_model)->stamp' failed

(main:5585): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE
(value)' failed
Erreur de segmentation

That is a part of my treeview :

/************************************************************
 ** XManagerProjectModel
 ************************************************************/
class TreeModel_Dnd : public Gtk::TreeStore {
protected:
	TreeModel_Dnd();

public:
	/************************************************************
	** ModelColumn
	************************************************************/
	class ModelColumn : public Gtk::TreeModel::ColumnRecord {
	public:
		ModelColumn() { add(name); add(item); add(icon); }
		Gtk::TreeModelColumn<Glib::ustring> name;
		Gtk::TreeModelColumn<XManagerProjectItem*> item;
		Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > icon;
	};
	ModelColumn column;

	static Glib::RefPtr<TreeModel_Dnd> create();

protected:
	//Overridden virtual functions:
	virtual bool row_draggable_vfunc(const Gtk::TreeModel::Path& path) const;
	virtual bool row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest,
					     const Gtk::SelectionData& selection_data) const;
	//virtual void get_value_vfunc(const iterator& iter,int column,
Glib::ValueBase& value) const;
};

TreeModel_Dnd::TreeModel_Dnd() {
	set_column_types(column);
}

Glib::RefPtr<TreeModel_Dnd> TreeModel_Dnd::create() {
	return Glib::RefPtr<TreeModel_Dnd>( new TreeModel_Dnd() );
}

//Make the value of the "draggable" column determine whether this row can be
dragged:
bool TreeModel_Dnd::row_draggable_vfunc(const Gtk::TreeModel::Path& path)
const {
	printf("row_draggable_vfunc\n");
	TreeModel_Dnd* unconstThis = const_cast<TreeModel_Dnd*>(this);
	const_iterator iter = unconstThis->get_iter(path);

	if(iter) {
		Row row = *iter;
		XManagerProjectItem* item = row[column.item];
		return ((item->Type == XManagerProjectItem::SOURCE) || (item->Type ==
XManagerProjectItem::FILE));
	}
	return Gtk::TreeStore::row_draggable_vfunc(path);
}

//Make the value of the "receives drags" column determine whether a row can
be dragged into it:
bool TreeModel_Dnd::row_drop_possible_vfunc(const Gtk::TreeModel::Path&
dest, const Gtk::SelectionData& selection_data) const {
	printf("row_drop_possible_vfunc\n");

	TreeModel_Dnd* unconstThis = const_cast<TreeModel_Dnd*>(this);
	const_iterator iter_dest = unconstThis->get_iter(dest);
	if(iter_dest) {
		Row row = *iter_dest;
		XManagerProjectItem* item = row[column.item];
		return (item->Type == XManagerProjectItem::DIRECTORY);
	}

	return Gtk::TreeStore::row_drop_possible_vfunc(dest,selection_data);
}

/************************************************************
 ** XManagerProject
 ************************************************************/
class XManagerProject : public Gtk::TreeView {
public:
        (...)
	Glib::RefPtr<Gtk::TreeSelection> treeSelection;
	Glib::RefPtr<TreeModel_Dnd> treemodel;
};

/************************************************************
 ** XManagerProject
 ************************************************************/
XManagerProject::XManagerProject(XProject* parent) : /*TreeView(),*/
Parent(parent) {
	treemodel = TreeModel_Dnd::create();
	set_model(treemodel);

	enable_model_drag_source();
	enable_model_drag_dest();

	append_column("Icon",treemodel->column.icon);
	append_column("Name",treemodel->column.name);

        (...)
}


Everything seems to be such as the tutorial ... I do not understand ...
--
View this message in context: http://www.nabble.com/TreeView---Drag-and-Drop---Gtk-CRITICAL-on-drop-t1382711.html#a3713084
Sent from the Gtkmm forum at Nabble.com.




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