summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2018-03-25 15:23:47 +0200
committerCaolán McNamara <caolanm@redhat.com>2018-04-04 11:06:04 +0200
commit2439b95b4d34e519aa2a5617a7f1e194b7864222 (patch)
tree269c47ed83588aab0bc6a83dbe36fe2095231485 /svx/source
parent2a2aeaeef39f6a940838e2da69c5e1bc61e3793d (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> (cherry picked from commit d312ff2b52c0ea2e2864518a36f6b432653c8297) Reviewed-on: https://gerrit.libreoffice.org/52009 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/sdr/animation/animationstate.cxx2
-rw-r--r--svx/source/sdr/animation/scheduler.cxx37
-rw-r--r--svx/source/sdr/overlay/overlayanimatedbitmapex.cxx2
-rw-r--r--svx/source/sdr/overlay/overlayrectangle.cxx2
4 files changed, 20 insertions, 23 deletions
diff --git a/svx/source/sdr/animation/animationstate.cxx b/svx/source/sdr/animation/animationstate.cxx
index e271e2f586a0..a7b672759fd0 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();
}
}
diff --git a/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx b/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
index 46ff77d897ce..ef23e626f07e 100644
--- a/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
+++ b/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
@@ -105,7 +105,7 @@ namespace sdr
}
// re-insert me as event
- getOverlayManager()->InsertEvent(this);
+ getOverlayManager()->InsertEvent(*this);
// register change (after change)
objectChange();
diff --git a/svx/source/sdr/overlay/overlayrectangle.cxx b/svx/source/sdr/overlay/overlayrectangle.cxx
index 7c72884205c0..8561d3f306cc 100644
--- a/svx/source/sdr/overlay/overlayrectangle.cxx
+++ b/svx/source/sdr/overlay/overlayrectangle.cxx
@@ -108,7 +108,7 @@ namespace sdr
}
// re-insert me as event
- getOverlayManager()->InsertEvent(this);
+ getOverlayManager()->InsertEvent(*this);
// register change (after change)
objectChange();