Skip to content

Fix write-unsafe VFS refresh when loading templates#2593

Closed
morfidon wants to merge 1 commit intominecraft-dev:devfrom
morfidon:dev
Closed

Fix write-unsafe VFS refresh when loading templates#2593
morfidon wants to merge 1 commit intominecraft-dev:devfrom
morfidon:dev

Conversation

@morfidon
Copy link

@morfidon morfidon commented Mar 14, 2026

closes #2592
Run VFS refresh via Application.invokeAndWait(..., modalityState) instead of calling RefreshQueue.refresh() inside a writeAction.

This preserves the current wizard/dialog modality state and prevents "Write-unsafe context! Model changes are allowed from write-safe contexts only"errors when loading templates on newer IntelliJ Platform versions.

Replace RefreshQueue.refresh() wrapped in writeAction with VirtualFile.refresh() invoked via Application.invokeAndWait(..., modalityState).
This preserves the current wizard/dialog modality state and avoids Write-unsafe context! failures on newer IntelliJ Platform builds.
@DenWav
Copy link
Member

DenWav commented Mar 17, 2026

Thanks for the contribution, I appreciate the time and effort.

Unfortunately this doesn't fix the problem, which I have tried before. You'll find the refresh method on VirtualFile does indeed just end up calling RefreshQueue.refresh(), though, so this really doesn't change anything. To be sure, I did test it, and saw no change.

I believe I have a working fix, though it's a little hacky. I haven't had a ton of time lately, but when I can I will try to revisit this.

@DenWav DenWav closed this Mar 17, 2026
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.

Write-unsafe context!

2 participants