Changeset 6216

Show
Ignore:
Timestamp:
05/26/08 03:06:39 (8 months ago)
Author:
eugene
Message:

Fixed user handling in GPG key management classes, this fixes several crash cases.

Location:
trunk/qt4-gui/src/dialogs
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/dialogs/gpgkeymanager.cpp

    r6211 r6216  
    9898 
    9999  // create the keylist 
    100   lst_keyList = new KeyList(); 
     100  lst_keyList = new KeyList(this); 
    101101  lst_keyList->setAllColumnsShowFocus(true); 
    102102  QStringList headers; 
     
    182182    return; 
    183183 
    184   ICQUser* u = gUserManager.FetchUser(tmp->szId.toLatin1(), tmp->nPPID, LOCK_R); 
    185   if ( u ) 
    186   { 
    187     editUser( u ); 
     184  editUser(tmp->szId, tmp->nPPID); 
     185} 
     186 
     187void GPGKeyManager::editUser(QString id, unsigned long ppid) 
     188{ 
     189  KeyListItem* item = NULL; 
     190  bool found = false; 
     191 
     192  for (int i = 0; i < lst_keyList->topLevelItemCount(); ++i) 
     193  { 
     194    item = dynamic_cast<KeyListItem*>(lst_keyList->topLevelItem(i)); 
     195 
     196    if (item->getszId() == id && item->getnPPID() == ppid) 
     197    { 
     198      found = true; 
     199      break; 
     200    } 
     201  } 
     202 
     203  if (!found) 
     204  { 
     205    ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     206    if (u == NULL) 
     207      return; 
     208    item = new KeyListItem(lst_keyList, u); 
    188209    gUserManager.DropUser(u); 
    189210  } 
    190 } 
    191  
    192 void GPGKeyManager::editUser(ICQUser* u) 
    193 { 
    194   for (int i = 0; i < lst_keyList->topLevelItemCount(); ++i) 
    195   { 
    196     KeyListItem* item = dynamic_cast<KeyListItem*>(lst_keyList->topLevelItem(i)); 
    197  
    198     if (item->getszId() == u->IdString() && item->getnPPID() == u->PPID()) 
    199     { 
    200       item->edit(); 
    201       return; 
    202     } 
    203   } 
    204  
    205   (new KeyListItem(lst_keyList, u))->edit(); 
     211 
     212  item->edit(); 
    206213}; 
    207214 
     
    278285  QString szId = text.mid(4); 
    279286 
    280   ICQUser* u = gUserManager.FetchUser(szId.toLatin1(), nPPID, LOCK_R); 
    281  
    282   if (u != NULL) 
    283   { 
    284     bool found = false; 
    285     for (int i = 0; i < topLevelItemCount(); ++i) 
    286     { 
    287       KeyListItem* item = dynamic_cast<KeyListItem*>(topLevelItem(i)); 
    288       if (item->getszId() == szId && item->getnPPID() == nPPID) 
    289       { 
    290         item->edit(); 
    291         found = true; 
    292         break; 
    293       } 
    294     } 
    295     if (!found) 
    296       (new KeyListItem(this, u))->edit(); 
    297     gUserManager.DropUser(u); 
    298   } 
     287  GPGKeyManager* km = dynamic_cast<GPGKeyManager*>(nativeParentWidget()); 
     288  if (km != NULL) 
     289    km->editUser(szId, nPPID); 
    299290} 
    300291 
  • trunk/qt4-gui/src/dialogs/gpgkeymanager.h

    r5837 r6216  
    4545  QLabel* lbl_passphrase; 
    4646  QLabel* lbl_dragndrop; 
    47   void editUser(ICQUser* u); 
     47  void editUser(QString id, unsigned long ppid); 
    4848  void initKeyList(); 
    4949 
     
    5555  void slot_remove(); 
    5656  void slot_doubleClicked(QTreeWidgetItem* item); 
     57 
     58  friend class KeyList; 
    5759}; 
    5860