4.7.2 TimerHandle Issue in Actor.h

you might want to show more of your code so Epic can see what you’re trying to do more easily and thus assist better

In Actor.h, the lifespan timerhandle has been set to private so we can get the timer information anymore.

I have actor were I need to get the information on their lifespan.
During the conversion, I created a new timerhandle set to the Lifespan function, but I’m fearing side effects like:

1 - Duplicate timer with different timing → so the the lifespan function will be called twice
2 - I have no clue if setting my timer will clear the one defined in the Actor.h and if code rely on it, it may break the code

Could you please confirm if there are some side effect to do this?
Could you please modify the timerhandle to Protected? if no could you please explain the rationals around this decision?

Thanks,

Here is a sample code:
In .H

FTimerHandle TimerHandle_LifeSpanExpired_2;

in .cpp

if (NewLifespan > 0.0f)
{
GetWorldTimerManager().SetTimer(TimerHandle_LifeSpanExpired_2, this, &AActor::LifeSpanExpired, NewLifespan );
}
else
{
GetWorldTimerManager().ClearTimer(TimerHandle_LifeSpanExpired_2);
}

In normal case, I should have use the current Handle TimerHandle_LifeSpanExpired but it is Private.

Thanks,

Hey -

Checking the source code for the promoted branch on GitHub it appears this has already been changed from private to protected. The following commit contains the file where this change occurred. Syncing the commit to your local build should allow you to work with the protected version as you suggested.

https://github.com/EpicGames/UnrealEngine/commit/c6c2c077b12686557cc2a3e77e513f0cf3ae341f

Cheers

Thanks for the update.

Could we have some insight on the question on how works the timerhandles if we set 2 different timerhandle on the same function?

Hey -

If you have two different timerhandles referencing the same function then each one will have a unique id that can be used independently of each other.

Thanks for the information.
It could be great if it is part of the docs as many of us are used of the old method that manage to only have 1 and only 1 timer per function. This can have some side effects for people.

Hi,

Why this changed wasn’t added to 4.7.3? Can we expect it on 4.7.4?

thanks,

Hey -

The commit listed above is in the promoted and master branches of GitHub. As such it will likely be integrated into the next major release for the engine. Keep in mind that you can use the link provided to merge just that commit into your source.