TreeStore behavior with -malign-double
- From: Bryan Silverthorn <bsilvert arlut utexas edu>
- To: gtkmm-list gnome org
- Subject: TreeStore behavior with -malign-double
- Date: Tue, 11 Jul 2006 15:02:58 -0500
I've attached a small test case (TreeViewTest.cc) that breaks when
compiled with -malign-double, using gtkmm-2.4.11 and 2.8.8 under RHEL
and FC5 respectively on i386:
"
$ g++ TreeViewTest.cc `pkg-config --cflags --libs gtkmm-2.4` -o TreeViewTest
$ ./TreeViewTest
hidden data is stored correctly.
$ g++ -malign-double TreeViewTest.cc `pkg-config --cflags --libs
gtkmm-2.4` -o TreeViewTest
$ ./TreeViewTest
hidden data has gone missing!
"
To summarize: TreeStore columns with custom data types do not correctly
store their values. I'm assuming that gtk+ and gtkmm were not compiled
with -malign-double, and that the problem is therefore a direct result
of the binary compatibility issues introduced by -malign-double.
So this issue is probably more of a (potentially quite time-wasting)
gotcha than a bug per se, but it would be nice if it wasn't an issue at
all---or was at least documented and/or checked for at either compile or
run time.
--
Bryan Silverthorn <bsilvert arlut utexas edu>
// TreeViewTest.cc
// simple demonstration of confusing TreeStore behavior;
// compare when compiled with and without -malign-double
#include <string>
#include <iostream>
#include <gtkmm.h>
using namespace std;
class DerivedTreeView : public Gtk::TreeView
{
public:
DerivedTreeView()
{
// attach store to view
Glib::RefPtr<Gtk::TreeStore> store = Gtk::TreeStore::create(_columns);
this->set_model(store);
this->append_column("Text", _columns.text);
// add a row of data
Gtk::TreeModel::iterator rowiter = store->append();
(*rowiter)[_columns.text] = "row of data";
(*rowiter)[_columns.hidden] = new string("stored correctly.");
// make sure that the hidden data was stored
string* hidden = rowiter->get_value(_columns.hidden);
if(hidden)
cout << "hidden data is " << *hidden << "\n";
else
cout << "hidden data has gone missing!\n";
}
private:
struct _ColumnsRecord : public Gtk::TreeModelColumnRecord
{
_ColumnsRecord()
{
this->add(text);
this->add(hidden);
}
Gtk::TreeModelColumn<Glib::ustring> text;
Gtk::TreeModelColumn<string*> hidden;
};
_ColumnsRecord _columns;
};
int main(int argc, char** argv)
{
Gtk::Main gtk(argc, argv);
Gtk::Window window;
DerivedTreeView tree;
window.add(tree);
tree.show();
window.show();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]