Browse Source

Fixed a logic error in the way slides were being queued.

The activeSlides vector was being modified by enqueueSlide while it was being iterated in update(). enqueueSlide now raises a flag, and it is update() that now modifies the activeSlides vector.
master
c-mendoza 8 years ago
parent
commit
08976e4047
  1. 24
      src/Sources/magSlideShowSource.cpp
  2. 1
      src/Sources/magSlideShowSource.h

24
src/Sources/magSlideShowSource.cpp

@ -102,14 +102,23 @@ void magSlideShowSource::update() {
deltaTime = nowTime-lastTime;
runningTime += deltaTime;
lastTime = nowTime;
// ofLogVerbose() << "Delta: " << deltaTime << " running: " << runningTime;
for (auto &slide : activeSlides)
{
slide->update(deltaTime);
}
// Queue the next slide if it is time
if (doPlayNextSlide)
{
playNextSlide();
if (activeSlides.size() > 1)
{
activeSlides[1]->transition->start(activeSlides[0]);
}
doPlayNextSlide = false;
}
// Erase any complete slides:
auto iter = activeSlides.begin();
for (; iter < activeSlides.end(); iter++)
@ -497,13 +506,8 @@ void magSlideShowSource::slideStateChanged(const void *sender, ofEventArgs &args
// << slide->getSlideStateName();
if (slide->getSlideState() == magSlide::SlideState::BuildOut)
{
// slide->transition->start();
// ofLogVerbose() << "BuildOut " << slide->getId();
playNextSlide();
if (activeSlides.size() > 1)
{
activeSlides[1]->transition->start(activeSlides[0]);
}
// Flag that we need to load the next slide:
doPlayNextSlide = true;
}
}

1
src/Sources/magSlideShowSource.h

@ -161,6 +161,7 @@ class magSlideShowSource : public ofx::piMapper::FboSource {
void fileAddedListener(const void *sender);
void fileRemovedListener(const void *sender);
bool doInit;
bool doPlayNextSlide = false;
};

Loading…
Cancel
Save