Bug 1410 - Assert in DefaultSimulatorImpl breaks Visualizer module
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed, 06 Jun 2012 18:41:58 +0100
changeset 8847 1b229b79d37d
parent 8846 6e874a0fee27
child 8848 9a34e12fab31
Bug 1410 - Assert in DefaultSimulatorImpl breaks Visualizer module
src/visualizer/model/pyviz.cc
src/visualizer/model/pyviz.h
--- a/src/visualizer/model/pyviz.cc	Tue Jun 05 22:46:39 2012 -0700
+++ b/src/visualizer/model/pyviz.cc	Wed Jun 06 18:41:58 2012 +0100
@@ -265,8 +265,11 @@
 PyViz::CallbackStopSimulation ()
 {
   NS_LOG_FUNCTION_NOARGS ();
-  Simulator::Stop (Seconds (0)); // Stop right now
-  m_stop = true;
+  if (m_runUntil <= Simulator::Now ())
+    {
+      Simulator::Stop (Seconds (0)); // Stop right now
+      m_stop = true;
+    }
 }
 
 void
@@ -316,9 +319,9 @@
   // sure we stop at the right time.  Otherwise, simulations with few
   // events just appear to "jump" big chunks of time.
   NS_LOG_LOGIC ("Schedule dummy callback to be called in " << (time - Simulator::Now ()));
+  m_runUntil = time;
   m_stop = false;
-  Simulator::Cancel (m_stopCallbackEvent);
-  m_stopCallbackEvent = Simulator::Schedule (time - Simulator::Now (), &PyViz::CallbackStopSimulation, this);
+  Simulator::ScheduleWithContext (0xffffffff, time - Simulator::Now (), &PyViz::CallbackStopSimulation, this);
 
   Ptr<SimulatorImpl> impl = Simulator::GetImplementation ();
   Ptr<VisualSimulatorImpl> visualImpl = DynamicCast<VisualSimulatorImpl> (impl);
--- a/src/visualizer/model/pyviz.h	Tue Jun 05 22:46:39 2012 -0700
+++ b/src/visualizer/model/pyviz.h	Wed Jun 06 18:41:58 2012 +0100
@@ -220,7 +220,7 @@
   void DoPause (std::string const &message);
 
   bool m_stop;
-  EventId m_stopCallbackEvent;
+  Time m_runUntil;
   void CallbackStopSimulation ();
 };