Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix IllegalArgumentException when re-show a disposed ComposeWindow #1240

Open
wants to merge 2 commits into
base: jb-main
Choose a base branch
from

Conversation

XYZboom
Copy link

@XYZboom XYZboom commented Apr 5, 2024

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: JetBrains/compose-multiplatform#4579

Copy link

google-cla bot commented Apr 5, 2024

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.

@XYZboom XYZboom marked this pull request as draft April 6, 2024 05:59
@XYZboom
Copy link
Author

XYZboom commented Apr 6, 2024

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

@XYZboom XYZboom force-pushed the dev-desktop-pack-after-dispose branch from ba0dfd3 to f53960b Compare April 6, 2024 13:35
call ComposeWindow.super.dispose before calling setUndecorated
@XYZboom XYZboom force-pushed the dev-desktop-pack-after-dispose branch from f53960b to a50b457 Compare April 6, 2024 13:41
@XYZboom
Copy link
Author

XYZboom commented Apr 6, 2024

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 XYZboom marked this pull request as ready for review April 6, 2024 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IllegalArgumentException when re-show a disposed ComposeWindow
1 participant