Skip to content

Commit

Permalink
Remove ugly hack in static_text.h
Browse files Browse the repository at this point in the history
Just use the root element, like GUIButton:add().
  • Loading branch information
Desour authored and sfan5 committed Aug 14, 2023
1 parent f7f3aaf commit d75c956
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions src/irrlicht_changes/static_text.h
Expand Up @@ -49,27 +49,7 @@ namespace gui
s32 id = -1,
bool fillBackground = false)
{
if (parent == NULL) {
// parent is NULL, so we must find one, or we need not to drop
// result, but then there will be a memory leak.
//
// What Irrlicht does is to use guienv as a parent, but the problem
// is that guienv is here only an IGUIEnvironment, while it is a
// CGUIEnvironment in Irrlicht, which inherits from both IGUIElement
// and IGUIEnvironment.
//
// A solution would be to dynamic_cast guienv to a
// IGUIElement*, but Irrlicht is shipped without rtti support
// in some distributions, causing the dymanic_cast to segfault.
//
// Thus, to find the parent, we create a dummy StaticText and ask
// for its parent, and then remove it.
irr::gui::IGUIStaticText *dummy_text =
guienv->addStaticText(L"", rectangle, border, wordWrap,
parent, id, fillBackground);
parent = dummy_text->getParent();
dummy_text->remove();
}
parent = parent ? parent : guienv->getRootGUIElement();
irr::gui::IGUIStaticText *result = new irr::gui::StaticText(
text, border, guienv, parent,
id, rectangle, fillBackground);
Expand Down

0 comments on commit d75c956

Please sign in to comment.