Browse Source

Fixed a potential double deletion in ComponentAnimator::AnimationTask

tags/2021-05-28
ed 5 years ago
parent
commit
971fc8e589
1 changed files with 10 additions and 5 deletions
  1. +10
    -5
      modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp

+ 10
- 5
modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp View File

@@ -32,6 +32,11 @@ class ComponentAnimator::AnimationTask
public: public:
AnimationTask (Component* c) noexcept : component (c) {} AnimationTask (Component* c) noexcept : component (c) {}
~AnimationTask()
{
proxy.deleteAndZero();
}
void reset (const Rectangle<int>& finalBounds, void reset (const Rectangle<int>& finalBounds,
float finalAlpha, float finalAlpha,
int millisecondsToSpendMoving, int millisecondsToSpendMoving,
@@ -58,17 +63,17 @@ public:
midSpeed = invTotalDistance; midSpeed = invTotalDistance;
endSpeed = jmax (0.0, endSpd * invTotalDistance); endSpeed = jmax (0.0, endSpd * invTotalDistance);
proxy.deleteAndZero();
if (useProxyComponent) if (useProxyComponent)
proxy.reset (new ProxyComponent (*component));
else
proxy.reset();
proxy = new ProxyComponent (*component);
component->setVisible (! useProxyComponent); component->setVisible (! useProxyComponent);
} }
bool useTimeslice (const int elapsed) bool useTimeslice (const int elapsed)
{ {
if (auto* c = proxy != nullptr ? proxy.get()
if (auto* c = proxy != nullptr ? proxy.getComponent()
: component.get()) : component.get())
{ {
msElapsed += elapsed; msElapsed += elapsed;
@@ -182,7 +187,7 @@ public:
}; };
WeakReference<Component> component; WeakReference<Component> component;
std::unique_ptr<Component> proxy;
Component::SafePointer<Component> proxy;
Rectangle<int> destination; Rectangle<int> destination;
double destAlpha; double destAlpha;


Loading…
Cancel
Save