compose-multiplatform-core icon indicating copy to clipboard operation
compose-multiplatform-core copied to clipboard

fix IllegalArgumentException when re-show a disposed ComposeWindow

Open XYZboom opened this issue 10 months ago • 3 comments

Proposed Changes

  • Move the setUndecoratedSafely extension function to become a member function of ComposeWindow and ComposeDialog.
  • Add document on dispose for ComposeWindow and ComposeDialog.
  • While it is still not possible to reshow a compose window that has already been disposed, it is now possible to set the window decorate state at runtime(see document on dispose).

Testing

Test: Added new unit tests.

Issues Fixed

Fixes: https://github.com/JetBrains/compose-multiplatform/issues/4579

XYZboom avatar Apr 05 '24 13:04 XYZboom

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Apr 05 '24 13:04 google-cla[bot]

Re-show a disposed compose window looks impossible right now, maybe here some other way to re-show a disposed window

XYZboom avatar Apr 06 '24 06:04 XYZboom

Now disposed window is not able to re-show but we can change decorated state of window at runtime. The code below works

fun main() = application {
    var undecorated by remember { mutableStateOf(false) }
    Window(onCloseRequest = {}, undecorated = undecorated) {
        Button(onClick = { undecorated = !undecorated }) {
            Text("Toggle Decorated")
        }
    }
}

Because recreating a window that has already been disposed is generally used to set the window decoration state at runtime, although it is still not possible to reshow a disposed window now, we can call setUndecoratedSafely to set the window decoration state safely at runtime.

XYZboom avatar Apr 06 '24 13:04 XYZboom