Skip to content

Commit 62c560e

Browse files
committed
Fix log
1 parent 199f24f commit 62c560e

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

tools/gdx-teavm-plugin/src/main/kotlin/com/github/xpenatan/gdx/teavm/gradle/GdxTeaVMAutomaticContinuousOutput.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ internal class GdxTeaVMAutomaticContinuousOutput internal constructor(
3535

3636
private var state = State.IDLE
3737
private var owners = 1
38+
private var detachAfterEvent = false
3839

3940
fun arm() {
4041
synchronized(lock) {
@@ -66,7 +67,13 @@ internal class GdxTeaVMAutomaticContinuousOutput internal constructor(
6667

6768
override fun onOutput(event: OutputEvent) {
6869
val forward = synchronized(lock) {
69-
shouldForward(event)
70+
val result = shouldForward(event)
71+
if(detachAfterEvent) {
72+
detachAfterEvent = false
73+
owners = 0
74+
uninstall(this)
75+
}
76+
result
7077
}
7178
if(forward) {
7279
delegate.onOutput(event)
@@ -84,12 +91,14 @@ internal class GdxTeaVMAutomaticContinuousOutput internal constructor(
8491
}
8592
if(text?.contains(GRADLE_CONTINUOUS_WAITING_MESSAGE) == true) {
8693
state = State.IDLE
94+
detachAfterEvent = true
8795
}
8896
return true
8997
}
9098
State.FILTERING -> {
9199
if(text?.contains(GRADLE_CONTINUOUS_WAITING_MESSAGE) == true) {
92100
state = State.IDLE
101+
detachAfterEvent = true
93102
return false
94103
}
95104
if(text?.contains("Change detected, executing build...") == true

tools/gdx-teavm-plugin/src/test/kotlin/com/github/xpenatan/gdx/teavm/gradle/GdxTeaVMWebDevServerTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ class GdxTeaVMWebDevServerTest {
5050
val realRebuild = LogEvent(6L, "test", LogLevel.LIFECYCLE, "real rebuild", null)
5151

5252
output.arm()
53-
listOf(before, transition, duplicateTaskOutput, serverError, waiting, realRebuild).forEach(output::onOutput)
53+
listOf(before, transition, duplicateTaskOutput, serverError, waiting).forEach(output::onOutput)
5454

55+
assertEquals(listOf(before, serverError), forwarded)
56+
assertTrue(uninstalled)
57+
output.onOutput(realRebuild)
5558
assertEquals(listOf(before, serverError, realRebuild), forwarded)
5659
output.close()
5760
assertTrue(uninstalled)

0 commit comments

Comments
 (0)