From e31633d60fac84bf8a5b7782d4f5eee2e585ecd6 Mon Sep 17 00:00:00 2001 From: Maximilian Seidler Date: Thu, 27 Nov 2025 16:44:07 +0100 Subject: [PATCH] animation: allow animated variables to be unique pointers --- include/hyprutils/animation/AnimatedVariable.hpp | 4 ++-- src/animation/AnimatedVariable.cpp | 4 ++-- src/animation/AnimationManager.cpp | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/hyprutils/animation/AnimatedVariable.hpp b/include/hyprutils/animation/AnimatedVariable.hpp index 113793f..653d96a 100644 --- a/include/hyprutils/animation/AnimatedVariable.hpp +++ b/include/hyprutils/animation/AnimatedVariable.hpp @@ -21,7 +21,7 @@ namespace Hyprutils { ; // m_bDummy = true; }; - void create(CAnimationManager*, int, Memory::CSharedPointer); + void create(CAnimationManager*, int, Memory::CWeakPointer); void connectToActive(); void disconnectFromActive(); @@ -136,7 +136,7 @@ namespace Hyprutils { public: CGenericAnimatedVariable() = default; - void create(const int typeInfo, CAnimationManager* pAnimationManager, Memory::CSharedPointer> pSelf, + void create(const int typeInfo, CAnimationManager* pAnimationManager, Memory::CWeakPointer> pSelf, const VarType& initialValue) { m_Begun = initialValue; m_Value = initialValue; diff --git a/src/animation/AnimatedVariable.cpp b/src/animation/AnimatedVariable.cpp index 13115fd..4db794b 100644 --- a/src/animation/AnimatedVariable.cpp +++ b/src/animation/AnimatedVariable.cpp @@ -11,9 +11,9 @@ static const std::string DEFAULTSTYLE = ""; #define SP CSharedPointer #define WP CWeakPointer -void CBaseAnimatedVariable::create(CAnimationManager* pManager, int typeInfo, SP pSelf) { +void CBaseAnimatedVariable::create(CAnimationManager* pManager, int typeInfo, WP pSelf) { m_Type = typeInfo; - m_pSelf = pSelf; + m_pSelf = std::move(pSelf); m_pAnimationManager = pManager; m_pSignals = pManager->getSignals(); diff --git a/src/animation/AnimationManager.cpp b/src/animation/AnimationManager.cpp index 446b2d9..2910549 100644 --- a/src/animation/AnimationManager.cpp +++ b/src/animation/AnimationManager.cpp @@ -64,14 +64,13 @@ void CAnimationManager::rotateActive() { std::vector> active; active.reserve(m_vActiveAnimatedVariables.size()); // avoid reallocations for (auto const& av : m_vActiveAnimatedVariables) { - const auto PAV = av.lock(); - if (!PAV) + if (!av) continue; - if (PAV->ok() && PAV->isBeingAnimated()) + if (av->ok() && av->isBeingAnimated()) active.emplace_back(av); else - PAV->m_bIsConnectedToActive = false; + av->m_bIsConnectedToActive = false; } m_vActiveAnimatedVariables = std::move(active);