Ignore:
Timestamp:
07/09/13 12:45:24 (15 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
f3baeb9
Parents:
7135658
git-author:
Ken Moore <ken@…> (07/09/13 12:42:57)
git-committer:
Ken Moore <ken@…> (07/09/13 12:45:24)
Message:

Now the AppCafe? crash when the last item is removed is fixed. Looks like we found a Qt bug with QTreeWidget and removing the last item with takeTopLevelItem().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-softwaremanager/mainUI.cpp

    r51d6c4b re7d8648  
    211211    cList << ui->tree_install_apps->topLevelItem(i)->whatsThis(0); 
    212212  } 
    213    //Now make adjustments as necessary 
    214   for(int i=0; i<installList.length(); i++){ 
    215     //Detemine what action should be done with this item location 
    216     int todo = 0; //0=insert new item, 1=update current item, 2=remove current item 
    217     if(i < cList.length()){ 
    218       if(installList[i] == cList[i]){ todo=1; } 
    219       else if( installList.contains(cList[i]) && !cList.contains(installList[i]) ){ todo=0; } //new item to be inserted here 
    220       else if( !installList.contains(cList[i]) ){ todo=2; } //current item in this location should be removed 
    221     } 
    222     //Now perform the action on this location 
    223     if(todo==0){  
    224       //insert new item 
    225       QTreeWidgetItem *item = new QTreeWidgetItem; //create the item 
    226       item->setWhatsThis(0,installList[i]); 
    227       //Now format the display 
    228       formatInstalledItemDisplay(item); 
    229       //Now insert this item onto the list 
    230       ui->tree_install_apps->insertTopLevelItem(i,item); 
    231       cList.insert(i,installList[i]); //reflect this inclusion into the current list 
    232     }else if(todo==1){ 
    233       //Update current item 
    234       formatInstalledItemDisplay( ui->tree_install_apps->topLevelItem(i) ); 
    235     }else{ 
    236       //Remove current item 
    237       ui->tree_install_apps->takeTopLevelItem(i); 
    238       cList.removeAt(i); //reflect the change to the current list 
    239       i--; //Re-check the item that should be in this location 
    240     } 
    241   } 
    242   //Now makesure that there are no extra items at the end 
    243   int il = installList.length(); 
    244   while(il < cList.length()){ 
    245    ui->tree_install_apps->takeTopLevelItem(il); 
    246    cList.removeAt(il); //reflect the change to the current list  
    247   } 
     213  //Quick finish if no items installed 
     214  if(installList.isEmpty()){ 
     215    ui->tree_install_apps->clear(); 
     216  }else{ 
     217    //Now make adjustments as necessary 
     218    for(int i=0; i<installList.length(); i++){ 
     219      //Detemine what action should be done with this item location 
     220      int todo = 0; //0=insert new item, 1=update current item, 2=remove current item 
     221      if(i < cList.length()){ 
     222        if(installList[i] == cList[i]){ todo=1; } 
     223        else if( installList.contains(cList[i]) && !cList.contains(installList[i]) ){ todo=0; } //new item to be inserted here 
     224        else if( !installList.contains(cList[i]) ){ todo=2; } //current item in this location should be removed 
     225      } 
     226      //Now perform the action on this location 
     227      if(todo==0){  
     228        //insert new item 
     229        QTreeWidgetItem *item = new QTreeWidgetItem; //create the item 
     230        item->setWhatsThis(0,installList[i]); 
     231        //Now format the display 
     232        formatInstalledItemDisplay(item); 
     233        //Now insert this item onto the list 
     234        ui->tree_install_apps->insertTopLevelItem(i,item); 
     235        cList.insert(i,installList[i]); //reflect this inclusion into the current list 
     236      }else if(todo==1){ 
     237        //Update current item 
     238        formatInstalledItemDisplay( ui->tree_install_apps->topLevelItem(i) ); 
     239      }else{ 
     240        //Remove current item 
     241        ui->tree_install_apps->takeTopLevelItem(i); 
     242        cList.removeAt(i); //reflect the change to the current list 
     243        i--; //Re-check the item that should be in this location 
     244      } 
     245    } 
     246    //Now makesure that there are no extra items at the end 
     247    int il = installList.length(); 
     248    while(il < cList.length()){ 
     249      ui->tree_install_apps->takeTopLevelItem(il); 
     250      cList.removeAt(il); //reflect the change to the current list  
     251    } 
     252  } //end of empty list check 
    248253   
    249254  //Make sure that there is an item selected 
     
    257262    }  
    258263  } 
    259    
    260264  on_tree_install_apps_itemSelectionChanged(); //Update the info boxes 
    261265  slotDisplayStats(); 
Note: See TracChangeset for help on using the changeset viewer.