mirror of
https://github.com/nicbarker/clay.git
synced 2025-01-23 09:56:03 +00:00
[Core] Fix a segfault if debug tools were enabled without a measure text function
Some checks failed
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Failing after 13s
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Failing after 12s
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
Some checks failed
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Failing after 13s
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Failing after 12s
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
This commit is contained in:
parent
cd82ce6fcf
commit
a093730da2
10
clay.h
10
clay.h
@ -596,6 +596,7 @@ CLAY__TYPEDEF(Clay_BooleanWarnings, struct {
|
|||||||
bool maxElementsExceeded;
|
bool maxElementsExceeded;
|
||||||
bool maxRenderCommandsExceeded;
|
bool maxRenderCommandsExceeded;
|
||||||
bool maxTextMeasureCacheExceeded;
|
bool maxTextMeasureCacheExceeded;
|
||||||
|
bool textMeasurementFunctionNotSet;
|
||||||
});
|
});
|
||||||
|
|
||||||
CLAY__TYPEDEF(Clay__Warning, struct {
|
CLAY__TYPEDEF(Clay__Warning, struct {
|
||||||
@ -1624,11 +1625,14 @@ Clay__MeasureTextCacheItem *Clay__MeasureTextCached(Clay_String *text, Clay_Text
|
|||||||
Clay_Context* context = Clay_GetCurrentContext();
|
Clay_Context* context = Clay_GetCurrentContext();
|
||||||
#ifndef CLAY_WASM
|
#ifndef CLAY_WASM
|
||||||
if (!Clay__MeasureText) {
|
if (!Clay__MeasureText) {
|
||||||
|
if (!context->booleanWarnings.textMeasurementFunctionNotSet) {
|
||||||
|
context->booleanWarnings.textMeasurementFunctionNotSet = true;
|
||||||
context->errorHandler.errorHandlerFunction(CLAY__INIT(Clay_ErrorData) {
|
context->errorHandler.errorHandlerFunction(CLAY__INIT(Clay_ErrorData) {
|
||||||
.errorType = CLAY_ERROR_TYPE_TEXT_MEASUREMENT_FUNCTION_NOT_PROVIDED,
|
.errorType = CLAY_ERROR_TYPE_TEXT_MEASUREMENT_FUNCTION_NOT_PROVIDED,
|
||||||
.errorText = CLAY_STRING("Clay's internal MeasureText function is null. You may have forgotten to call Clay_SetMeasureTextFunction(), or passed a NULL function pointer by mistake."),
|
.errorText = CLAY_STRING("Clay's internal MeasureText function is null. You may have forgotten to call Clay_SetMeasureTextFunction(), or passed a NULL function pointer by mistake."),
|
||||||
.userData = context->errorHandler.userData });
|
.userData = context->errorHandler.userData });
|
||||||
return NULL;
|
}
|
||||||
|
return &CLAY__MEASURE_TEXT_CACHE_ITEM_DEFAULT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
uint32_t id = Clay__HashTextWithConfig(text, config);
|
uint32_t id = Clay__HashTextWithConfig(text, config);
|
||||||
@ -3918,9 +3922,7 @@ void Clay_BeginLayout(void) {
|
|||||||
if (context->debugModeEnabled) {
|
if (context->debugModeEnabled) {
|
||||||
rootDimensions.width -= (float)Clay__debugViewWidth;
|
rootDimensions.width -= (float)Clay__debugViewWidth;
|
||||||
}
|
}
|
||||||
context->booleanWarnings.maxElementsExceeded = false;
|
context->booleanWarnings = CLAY__INIT(Clay_BooleanWarnings) CLAY__DEFAULT_STRUCT;
|
||||||
context->booleanWarnings.maxTextMeasureCacheExceeded = false;
|
|
||||||
context->booleanWarnings.maxRenderCommandsExceeded = false;
|
|
||||||
Clay__OpenElement();
|
Clay__OpenElement();
|
||||||
CLAY_ID("Clay__RootContainer");
|
CLAY_ID("Clay__RootContainer");
|
||||||
CLAY_LAYOUT({ .sizing = {CLAY_SIZING_FIXED((rootDimensions.width)), CLAY_SIZING_FIXED(rootDimensions.height)} });
|
CLAY_LAYOUT({ .sizing = {CLAY_SIZING_FIXED((rootDimensions.width)), CLAY_SIZING_FIXED(rootDimensions.height)} });
|
||||||
|
Loading…
Reference in New Issue
Block a user