mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
fix(ui): avoid potential null pointer issue in CSimpleButton::SetFontString
This commit is contained in:
parent
25780ae857
commit
a9364386d8
@ -491,28 +491,21 @@ void CSimpleButton::SetFontString(CSimpleFontString* text) {
|
||||
|
||||
if (text) {
|
||||
text->SetFrame(this, DRAWLAYER_ARTWORK, 1);
|
||||
}
|
||||
|
||||
if (!text->Sub482AC0()) {
|
||||
auto font = this->m_normalFont;
|
||||
if (!text->Sub482AC0()) {
|
||||
auto font = this->m_normalFont;
|
||||
uint32_t styleFlags = font ? font->m_attributes.m_styleFlags : 0x0;
|
||||
|
||||
int32_t styleFlags;
|
||||
float offsetX = 0.0f;
|
||||
float offsetY = 0.0f;
|
||||
|
||||
if (font) {
|
||||
styleFlags = font->m_attributes.m_styleFlags;
|
||||
} else {
|
||||
styleFlags = 0;
|
||||
}
|
||||
|
||||
float offsetX = 0.0f;
|
||||
float offsetY = 0.0f;
|
||||
|
||||
if (styleFlags & 0x1) {
|
||||
text->SetPoint(FRAMEPOINT_LEFT, this, FRAMEPOINT_LEFT, offsetX, offsetY, 1);
|
||||
} else if (styleFlags & 0x4) {
|
||||
text->SetPoint(FRAMEPOINT_RIGHT, this, FRAMEPOINT_RIGHT, offsetX, offsetY, 1);
|
||||
} else {
|
||||
text->SetPoint(FRAMEPOINT_CENTER, this, FRAMEPOINT_CENTER, offsetX, offsetY, 1);
|
||||
if (styleFlags & 0x1) {
|
||||
text->SetPoint(FRAMEPOINT_LEFT, this, FRAMEPOINT_LEFT, offsetX, offsetY, 1);
|
||||
} else if (styleFlags & 0x4) {
|
||||
text->SetPoint(FRAMEPOINT_RIGHT, this, FRAMEPOINT_RIGHT, offsetX, offsetY, 1);
|
||||
} else {
|
||||
text->SetPoint(FRAMEPOINT_CENTER, this, FRAMEPOINT_CENTER, offsetX, offsetY, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user