Skip to content

Commit e3a3ed0

Browse files
travkin79Copilot
andcommitted
Fix UserPreferenceService.unbindChatView() thread safety
Wrap the chatViewSideEffect disposal in ensureRealm() to guarantee it runs on the correct data binding Realm thread, preventing potential InvalidThreadAccessException when unbinding from a non-UI thread. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0408019 commit e3a3ed0

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/UserPreferenceService.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,12 @@ public void bindChatView(ChatView chatView) {
503503
* Unbind the currently bound chat view if any.
504504
*/
505505
public void unbindChatView() {
506-
if (chatViewSideEffect != null) {
507-
chatViewSideEffect.dispose();
508-
chatViewSideEffect = null;
509-
}
506+
ensureRealm(() -> {
507+
if (chatViewSideEffect != null) {
508+
chatViewSideEffect.dispose();
509+
chatViewSideEffect = null;
510+
}
511+
});
510512
}
511513

512514
/**

0 commit comments

Comments
 (0)