diff --git a/src/resources_widget.cc b/src/resources_widget.cc index c69d2a8..f638983 100644 --- a/src/resources_widget.cc +++ b/src/resources_widget.cc @@ -95,12 +95,12 @@ ResourcesWidget::get_selected_key(unsigned int& selection) Resource* ResourcesWidget::get_selected_resource() { - unsigned int key; - if(get_selected_key(key)) + TreeModel::iterator it = get_selection()->get_selected(); + + if(it) { - Simulation& sim = Simulation::get_instance(); - const Environment& env = sim.get_history().get_environment_at(sim.get_front()); - return env.get_resources().find(key)->second; + const void* r_handle = (*it)[_handles_column]; + return reinterpret_cast(const_cast(r_handle)); } else return NULL; @@ -111,7 +111,8 @@ ResourcesWidget::on_button_press_event(GdkEventButton* event) { TreeView::on_button_press_event(event); - if((event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) + if((Simulation::get_instance().get_state() == Simulation::state_stopped) && + (event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) { RefPtr action_group = Gtk::ActionGroup::create(); @@ -127,12 +128,11 @@ ResourcesWidget::on_button_press_event(GdkEventButton* event) RefPtr UIManager = Gtk::UIManager::create(); UIManager->insert_action_group(action_group); - unsigned int selection; Glib::ustring ui_info = "" " " " "; - if(get_selected_key(selection)) + if(get_selected_resource() != NULL) ui_info += " " " " @@ -157,8 +157,7 @@ void ResourcesWidget::update(const History& history) { typedef Environment::Resources::const_iterator ResourceIt; - const Environment::Resources& resources = - Simulation::get_instance().get_history().get_last_environment().get_resources(); + const Environment::Resources& resources = history.get_last_environment().get_resources(); _model->clear(); @@ -279,9 +278,11 @@ ResourcesWidget::_on_cell_name_data(Gtk::CellRenderer* cr, unsigned int key = (*it)[_key_column]; Simulation& sim = Simulation::get_instance(); - const Environment& env = sim.get_history().get_environment_at(sim.get_front()); - Resource& resource = *(env.get_resources().find(key)->second); + const Environment& env = sim.get_history().get_last_environment(); + const void* r_handle = (*it)[_handles_column]; + Resource& resource = *reinterpret_cast(const_cast(r_handle)); + std::ostringstream oss; oss << "" << resource.get_name() << "\n"; diff --git a/src/schedulables_tree_widget.cc b/src/schedulables_tree_widget.cc index f2d8965..7e9efbb 100644 --- a/src/schedulables_tree_widget.cc +++ b/src/schedulables_tree_widget.cc @@ -341,6 +341,7 @@ SchedulablesTreeWidget::update(const History& history) // We can clear it now, since until next update we won't need it. _expanded_rows.clear(); + } void