Skip to content

Commit

Permalink
Fix segfault without importer
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphal authored and kathleenhang committed Mar 5, 2024
1 parent d1952fd commit edd357d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions library/private/animationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class animationManager
void DisableAllAnimation();
int GetAnimationIndex();

/**
* Return the current animation name if any
* Can be called before initialization safely
*/
std::string GetAnimationName();

/**
Expand Down
11 changes: 10 additions & 1 deletion library/src/animationManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace f3d::detail
bool animationManager::Initialize(
const options* options, window* window, interactor_impl* interactor, vtkImporter* importer)
{
assert(importer);
this->HasAnimation = false;
this->Playing = false;
this->CurrentTime = 0;
Expand Down Expand Up @@ -260,6 +261,7 @@ void animationManager::Tick()
//----------------------------------------------------------------------------
bool animationManager::LoadAtTime(double timeValue)
{
assert(this->Importer);
if (!this->HasAnimation)
{
return false;
Expand Down Expand Up @@ -316,6 +318,11 @@ int animationManager::GetAnimationIndex()
// ---------------------------------------------------------------------------------
std::string animationManager::GetAnimationName()
{
if (!this->Importer)
{
return "";
}

if (this->AnimationIndex == -1)
{
return "All Animations";
Expand All @@ -325,6 +332,7 @@ std::string animationManager::GetAnimationName()
//----------------------------------------------------------------------------
void animationManager::EnableAllAnimation()
{
assert(this->Importer);
if (this->AnimationIndex == this->AvailAnimations - 1)
{
for (int i = 0; i < this->AvailAnimations; i++)
Expand All @@ -340,6 +348,7 @@ void animationManager::EnableAllAnimation()
//----------------------------------------------------------------------------
void animationManager::DisableAllAnimation()
{
assert(this->Importer);
if (this->AnimationIndex == this->AvailAnimations - 1)
{
for (int i = 0; i < this->AvailAnimations; i++)
Expand All @@ -359,4 +368,4 @@ void animationManager::GetTimeRange(double timeRange[2])
timeRange[0] = this->TimeRange[0];
timeRange[1] = this->TimeRange[1];
}
}
}

0 comments on commit edd357d

Please sign in to comment.