@@ -21,8 +21,7 @@ import com.diffplug.common.swt.os.WS
2121import com.diffplug.common.tree.TreeIterable
2222import com.diffplug.common.tree.TreeQuery
2323import com.diffplug.common.tree.TreeStream
24- import io.reactivex.disposables.Disposable
25- import io.reactivex.disposables.Disposables
24+ import kotlinx.coroutines.Job
2625import org.eclipse.swt.SWT
2726import org.eclipse.swt.graphics.Image
2827import org.eclipse.swt.graphics.Point
@@ -36,7 +35,7 @@ import java.util.*
3635
3736/* * A fluent builder for creating SWT [Shell]s. */
3837class 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 }
0 commit comments