compose-multiplatform-core
compose-multiplatform-core copied to clipboard
fix IllegalArgumentException when re-show a disposed ComposeWindow
Proposed Changes
- Move the
setUndecoratedSafelyextension function to become a member function ofComposeWindowandComposeDialog. - Add document on
disposeforComposeWindowandComposeDialog. - 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
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.
Re-show a disposed compose window looks impossible right now, maybe here some other way to re-show a disposed window
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.