- Manage exceptions into SimulationController.
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@966 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
3f314f6225
commit
a4bde96a7b
|
@ -28,6 +28,11 @@
|
||||||
#include "gui_builder.hh"
|
#include "gui_builder.hh"
|
||||||
#include "graphical_preferences_editor.hh"
|
#include "graphical_preferences_editor.hh"
|
||||||
|
|
||||||
|
#include "backend/cpu_policy_exception.hh"
|
||||||
|
#include "backend/malformed_policy_exception.hh"
|
||||||
|
#include "backend/null_policy_exception.hh"
|
||||||
|
#include "backend/user_interrupt_exception.hh"
|
||||||
|
|
||||||
#include "backend/cpu_policies_gatekeeper.hh"
|
#include "backend/cpu_policies_gatekeeper.hh"
|
||||||
#include "backend/cpu_policy.hh"
|
#include "backend/cpu_policy.hh"
|
||||||
#include "backend/cpu_policy_manager.hh"
|
#include "backend/cpu_policy_manager.hh"
|
||||||
|
@ -38,6 +43,7 @@
|
||||||
#include "backend/serializer.hh"
|
#include "backend/serializer.hh"
|
||||||
|
|
||||||
#include <gdkmm/pixbuf.h>
|
#include <gdkmm/pixbuf.h>
|
||||||
|
#include <glibmm/markup.h>
|
||||||
#include <glibmm/timer.h>
|
#include <glibmm/timer.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/aboutdialog.h>
|
#include <gtkmm/aboutdialog.h>
|
||||||
|
@ -329,7 +335,9 @@ SimulationController::on_simulation_run()
|
||||||
_toolbt_stop->set_sensitive(true);
|
_toolbt_stop->set_sensitive(true);
|
||||||
|
|
||||||
_break_requested = false;
|
_break_requested = false;
|
||||||
_sim.run();
|
// Used instead of simply calling "_sim.run()" to
|
||||||
|
// have exception handling only in one place:
|
||||||
|
run_simulation_adaptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -405,7 +413,55 @@ SimulationController::update(const Simulation& simulation)
|
||||||
bool
|
bool
|
||||||
SimulationController::run_simulation_adaptor()
|
SimulationController::run_simulation_adaptor()
|
||||||
{
|
{
|
||||||
|
using Gtk::MessageDialog;
|
||||||
|
using namespace Glib;
|
||||||
|
|
||||||
if(!_break_requested)
|
if(!_break_requested)
|
||||||
|
try
|
||||||
|
{
|
||||||
_sim.run();
|
_sim.run();
|
||||||
|
}
|
||||||
|
catch(const UserInterruptException& uie)
|
||||||
|
{
|
||||||
|
// Show the user a dialog
|
||||||
|
MessageDialog diag(_("<b>The selected user CPU policy stopped before returning:</b>\n") + Markup::escape_text(uie.what()),
|
||||||
|
true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||||
|
diag.run();
|
||||||
|
}
|
||||||
|
catch(const MalformedPolicyException& mpe)
|
||||||
|
{
|
||||||
|
// Show user a dialog
|
||||||
|
MessageDialog diag(_("<b>The selected user CPU policy was malformed and didn't run:</b>\n") + Markup::escape_text(mpe.what()),
|
||||||
|
true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||||
|
diag.run();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Deactivate the policy
|
||||||
|
_sim.set_policy(NULL);
|
||||||
|
}
|
||||||
|
catch(const CPUPolicyException& cpe)
|
||||||
|
{
|
||||||
|
// Fatal error. We should never get here.
|
||||||
|
std::cerr << _(" [EE] Fatal error. Impossible to deactivate the policy in ") << __FILE__ << ":" << __LINE__
|
||||||
|
<< std::endl << _(" [EE] ") << cpe.what() << std::endl;
|
||||||
|
;
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(const NullPolicyException& npe)
|
||||||
|
{
|
||||||
|
MessageDialog diag(_("<b>No active policy selected:</b>\n") + Markup::escape_text(npe.what()),
|
||||||
|
true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||||
|
diag.run();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(const CPUPolicyException& cpe)
|
||||||
|
{
|
||||||
|
MessageDialog diag(_("<b>Unexpected error</b>:\n") + Markup::escape_text(cpe.what()),
|
||||||
|
true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||||
|
diag.run();
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue