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

live-preview: Do not fail to render when top level sources are not lo… #6569

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

hunger
Copy link
Member

@hunger hunger commented Oct 15, 2024

…aded

Ths can open one file in VSCode and show the preview. Then you click on another file in the file tree, which will replace the current file.

This replacement invalidates the data stored in the live-previews caches, so it used to render an empty file. Read the data from disc instead -- if that is an option.

…aded

Ths can open one file in VSCode and show the preview. Then you click
on another file in the file tree, which will replace the current file.

This replacement invalidates the data stored in the live-previews caches, so
it used to render an empty file. Read the data from disc instead -- if
that is an option.
@ogoffart
Copy link
Member

is it not wrong to replace the content of the editor that we get from didOpenDocument with the content from the file?
We should only remove from the cache the files that were opened from the file system, not the one opened from the editor.

@hunger
Copy link
Member Author

hunger commented Oct 16, 2024

The only way we get invalidations for files open in the editor is when that editor gets closed. At that point the on-disc file becomes the one we should use.

@ogoffart
Copy link
Member

ah ok.

@ogoffart
Copy link
Member

So closing a tab in slintpad might cause problems then.

@hunger
Copy link
Member Author

hunger commented Oct 16, 2024

It's what happens here: One file is open in the editor and something in int gets previewed. It then gets replaced by a different file. So we get an invalidation request as the original file we are previewing gets closed. That file is obviously a dependency of the current preview, so we try to rerender.

That would work for any but the root file: The compiler loads data for all others from disk as needed, we just need to do that manually for the top-level file. This PR fixes that.

@hunger
Copy link
Member Author

hunger commented Oct 16, 2024

If you close the one with the preview: Probably :-) But you can not close things in slintpad easily.

@hunger hunger merged commit 9449f23 into slint-ui:master Oct 16, 2024
36 checks passed
@hunger hunger deleted the tobias/push-lorwtpxtptys branch October 16, 2024 08:59
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.

2 participants