clay
clay copied to clipboard
[Core] Crash when introducing a scroll area mid frame
Here
Clay_ScrollContainerData Clay_GetScrollContainerData(Clay_ElementId id) {
...
.config = *Clay__FindElementConfigWithType(scrollContainerData->layoutElement, CLAY__ELEMENT_CONFIG_TYPE_SCROLL).scrollElementConfig,
This call above can be NULL which causes a crash due to the de-ref. I have change so I do this locally, but I'm unsure if it's correct or not (but it seems to work)
Clay_ScrollElementConfig* scrollConfig = Clay__FindElementConfigWithType(scrollContainerData->layoutElement, CLAY__ELEMENT_CONFIG_TYPE_SCROLL).scrollElementConfig;
if (!scrollConfig) {
return CLAY__INIT(Clay_ScrollContainerData) CLAY__DEFAULT_STRUCT;
}
return CLAY__INIT(Clay_ScrollContainerData) {
.scrollPosition = &scrollContainerData->scrollPosition,
.scrollContainerDimensions = { scrollContainerData->boundingBox.width, scrollContainerData->boundingBox.height },
.contentDimensions = scrollContainerData->contentSize,
.config = *scrollConfig,
.found = true
};
Any update on this? I still have to keep a fork because of this crash.
My apologies, this one slipped through the cracks. I'll take a look at it now 🙂
Your fix looks like totally the right way to do it! I've comitted it here: https://github.com/nicbarker/clay/commit/06167b4f4b5e52a29e17cfc7e61b41aa2e982ba3
Thanks! :)