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 remembers painter twice and break the cache #303

Merged
merged 2 commits into from
Feb 17, 2024

Conversation

devkanro
Copy link
Collaborator

  1. Move the InDebugMode property to foundation module.
  2. Rename the utils in foundation to util
  3. Fix remembers painter twice to break the cache, see the comments below.

@@ -166,7 +166,7 @@ public class ResourcePainterProvider(
loadSvgPainter(inputStream, scope)
}
},
rememberAction = { remember(url, scope.density) { it } },
paintAction = { it },
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not remember painter here, because we have already the cache here.

Before:
截屏2024-02-17 19 30 59

After:
截屏2024-02-17 19 31 57

It only happened with first default selected icon button

@@ -205,7 +205,7 @@ public class ResourcePainterProvider(
loadingAction = { resourceUrl ->
resourceUrl.openStream().use { loadXmlImageVector(InputSource(it), scope) }
},
rememberAction = { rememberVectorPainter(it) },
paintAction = { rememberVectorPainter(it) },
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can still remember the vector because vector self is a key.

)

@Composable
private fun <T> tryLoadingResource(
url: URL,
loadingAction: (URL) -> T,
rememberAction: @Composable (T) -> Painter,
paintAction: @Composable (T) -> Painter,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I rename the rememberAction to paintAction, it more seems like a action to convert T to a painter

@devkanro devkanro changed the title Fix remembers painter twice to break the cache Fix remembers painter twice and break the cache Feb 17, 2024
Copy link
Collaborator

@rock3r rock3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rock3r rock3r merged commit d587c1f into JetBrains:main Feb 17, 2024
6 checks 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.

2 participants