diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2018-03-25 15:23:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-26 09:30:25 +0200 |
commit | d312ff2b52c0ea2e2864518a36f6b432653c8297 (patch) | |
tree | 34d1b98329a8a56b289d82299534d4120485f1ad /svx/source/sdr/animation | |
parent | 42af2f3b2ebd6c559e92e487b9e19ab1e9cd6e33 (diff) |
tdf#112997 multiple animated gif only one frame
Not sure what the problem is, but using a vector and just making sure
we insert into the right spot for the sorting fixes it.
Change-Id: I11c08e08a14c98ba7eb6a5d925c75bab891ecf63
Reviewed-on: https://gerrit.libreoffice.org/51829
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/sdr/animation')
-rw-r--r-- | svx/source/sdr/animation/animationstate.cxx | 2 | ||||
-rw-r--r-- | svx/source/sdr/animation/scheduler.cxx | 37 |
2 files changed, 18 insertions, 21 deletions
diff --git a/svx/source/sdr/animation/animationstate.cxx b/svx/source/sdr/animation/animationstate.cxx index f0e67cfcec07..4b3b5f2fa08e 100644 --- a/svx/source/sdr/animation/animationstate.cxx +++ b/svx/source/sdr/animation/animationstate.cxx @@ -102,7 +102,7 @@ namespace sdr // set time and reactivate by re-adding to the scheduler SetTime(nNextTime); - mrVOContact.GetObjectContact().getPrimitiveAnimator().InsertEvent(this); + mrVOContact.GetObjectContact().getPrimitiveAnimator().InsertEvent(*this); } } diff --git a/svx/source/sdr/animation/scheduler.cxx b/svx/source/sdr/animation/scheduler.cxx index 0d7490850792..a8fc3272be8b 100644 --- a/svx/source/sdr/animation/scheduler.cxx +++ b/svx/source/sdr/animation/scheduler.cxx @@ -19,6 +19,7 @@ #include <svx/sdr/animation/scheduler.hxx> +#include <algorithm> #include <vector> @@ -45,12 +46,6 @@ namespace sdr } } - bool CompareEvent::operator()(Event* const& lhs, Event* const& rhs) const - { - return lhs->GetTime() < rhs->GetTime(); - } - - Scheduler::Scheduler() : mnTime(0), mnDeltaTime(0), @@ -78,17 +73,17 @@ namespace sdr void Scheduler::triggerEvents() { - if (maList.empty()) + if (mvEvents.empty()) return; // copy events which need to be executed to a vector. Remove them from // the scheduler ::std::vector< Event* > aToBeExecutedList; - while(!maList.empty() && maList[0]->GetTime() <= mnTime) + while(!mvEvents.empty() && mvEvents.front()->GetTime() <= mnTime) { - Event* pNextEvent = maList.front(); - maList.erase(maList.begin()); + Event* pNextEvent = mvEvents.front(); + mvEvents.erase(mvEvents.begin()); aToBeExecutedList.push_back(pNextEvent); } @@ -105,9 +100,9 @@ namespace sdr void Scheduler::checkTimeout() { // re-start or stop timer according to event list - if(!IsPaused() && !maList.empty()) + if(!IsPaused() && !mvEvents.empty()) { - mnDeltaTime = maList.front()->GetTime() - mnTime; + mnDeltaTime = mvEvents.front()->GetTime() - mnTime; if(0L != mnDeltaTime) { @@ -129,11 +124,11 @@ namespace sdr Stop(); mnTime = nTime; - if (maList.empty()) + if (mvEvents.empty()) return; // reset event time points - for (auto & rEvent : maList) + for (auto & rEvent : mvEvents) { rEvent->SetTime(nTime); } @@ -148,19 +143,21 @@ namespace sdr } } - void Scheduler::InsertEvent(Event* pNew) + void Scheduler::InsertEvent(Event& rNew) { - maList.insert(pNew); + // insert maintaining time ordering + auto it = mvEvents.begin(); + while (it != mvEvents.end() && rNew.GetTime() >= (*it)->GetTime()) + it++; + mvEvents.insert(it, &rNew); checkTimeout(); } void Scheduler::RemoveEvent(Event* pOld) { - if(!maList.empty()) + if(!mvEvents.empty()) { - auto it = maList.find(pOld); - if (it != maList.end()) - maList.erase(it); + mvEvents.erase(std::remove(mvEvents.begin(), mvEvents.end(), pOld), mvEvents.end()); checkTimeout(); } } |