@@ -3226,7 +3226,9 @@ public void run() {
32263226
32273227 // Timer to display a message if a debugging step takes a long time
32283228 _debugStepTimer = new Timer (DEBUG_STEP_TIMER_VALUE , new ActionListener () {
3229- public void actionPerformed (ActionEvent e ) { _model .printDebugMessage ("Stepping ..." ); }
3229+ public void actionPerformed (ActionEvent e ) {
3230+ if (!_model .getDebugger ().isAutomaticTraceEnabled ()) { _model .printDebugMessage ("Stepping ..." ); }
3231+ }
32303232 });
32313233 _debugStepTimer .setRepeats (false );
32323234
@@ -5766,40 +5768,52 @@ void debuggerResume() throws DebugException {
57665768
57675769 /** Automatically traces through the entire program with a defined rate for stepping into each line of code*/
57685770 void debuggerAutomaticTrace () {
5771+ _log .log ("debuggerAutomaticTrace(): isDebuggerReady() = " +isDebuggerReady ());
57695772 if (isDebuggerReady ()) {
57705773 if (!_model .getDebugger ().isAutomaticTraceEnabled ()) {
5771- try {
5772- int rate = DrJava .getConfig ().getSetting (OptionConstants .AUTO_STEP_RATE );
5773-
5774- _automaticTraceTimer = new Timer (rate , new ActionListener () {
5775- public void actionPerformed (ActionEvent e ) {
5776- _debugStepTimer .stop ();
5777- if (_model .getDebugger ().isAutomaticTraceEnabled ()) {
5778- // hasn't been disabled in the meantime
5779- debuggerStep (Debugger .StepType .STEP_INTO );
5780- // _debugStepTimer.restart(); // _debugStepTimer prints "Stepping..." when timer expires
5781- }
5782- }
5783- });
5784- _automaticTraceTimer .setRepeats (false );
5785- _model .getDebugger ().setAutomaticTraceEnabled (true );
5786- _debugPanel .setAutomaticTraceButtonText ();
5787- debuggerStep (Debugger .StepType .STEP_INTO );
5788- _debugStepTimer .stop ();
5789- }
5790- catch (IllegalStateException ise ) {
5791- /* This may happen if the user if stepping very frequently, and is even more likely if they are using both
5792- * hotkeys and UI buttons. Ignore it in this case. Hopefully, there are no other situations where the user
5793- * can be trying to step while there are no suspended threads. */
5794- }
5774+ enableAutomaticTrace ();
57955775 }
57965776 else {
5797- _model .getDebugger ().setAutomaticTraceEnabled (false );
5798- _debugPanel .setAutomaticTraceButtonText ();
5799- if (_automaticTraceTimer != null ) _automaticTraceTimer .stop ();
5777+ disableAutomaticTrace ();
58005778 }
58015779 }
58025780 }
5781+
5782+ /** Enable automatic trace. Assumes that the debugger is ready. */
5783+ private void enableAutomaticTrace () {
5784+ try {
5785+ int rate = DrJava .getConfig ().getSetting (OptionConstants .AUTO_STEP_RATE );
5786+
5787+ _automaticTraceTimer = new Timer (rate , new ActionListener () {
5788+ public void actionPerformed (ActionEvent e ) {
5789+ _debugStepTimer .stop ();
5790+ if (_model .getDebugger ().isAutomaticTraceEnabled ()) {
5791+ // hasn't been disabled in the meantime
5792+ debuggerStep (Debugger .StepType .STEP_INTO );
5793+ // _debugStepTimer.restart(); // _debugStepTimer prints "Stepping..." when timer expires
5794+ }
5795+ }
5796+ });
5797+ _automaticTraceTimer .setRepeats (false );
5798+ _model .getDebugger ().setAutomaticTraceEnabled (true );
5799+ _debugPanel .setAutomaticTraceButtonText ();
5800+ debuggerStep (Debugger .StepType .STEP_INTO );
5801+ _debugStepTimer .stop ();
5802+ }
5803+ catch (IllegalStateException ise ) {
5804+ /* This may happen if the user if stepping very frequently, and is even more likely if they are using both
5805+ * hotkeys and UI buttons. Ignore it in this case. Hopefully, there are no other situations where the user
5806+ * can be trying to step while there are no suspended threads. */
5807+ }
5808+ }
5809+
5810+ /** Disable the automatic trace. Assumes that the debugger is ready. */
5811+ private void disableAutomaticTrace () {
5812+ _log .log ("disableAutomaticTrace(): isDebuggerReady() = " +isDebuggerReady ());
5813+ _model .getDebugger ().setAutomaticTraceEnabled (false );
5814+ _debugPanel .setAutomaticTraceButtonText ();
5815+ if (_automaticTraceTimer != null ) _automaticTraceTimer .stop ();
5816+ }
58035817
58045818 /** Steps in the debugger. */
58055819 void debuggerStep (Debugger .StepType type ) {
@@ -8615,7 +8629,7 @@ private class UIDebugListener implements DebugListener {
86158629 /* Must be executed in evevt thread.*/
86168630 public void debuggerStarted () { EventQueue .invokeLater (new Runnable () { public void run () { showDebugger (); } }); }
86178631
8618- /* Must be executed in eventt thread.*/
8632+ /* Must be executed in event thread.*/
86198633 public void debuggerShutdown () {
86208634 EventQueue .invokeLater (new Runnable () {
86218635 public void run () {
@@ -8630,7 +8644,9 @@ public void run() {
86308644 public void stepRequested () {
86318645 // Print a message if step takes a long time; timer must be restarted on every step (automatic trace)
86328646 synchronized (_debugStepTimer ) {
8633- if (! _automaticTraceTimer .isRunning ()) {
8647+ // only print the stepping message if we're not doing automatic trace
8648+ // i.e. do it if the _automaticTraceTimer is null, or if the _automaticTraceTimer is not running
8649+ if ((_automaticTraceTimer == null ) || (! _automaticTraceTimer .isRunning ())) {
86348650 if (! _debugStepTimer .isRunning ()) _debugStepTimer .start ();
86358651 else _debugStepTimer .restart ();
86368652 }
@@ -9080,6 +9096,8 @@ public void focusOnDefinitionsPane() {
90809096 }
90819097
90829098 public void interactionStarted () {
9099+ _log .log ("interactionStarted()" );
9100+ disableAutomaticTrace ();
90839101 _interactionsPane .endCompoundEdit ();
90849102 _disableInteractionsPane ();
90859103 _guiAvailabilityNotifier .unavailable (GUIAvailabilityListener .ComponentType .INTERACTIONS );
0 commit comments