Skip to content

Commit

Permalink
[SUTK] Fix for segfault when the last tab is destroyed, added more co…
Browse files Browse the repository at this point in the history
…mments on onStepAll() method in AnimationGroup
  • Loading branch information
ravi688 committed Jan 7, 2025
1 parent f027a2f commit 6e7a707
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sutk/include/sutk/AnimationEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ namespace SUTK
// Called when all the animations in this group have ended
virtual void onWhenAllEnd() noexcept { }
// Called after when onStep() is invoked over all animations in this group
// NOTE: It is called even if the last stepped animation is ended resulting in zero animation count.
// So, if you're destroy some objects in onEnd() of an Animation then make sure to check of nulls.
virtual void onStepAll() noexcept { }
};
class AnimContextBase : public UIDriverObject
Expand Down
5 changes: 4 additions & 1 deletion sutk/source/NotebookView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,10 @@ namespace SUTK
void TabAnimGroup::onStepAll() noexcept
{
auto* tabBar = m_notebook->getTabBar();
tabBar->scrollToTab(tabBar->getSelectedTab());
// onStepAll() is called even for the last (only one is left) stepped animation and that animation might destroy the only tab left in the TabBar
// Causing tabBar->getSelectedTab() to return nullptr, so we need to check for null here.
if(tabBar->getSelectedTab())
tabBar->scrollToTab(tabBar->getSelectedTab());
}
TabAnimGroup::TabAnimGroup(UIDriver& driver, NotebookView* notebook) noexcept : AnimGroup(driver), m_notebook(notebook)
{
Expand Down

0 comments on commit 6e7a707

Please sign in to comment.