Module: tools Branch: master Commit: 5753c5abf6641914a3f7fe396196e22aa11f1918 URL: https://source.winehq.org/git/tools.git/?a=commit;h=5753c5abf6641914a3f7fe39...
Author: Francois Gouget fgouget@codeweavers.com Date: Mon Jun 11 18:44:16 2018 +0200
testbot: Make it possible to get an unfiltered clone of a collection.
Once a filter has been applied to a collection it cannot be removed. This is particularly a problem on Detailref collections (such as $Job->Steps) as the code that has set the filter may be anywhere. So Clone() makes it possible to get an unfiltered copy of the collection without modifying the original collection's filter, and thus without impacting the code using it.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/lib/ObjectModel/Collection.pm | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/testbot/lib/ObjectModel/Collection.pm b/testbot/lib/ObjectModel/Collection.pm index 712172b..c110c98 100644 --- a/testbot/lib/ObjectModel/Collection.pm +++ b/testbot/lib/ObjectModel/Collection.pm @@ -40,7 +40,7 @@ criteria. use Exporter 'import'; our @EXPORT_OK = qw(new ComputeMasterKey);
-use Scalar::Util qw(weaken); +use Scalar::Util qw(blessed weaken); use ObjectModel::BackEnd; use ObjectModel::Item;
@@ -114,6 +114,38 @@ sub _initialize($;$) $self->{AllScopeItems}->{ref($self)} ||= {}; }
+=pod +=over 12 + +=item C<Clone()> + +Clones the collection, omitting the filters that were applied to it. + +=back +=cut + +sub Clone($) +{ + my ($self) = @_; + + my $Copy = {TableName => $self->{TableName}, + CollectionName => $self->{CollectionName}, + ItemName => $self->{ItemName}, + PropertyDescriptors => $self->{PropertyDescriptors}, + MasterColNames => $self->{MasterColNames}, + MasterColValues => $self->{MasterColValues}, + MasterKey => $self->{MasterKey}, + Filters => {}, + AllScopeItems => $self->{AllScopeItems}, + Items => undef}; + # See Collection::new() + weaken($Copy->{AllScopeItems}); + + $Copy = bless $Copy, blessed($self); + $Copy->_initialize(@_); + return $Copy; +} + sub GetPropertyDescriptors($) { my ($self) = @_;