Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Fix Tween.is_active() always true after stop() and then start() (Fix #39760 & #39801) #47142

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scene/animation/tween.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,22 @@ bool Tween::start() {
return true;
}

pending_update++;
for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
InterpolateData &data = E->get();
data.active = true;
}
pending_update--;

// We want to be activated
set_active(true);

// Don't resume from current position if stop_all() function has been used
if (was_stopped) {
seek(0);
}
was_stopped = false;

return true;
}

Expand Down Expand Up @@ -925,6 +939,7 @@ bool Tween::stop(Object *p_object, StringName p_key) {
bool Tween::stop_all() {
// We no longer need to be active since all tweens have been stopped
set_active(false);
was_stopped = true;

// For each interpolation...
pending_update++;
Expand Down
2 changes: 1 addition & 1 deletion scene/animation/tween.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Tween : public Node {
float speed_scale;
mutable int pending_update;
int uid;

bool was_stopped = false;
List<InterpolateData> interpolates;

struct PendingCommand {
Expand Down