Avoid null items in picklist
authorMichael Andres <ma@suse.de>
Thu, 3 Dec 2009 11:43:35 +0000 (12:43 +0100)
committerMichael Andres <ma@suse.de>
Thu, 3 Dec 2009 11:43:35 +0000 (12:43 +0100)
zypp/ui/SelectableImpl.h

index f8f1fd5..54bb1e8 100644 (file)
@@ -253,7 +253,7 @@ namespace zypp
       {
         if ( ! _picklistPtr )
         {
-          _picklistPtr.reset( new PickList( _availableItems.size() ) );
+          _picklistPtr.reset( new PickList );
           // installed without identical avaialble first:
           for_( it, _installedItems.begin(), _installedItems.end() )
           {
@@ -467,6 +467,31 @@ namespace zypp
         str << "}  ";
       }
 
+      if ( obj.picklistEmpty() )
+      {
+        str << "(P 0) {}";
+      }
+      else
+      {
+        PoolItem cand( obj.candidateObj() );
+        PoolItem up( obj.updateCandidateObj() );
+        str << "(P " << obj.picklistSize() << ") {" << endl;
+        for_( it, obj.picklistBegin(), obj.picklistEnd() )
+        {
+          char t = ' ';
+          if ( *it == cand )
+          {
+            t = *it == up ? 'C' : 'c';
+          }
+          else if ( *it == up )
+          {
+            t = 'u';
+          }
+          str << " " << t << " " << *it << "\t" << obj.pickStatus( *it ) << endl;
+        }
+        str << "}  ";
+      }
+
       return str;
     }
     /////////////////////////////////////////////////////////////////