- Fixed bug causing crash on adding a resource after simulation is terminated. A workaround was used, it was caused by Simulation::get_front() returning a wrong value.
- Other minor improvements to the ResourceWidget git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@988 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
d570314405
commit
f617c51a87
|
@ -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<Resource*>(const_cast<void*>(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<ActionGroup> action_group = Gtk::ActionGroup::create();
|
||||
|
||||
|
@ -127,12 +128,11 @@ ResourcesWidget::on_button_press_event(GdkEventButton* event)
|
|||
RefPtr<UIManager> UIManager = Gtk::UIManager::create();
|
||||
UIManager->insert_action_group(action_group);
|
||||
|
||||
unsigned int selection;
|
||||
Glib::ustring ui_info =
|
||||
"<ui>"
|
||||
" <popup name='PopupMenu'>"
|
||||
" <menuitem action='AddResource'/>";
|
||||
if(get_selected_key(selection))
|
||||
if(get_selected_resource() != NULL)
|
||||
ui_info +=
|
||||
" <separator/>"
|
||||
" <menuitem action='EditResource'/>"
|
||||
|
@ -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,8 +278,10 @@ 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<Resource*>(const_cast<void*>(r_handle));
|
||||
|
||||
std::ostringstream oss;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue