Skip to content

Commit

Permalink
Fixed crash when position of ChildWindow depends on its size
Browse files Browse the repository at this point in the history
  • Loading branch information
texus committed Jul 17, 2022
1 parent b7eba92 commit 22c49d9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Widgets/ChildWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ namespace tgui

void ChildWindow::setPosition(const Layout2d& position)
{
Layout2d containerPos = position;
if (m_keepInParent && m_parent && (m_parent->getSize().x > 0) && (m_parent->getSize().y > 0))
{
const Vector2f origin{getOrigin().x * getSize().x, getOrigin().y * getSize().y};
Expand All @@ -144,11 +143,11 @@ namespace tgui
else if (x > m_parent->getSize().x - getSize().x)
x = std::max(0.f, m_parent->getSize().x - getSize().x);

containerPos = {x + origin.x, y + origin.y};
Container::setPosition({x + origin.x, y + origin.y});
}
}

Container::setPosition(containerPos);
else
Container::setPosition(position);

// Calculate the distance from the right side that the buttons will need
float buttonOffsetX = 0;
Expand Down

0 comments on commit 22c49d9

Please sign in to comment.