Francois Gouget : testbot: Better track VM status changes.

Alexandre Julliard julliard at winehq.org
Tue Jun 28 11:49:22 CDT 2022


Module: tools
Branch: master
Commit: 9c03a8fe82672fb25106681a10725e74f7a4f8ee
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=9c03a8fe82672fb25106681a10725e74f7a4f8ee

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Mon Jun 27 19:58:34 2022 +0200

testbot: Better track VM status changes.

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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 f0c16d19..2f736c63 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($$$$$$)




More information about the wine-cvs mailing list