Skip to content

Commit 92b5ee9

Browse files
committed
Disposable -> Job
1 parent 0d04c0c commit 92b5ee9

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

durian-swt/src/main/java/com/diffplug/common/swt/Shells.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import com.diffplug.common.swt.os.WS
2121
import com.diffplug.common.tree.TreeIterable
2222
import com.diffplug.common.tree.TreeQuery
2323
import com.diffplug.common.tree.TreeStream
24-
import io.reactivex.disposables.Disposable
25-
import io.reactivex.disposables.Disposables
24+
import kotlinx.coroutines.Job
2625
import org.eclipse.swt.SWT
2726
import org.eclipse.swt.graphics.Image
2827
import org.eclipse.swt.graphics.Point
@@ -36,7 +35,7 @@ import java.util.*
3635

3736
/** A fluent builder for creating SWT [Shell]s. */
3837
class Shells private constructor(private val style: Int, private val coat: Coat) {
39-
private var title: String = ""
38+
private var title: String? = null
4039
private var image: Image? = null
4140
private var alpha = SWT.DEFAULT
4241
private val size = Point(SWT.DEFAULT, SWT.DEFAULT)
@@ -434,17 +433,19 @@ class Shells private constructor(private val style: Int, private val coat: Coat)
434433

435434
/** Prevents the given shell from closing without prompting. Returns a Subscription which can cancel this blocking. */
436435
@JvmStatic
437-
fun confirmClose(shell: Shell, title: String, question: String, runOnClose: Runnable): Disposable {
436+
fun confirmClose(shell: Shell, title: String, question: String, runOnClose: Runnable): Job {
438437
val listener = Listener { e: Event ->
439438
e.doit = SwtMisc.blockForQuestion(title, question, shell)
440439
if (e.doit) {
441440
runOnClose.run()
442441
}
443442
}
444443
shell.addListener(SWT.Close, listener)
445-
return Disposables.fromRunnable {
446-
SwtExec.immediate().guardOn(shell).execute {
447-
shell.removeListener(SWT.Close, listener)
444+
return Job().apply {
445+
invokeOnCompletion {
446+
SwtExec.immediate().guardOn(shell).execute {
447+
shell.removeListener(SWT.Close, listener)
448+
}
448449
}
449450
}
450451
}

durian-swt/src/test/java/com/diffplug/common/swt/SwtExecProfile.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
import com.diffplug.common.debug.JuxtaProfiler;
2121
import com.diffplug.common.debug.LapTimer;
2222
import com.diffplug.common.rx.Rx;
23-
import io.reactivex.disposables.Disposable;
2423
import java.util.LinkedHashMap;
2524
import java.util.Map;
2625
import java.util.concurrent.RejectedExecutionException;
2726
import java.util.function.Consumer;
27+
import kotlinx.coroutines.Job;
2828
import kotlinx.coroutines.flow.MutableSharedFlow;
2929
import org.eclipse.swt.widgets.Display;
3030
import org.eclipse.swt.widgets.Widget;
@@ -137,7 +137,7 @@ public void run(Widget guard) {
137137
toProfile.forEach((name, underTest) -> {
138138
profiler.addTest(name, new JuxtaProfiler.InitTimedCleanup(LapTimer.createNanoWrap2Sec()) {
139139
MutableSharedFlow<Integer> subject;
140-
Disposable sub;
140+
Job sub;
141141

142142
@Override
143143
protected void init() throws Throwable {
@@ -152,7 +152,7 @@ protected void timed() throws Throwable {
152152

153153
@Override
154154
protected void cleanup() throws Throwable {
155-
sub.dispose();
155+
sub.cancel(null);
156156
subject = null;
157157
sub = null;
158158
}

0 commit comments

Comments
 (0)