Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix: do not perform code action if the activity is being destroyed (f…
Browse files Browse the repository at this point in the history
…ixes #950)
  • Loading branch information
itsaky committed May 27, 2023
1 parent 96340f8 commit 30b3946
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ abstract class ProjectHandlerActivity : BaseEditorActivity(), IProjectHandler {
closeProject(false)
}

if (IDELanguageClientImpl.isInitialized()) {
IDELanguageClientImpl.shutdown()
}

super.preDestroy()

if (isDestroying) {

if (IDELanguageClientImpl.isInitialized()) {
IDELanguageClientImpl.shutdown()
}

try {
stopLanguageServers()
} catch (err: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public void performCodeAction(PerformCodeActionParams params) {
}

final var action = params.getAction();
final var activity = activity();
if (activity() == null) {
LOG.error(
"Unable to perform code action",
Expand All @@ -179,6 +180,15 @@ public void performCodeAction(PerformCodeActionParams params) {
return;
}

if (activity.isFinishing()
|| activity.isDestroyed()
|| activity.getSupportFragmentManager().isDestroyed()
|| activity.getSupportFragmentManager().isStateSaved()) {
LOG.error("Cannot perform code action. Activity is in an invalid state.");
// Should we try to show the error message to the user?
return;
}

final var currentEditor = activity().getCurrentEditor();
final var editor = currentEditor != null ? currentEditor.getEditor() : null;

Expand Down

0 comments on commit 30b3946

Please sign in to comment.