mirror of
https://github.com/whoahq/whoa.git
synced 2026-11-27 08:13:50 +03:00
fix(ui): avoid potential null pointer issue in CSimpleButton::SetFontString
This commit is contained in:
1 file changed
+12
-19
+12
-19
@@ -491,28 +491,21 @@ void CSimpleButton::SetFontString(CSimpleFontString* text) {
|
|||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
text->SetFrame(this, DRAWLAYER_ARTWORK, 1);
|
text->SetFrame(this, DRAWLAYER_ARTWORK, 1);
|
||||||
}
|
|
||||||
|
|
||||||
if (!text->Sub482AC0()) {
|
if (!text->Sub482AC0()) {
|
||||||
auto font = this->m_normalFont;
|
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) {
|
if (styleFlags & 0x1) {
|
||||||
styleFlags = font->m_attributes.m_styleFlags;
|
text->SetPoint(FRAMEPOINT_LEFT, this, FRAMEPOINT_LEFT, offsetX, offsetY, 1);
|
||||||
} else {
|
} else if (styleFlags & 0x4) {
|
||||||
styleFlags = 0;
|
text->SetPoint(FRAMEPOINT_RIGHT, this, FRAMEPOINT_RIGHT, offsetX, offsetY, 1);
|
||||||
}
|
} else {
|
||||||
|
text->SetPoint(FRAMEPOINT_CENTER, this, FRAMEPOINT_CENTER, offsetX, offsetY, 1);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user