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 dialog InvalidOperationException #434

Merged
merged 1 commit into from
Oct 15, 2023

Conversation

duydang2311
Copy link
Contributor

This PR should close #433. I have changed the response handler from SetResult to TrySetResult to make it safe from the task already completed exception.
However, a better fix might be to not let the response handler executes the second time by destroying the VisibleDialog component when the player responds or disconnects. There are two related callbacks: OnPlayerDisconnect and OnPlayerDialogResponse. But I'm not sure about the execution order of these two callbacks.

@ikkentim
Copy link
Owner

However, a better fix might be to not let the response handler executes the second time by destroying the VisibleDialog component when the player responds or disconnects. There are two related callbacks: OnPlayerDisconnect and OnPlayerDialogResponse. But I'm not sure about the execution order of these two callbacks.

It might be a good idea to try this out. To try that, edit the OnPlayerDisconnect event handler and destroy the component there, after it is being handled. player.Destroy();

https://github.com/ikkentim/SampSharp/blob/master/src/SampSharp.Entities/SAMP/Dialogs/DialogSystem.cs#L27

@duydang2311
Copy link
Contributor Author

I also think it's better to do that. OnPlayerDisconnect event handler now should destroy the VisibleDialog component too.

@ikkentim
Copy link
Owner

Thank you!

@ikkentim ikkentim merged commit c09a54e into ikkentim:master Oct 15, 2023
1 check passed
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.

Exception on player disconnect/crash when a Dialog window is active
2 participants