@@ -20,13 +20,16 @@ class HeadlessChildModel (parentWorkspace: AbstractWorkspace, path: String, mode
2020 world,
2121 new org.nlogo.compile.Compiler (if (Version .is3D) NetLogoThreeDDialect else NetLogoLegacyDialect ),
2222 new org.nlogo.render.Renderer (world),
23- new org.nlogo.sdm.AggregateManagerLite ,
24- null ) {
23+ new org.nlogo.sdm.AggregateManagerLite ) {
2524
2625 override def sendOutput (oo : OutputObject , toOutputArea : Boolean ): Unit = {
27- frame.foreach { f => onEDT {
28- new org.nlogo.window.Events .OutputEvent (false , oo, false , ! toOutputArea, System .currentTimeMillis).raise(f)
29- }}
26+ if (LevelSpace .isHeadless) {
27+ workspace.sendOutput(oo, toOutputArea)
28+ } else {
29+ frame.foreach { f => onEDT {
30+ new org.nlogo.window.Events .OutputEvent (false , oo, false , ! toOutputArea, System .currentTimeMillis).raise(f)
31+ }}
32+ }
3033 }
3134
3235 override def runtimeError (owner : JobOwner , context : Context , instruction : Instruction , ex : Exception ): Unit = {
@@ -54,12 +57,14 @@ class HeadlessChildModel (parentWorkspace: AbstractWorkspace, path: String, mode
5457 scheduledRepaint.setRepeats(false )
5558 // Since we never block on painting child models, we don't care if we have a world lock or not.
5659 override def updateDisplay (ignored : Boolean ): Unit = {
57- frame.foreach { f =>
58- if (f.isVisible && ! scheduledRepaint.isRunning) {
59- // Not that if we don't max(0) here, the conversion to int can underflow
60- val nextRepaint = (minTimeBetweenRepaints - timeSinceLastRepaint).max(0 ).toInt
61- scheduledRepaint.setDelay(nextRepaint)
62- scheduledRepaint.start()
60+ if (! LevelSpace .isHeadless) {
61+ frame.foreach { f =>
62+ if (f.isVisible && ! scheduledRepaint.isRunning) {
63+ // Not that if we don't max(0) here, the conversion to int can underflow
64+ val nextRepaint = (minTimeBetweenRepaints - timeSinceLastRepaint).max(0 ).toInt
65+ scheduledRepaint.setDelay(nextRepaint)
66+ scheduledRepaint.start()
67+ }
6368 }
6469 }
6570 }
@@ -76,7 +81,8 @@ class HeadlessChildModel (parentWorkspace: AbstractWorkspace, path: String, mode
7681 workspace.requestDisplayUpdate(false )
7782 }
7883
79- def isVisible : Boolean = frame.exists(_.isVisible)
84+ def isVisible : Boolean =
85+ ! LevelSpace .isHeadless && frame.exists(_.isVisible)
8086
8187 def setSpeed (d : Double ): Unit = {}
8288
0 commit comments