Permalink
Browse files

engine: handle faders deletion on fade out

Otherwise faders will stay in universes forever
  • Loading branch information...
mcallegari committed Dec 8, 2018
1 parent 5fb4119 commit c50b5fdc8e9f84f9264249e55d8a9ef3b56ec124
Showing with 14 additions and 31 deletions.
  1. +1 −0 engine/src/fadechannel.cpp
  2. +12 −17 engine/src/genericfader.cpp
  3. +0 −14 engine/src/scene.cpp
  4. +1 −0 engine/src/universe.cpp
@@ -283,6 +283,7 @@ uchar FadeChannel::calculateCurrent(uint fadeTime, uint elapsedTime)
// Return the target value if all time has been consumed
// or if the channel has been marked ready.
m_current = m_target;
setReady(true);
}
else if (elapsedTime == 0)
{
@@ -171,19 +171,22 @@ void GenericFader::write(Universe *universe)
else
universe->writeBlended(address, value, m_blendMode);

if ((channelType & FadeChannel::Intensity) &&
if (((channelType & FadeChannel::Intensity) &&
(channelType & FadeChannel::HTP) &&
m_blendMode == Universe::NormalBlend)
m_blendMode == Universe::NormalBlend) || m_fadeOut)
{
// Remove all HTP channels that reach their target _zero_ value.
// Remove all channels that reach their target _zero_ value.
// They have no effect either way so removing them saves a bit of CPU.
if (fc.current() == 0 && fc.target() == 0)
if (fc.current() == 0 && fc.target() == 0 && fc.isReady())
{
it.remove();
continue;
}
}
}

if (m_fadeOut && channelsCount() == 0)
requestDelete();
}

qreal GenericFader::intensity() const
@@ -231,24 +234,16 @@ void GenericFader::setFadeOut(bool enable, uint fadeTime)
while (it.hasNext() == true)
{
FadeChannel& fc(it.next().value());
int channelType = fc.type();
//int channelType = fc.type();

if ((channelType & FadeChannel::Intensity) == 0)
continue;
//if ((channelType & FadeChannel::Intensity) == 0)
// continue;

fc.setStart(fc.current());
fc.setTarget(0);
fc.setElapsed(0);
fc.setReady(false);

if (fc.canFade() == false)
{
fc.setFadeTime(0);
}
else
{
fc.setFadeTime(fadeTime);
fc.setTarget(0);
}
fc.setFadeTime(fc.canFade() ? fadeTime : 0);
}
}
}
@@ -690,20 +690,6 @@ void Scene::write(MasterTimer *timer, QList<Universe*> ua)
}
}

// check if all channels reached their target
// e.g. this happens when all channels are LTP
bool needToStop = true;
foreach (GenericFader *f, m_fadersMap.values())
{
if (f->channelsCount())
{
needToStop = false;
break;
}
}
if (needToStop)
stop(FunctionParent::master());

if (isPaused() == false)
{
incrementElapsed();
@@ -293,6 +293,7 @@ void Universe::processFaders()
if (fader->isEnabled() == false)
continue;

//qDebug() << "Processing fader" << fader->name();
fader->write(this);
}

0 comments on commit c50b5fd

Please sign in to comment.