Skip to content

Commit

Permalink
Fix calling chain in galleryslide functions.
Browse files Browse the repository at this point in the history
The clang-tidy "bugprone parent virtual call" checker pointed out a
couple of places where galleryslide functions call directly up to
their grandparent function instead of their (in this case
non-existent) parent function.  Add new parent functions that do
nothing more than call up, and call those instead of directly calling
the grandparent.

https://clang.llvm.org/extra/clang-tidy/checks/bugprone-parent-virtual-call.html
  • Loading branch information
linuxdude42 committed Nov 22, 2019
1 parent f72d079 commit 1332eb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
16 changes: 4 additions & 12 deletions mythtv/programs/mythfrontend/galleryslide.cpp
Expand Up @@ -163,9 +163,7 @@ void SequentialAnimation::Start(bool forwards, float speed)
m_current = forwards ? 0 : m_group.size() - 1;

// Start group, then first child
// Parent function explicitly set to zero. Have to call
// grandparent directly to get work done.
AbstractAnimation::Start(forwards, speed);
GroupAnimation::Start(forwards, speed);
m_group.at(m_current)->Start(m_forwards, m_speed);
}

Expand All @@ -177,9 +175,7 @@ void SequentialAnimation::Start(bool forwards, float speed)
void SequentialAnimation::SetSpeed(float speed)
{
// Set group speed for subsequent children
// Parent function explicitly set to zero. Have to call
// grandparent directly to get work done.
AbstractAnimation::SetSpeed(speed);
GroupAnimation::SetSpeed(speed);

// Set active child
if (!m_running || m_current < 0 || m_current >= m_group.size())
Expand Down Expand Up @@ -230,9 +226,7 @@ void ParallelAnimation::Start(bool forwards, float speed)
m_finished = m_group.size();

// Start group, then all children
// Parent function explicitly set to zero. Have to call
// grandparent directly to get work done.
AbstractAnimation::Start(forwards, speed);
GroupAnimation::Start(forwards, speed);
foreach(AbstractAnimation *animation, m_group)
animation->Start(m_forwards, m_speed);
}
Expand All @@ -245,9 +239,7 @@ void ParallelAnimation::Start(bool forwards, float speed)
void ParallelAnimation::SetSpeed(float speed)
{
// Set group speed, then all children
// Parent function explicitly set to zero. Have to call
// grandparent directly to get work done.
AbstractAnimation::SetSpeed(speed);
GroupAnimation::SetSpeed(speed);
foreach(AbstractAnimation *animation, m_group)
animation->SetSpeed(m_speed);
}
Expand Down
6 changes: 4 additions & 2 deletions mythtv/programs/mythfrontend/galleryslide.h
Expand Up @@ -94,8 +94,10 @@ class GroupAnimation : public AbstractAnimation
GroupAnimation() : AbstractAnimation() {}
virtual ~GroupAnimation() { GroupAnimation::Clear(); }
void Pulse(int interval) override = 0; // AbstractAnimation
void Start(bool forwards, float speed = 1.0) override = 0; // AbstractAnimation
void SetSpeed(float speed) override = 0; // AbstractAnimation
void Start(bool forwards, float speed = 1.0) override // AbstractAnimation
{ AbstractAnimation::Start(forwards, speed); }
void SetSpeed(float speed) override // AbstractAnimation
{ AbstractAnimation::SetSpeed(speed); }
virtual void Add(AbstractAnimation *child);
void Clear() override; // AbstractAnimation

Expand Down

0 comments on commit 1332eb8

Please sign in to comment.