From 99b6cbfe6fdc0f7012cf0c89e49e2c71ef4dc79c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 22 Apr 2012 19:13:49 +0000 Subject: Fix crash when showing properties window (fix #828). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4233 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/PropertiesWindow.cpp | 54 ++++++++------------------------------------ src/gui/PropertiesWindow.hpp | 21 ++++------------- 2 files changed, 13 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index a8f1e030..40089ab1 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -34,7 +34,6 @@ namespace GUI { PropertiesWindow::PropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr& xml) : Window(cobject) - , _initialised(false) { xml->get_widget("properties_vbox", _vbox); xml->get_widget("properties_scrolledwindow", _scrolledwindow); @@ -53,33 +52,6 @@ PropertiesWindow::PropertiesWindow(BaseObjectType* cobject, sigc::mem_fun(this, &PropertiesWindow::ok_clicked)); } -void -PropertiesWindow::init() -{ - Forge& forge = _app->forge(); - Gtk::TreeModel::Row row = *_type_choices->append(); - row[_type_cols.type] = forge.Int; - row[_type_cols.choice] = "Int"; - - row = *_type_choices->append(); - row[_type_cols.type] = forge.Float; - row[_type_cols.choice] = "Float"; - - row = *_type_choices->append(); - row[_type_cols.type] = forge.Bool; - row[_type_cols.choice] = "Bool"; - - row = *_type_choices->append(); - row[_type_cols.type] = forge.URI; - row[_type_cols.choice] = "URI"; - - row = *_type_choices->append(); - row[_type_cols.type] = forge.String; - row[_type_cols.choice] = "String"; - - _initialised = true; -} - void PropertiesWindow::reset() { @@ -125,25 +97,17 @@ PropertiesWindow::set_object(SharedPtr model) Gtk::Label* lab = manage( new Gtk::Label(world->rdf_world()->prefixes().qualify(i->first.str()), 0.0, 0.5)); - _table->attach(*lab, 0, 1, n_rows, n_rows + 1, Gtk::FILL|Gtk::SHRINK, Gtk::SHRINK); - - // Column 1: Type - Gtk::ComboBox* combo = manage(new Gtk::ComboBox()); - combo->set_model(_type_choices); - combo->pack_start(_type_cols.choice); - const char path[] = { static_cast(value.type()) - 1 + '0', '\0' }; - combo->set_active(_type_choices->get_iter(path)); - Gtk::Alignment* align = manage(new Gtk::Alignment(0.0, 0.5, 0.0, 1.0)); - align->add(*combo); - _table->attach(*align, 1, 2, n_rows, n_rows + 1, Gtk::FILL|Gtk::SHRINK, Gtk::SHRINK); - - // Column 2: Value - align = manage(new Gtk::Alignment(0.0, 0.5, 1.0, 0.0)); + _table->attach(*lab, 0, 1, n_rows, n_rows + 1, + Gtk::FILL|Gtk::SHRINK, Gtk::SHRINK); + + // Column 1: Value + Gtk::Alignment* align = manage(new Gtk::Alignment(0.0, 0.5, 1.0, 0.0)); Gtk::Widget* value_widget = create_value_widget(i->first, value); if (value_widget) align->add(*value_widget); - _table->attach(*align, 2, 3, n_rows, n_rows + 1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK); - _records.insert(make_pair(i->first, Record(value, combo, align, n_rows))); + _table->attach(*align, 1, 2, n_rows, n_rows + 1, + Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK); + _records.insert(make_pair(i->first, Record(value, align, n_rows))); } _table->show_all(); @@ -263,7 +227,7 @@ PropertiesWindow::value_edited(const Raul::URI& predicate) Forge& forge = _app->forge(); Record& record = r->second; - Raul::Atom::TypeID type = (*record.type_widget->get_active())[_type_cols.type]; + Raul::Atom::TypeID type = record.value.type(); if (type == forge.Int) { Gtk::SpinButton* widget = dynamic_cast(record.value_widget->get_child()); if (!widget) goto bad_type; diff --git a/src/gui/PropertiesWindow.hpp b/src/gui/PropertiesWindow.hpp index 7b3464c4..03babf36 100644 --- a/src/gui/PropertiesWindow.hpp +++ b/src/gui/PropertiesWindow.hpp @@ -48,25 +48,16 @@ public: private: /** Record of a property (row in the table) */ struct Record { - Record(const Raul::Atom& v, Gtk::ComboBox* tw, Gtk::Alignment* vw, int r) - : value(v), type_widget(tw), value_widget(vw), row(r) + Record(const Raul::Atom& v, Gtk::Alignment* vw, int r) + : value(v), value_widget(vw), row(r) {} Raul::Atom value; - Gtk::ComboBox* type_widget; Gtk::Alignment* value_widget; int row; }; - /** Columns for type combo in treeview */ - class TypeColumns : public Gtk::TreeModel::ColumnRecord { - public: - TypeColumns() { add(type); add(choice); } - - Gtk::TreeModelColumn type; - Gtk::TreeModelColumn choice; - }; - - Gtk::Widget* create_value_widget(const Raul::URI& uri, const Raul::Atom& value); + Gtk::Widget* create_value_widget(const Raul::URI& uri, + const Raul::Atom& value); void init(); void reset(); @@ -83,9 +74,6 @@ private: typedef std::map Records; Records _records; - TypeColumns _type_cols; - Glib::RefPtr _type_choices; - SharedPtr _model; sigc::connection _property_connection; Gtk::VBox* _vbox; @@ -94,7 +82,6 @@ private: Gtk::Button* _cancel_button; Gtk::Button* _apply_button; Gtk::Button* _ok_button; - bool _initialised : 1; }; } // namespace GUI -- cgit v1.2.1