Skip to content

Commit

Permalink
Merge pull request #4134 from jtulach/jtulach/DontCallSwing
Browse files Browse the repository at this point in the history
Removing isEventDispatchThread - it causes problems in headless env
  • Loading branch information
ebarboni committed May 23, 2022
2 parents aaa9fca + 739a923 commit 81a902f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Expand Up @@ -171,7 +171,7 @@ ThreadMXBean getThreadMXBean() {
@Override
@Messages("Save_Progress=Saving snapshot")
void openProgress(final int steps) {
if (EventQueue.isDispatchThread()) {
if (isDispatchThread()) {
// log warnining
return;
}
Expand All @@ -180,7 +180,7 @@ void openProgress(final int steps) {

@Override
void closeProgress() {
if (EventQueue.isDispatchThread()) {
if (isDispatchThread()) {
return;
}
progress.finish();
Expand All @@ -189,12 +189,16 @@ void closeProgress() {

@Override
void progress(int i) {
if (EventQueue.isDispatchThread()) {
if (isDispatchThread()) {
return;
}
if (progress != null) {
progress.progress(i);
}
}


@Override
boolean isDispatchThread() {
return EventQueue.isDispatchThread();
}
}
Expand Up @@ -27,7 +27,6 @@
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.annotations.common.NonNull;

Expand Down Expand Up @@ -227,7 +226,7 @@ private synchronized void stopSampling(boolean cancel, DataOutputStream dos) {
if (cancel || samples < 1) {
return;
}
if (SwingUtilities.isEventDispatchThread()) throw new IllegalStateException("sampling cannot be stopped from EDT"); //NOI18N
if (isDispatchThread()) throw new IllegalStateException("sampling cannot be stopped from EDT"); //NOI18N
double average = sum / samples;
double std_deviation = Math.sqrt(devSquaresSum / samples);
boolean writeCommand = dos != null;
Expand Down Expand Up @@ -255,4 +254,8 @@ private synchronized void stopSampling(boolean cancel, DataOutputStream dos) {
samplesStream = null;
}
}

boolean isDispatchThread() {
return false;
}
}

0 comments on commit 81a902f

Please sign in to comment.