Only set OldStatus once to avoid issues in case the status is changed multiple times before the VM is saved.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- This matches the recent job status tracking change. --- testbot/lib/WineTestBot/VMs.pm | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm index f0c16d19ec..2f736c636e 100644 --- a/testbot/lib/WineTestBot/VMs.pm +++ b/testbot/lib/WineTestBot/VMs.pm @@ -157,15 +157,6 @@ use WineTestBot::TestAgent; use WineTestBot::Utils;
-sub _initialize($$) -{ - my ($self, $VMs) = @_; - - $self->SUPER::_initialize($VMs); - - $self->{OldStatus} = undef; -} - sub InitializeNew($$) { my ($self, $Collection) = @_; @@ -270,8 +261,8 @@ sub Status($;$)
if (!defined $CurrentStatus or $NewStatus ne $CurrentStatus) { + $self->{OldStatus} ||= $CurrentStatus; $self->SUPER::Status($NewStatus); - $self->{OldStatus} = $CurrentStatus; }
return $NewStatus; @@ -424,15 +415,11 @@ sub OnSaved($) my ($self) = @_;
$self->SUPER::OnSaved(); - - if (defined($self->{OldStatus})) + if (defined $self->{OldStatus} and $self->{OldStatus} ne $self->Status) { - my $NewStatus = $self->Status; - if ($NewStatus ne $self->{OldStatus}) - { - VMStatusChange($self->GetKey(), $self->{OldStatus}, $NewStatus); - } + VMStatusChange($self->GetKey(), $self->{OldStatus}, $self->Status); } + delete $self->{OldStatus}; }
sub Run($$$$$$)