animation: allow animated variables to be unique pointers

This commit is contained in:
Maximilian Seidler 2025-11-27 16:44:07 +01:00
parent 0168583075
commit e31633d60f
3 changed files with 7 additions and 8 deletions

View file

@ -21,7 +21,7 @@ namespace Hyprutils {
; // m_bDummy = true;
};
void create(CAnimationManager*, int, Memory::CSharedPointer<CBaseAnimatedVariable>);
void create(CAnimationManager*, int, Memory::CWeakPointer<CBaseAnimatedVariable>);
void connectToActive();
void disconnectFromActive();
@ -136,7 +136,7 @@ namespace Hyprutils {
public:
CGenericAnimatedVariable() = default;
void create(const int typeInfo, CAnimationManager* pAnimationManager, Memory::CSharedPointer<CGenericAnimatedVariable<VarType, AnimationContext>> pSelf,
void create(const int typeInfo, CAnimationManager* pAnimationManager, Memory::CWeakPointer<CGenericAnimatedVariable<VarType, AnimationContext>> pSelf,
const VarType& initialValue) {
m_Begun = initialValue;
m_Value = initialValue;

View file

@ -11,9 +11,9 @@ static const std::string DEFAULTSTYLE = "";
#define SP CSharedPointer
#define WP CWeakPointer
void CBaseAnimatedVariable::create(CAnimationManager* pManager, int typeInfo, SP<CBaseAnimatedVariable> pSelf) {
void CBaseAnimatedVariable::create(CAnimationManager* pManager, int typeInfo, WP<CBaseAnimatedVariable> pSelf) {
m_Type = typeInfo;
m_pSelf = pSelf;
m_pSelf = std::move(pSelf);
m_pAnimationManager = pManager;
m_pSignals = pManager->getSignals();

View file

@ -64,14 +64,13 @@ void CAnimationManager::rotateActive() {
std::vector<CWeakPointer<CBaseAnimatedVariable>> 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);