Show
Ignore:
Timestamp:
07/24/08 04:08:58 (4 months ago)
Author:
flynd
Message:

Use a const pointer for user objects that are only fetched for read access. Fixed some places where we changed the user even though we just had a read lock.

Location:
trunk/qt4-gui/src/contactlist
Files:
4 modified

Legend:

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

    r6330 r6463  
    9191    case LIST_CONTACT_ADDED: 
    9292    { 
    93       ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); 
     93      const ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); 
    9494      if (u == NULL) 
    9595      { 
     
    196196    return; 
    197197 
    198   ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     198  const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    199199  if (u == NULL) 
    200200    return; 
     
    339339} 
    340340 
    341 void ContactListModel::addUser(ICQUser* licqUser) 
     341void ContactListModel::addUser(const ICQUser* licqUser) 
    342342{ 
    343343  ContactUserData* newUser = new ContactUserData(licqUser, this); 
    344344  connect(newUser, SIGNAL(dataChanged(const ContactUserData*)), 
    345345      SLOT(userDataChanged(const ContactUserData*))); 
    346   connect(newUser, SIGNAL(updateUserGroups(ContactUserData*, ICQUser*)), 
    347       SLOT(updateUserGroups(ContactUserData*, ICQUser*))); 
     346  connect(newUser, SIGNAL(updateUserGroups(ContactUserData*, const ICQUser*)), 
     347      SLOT(updateUserGroups(ContactUserData*, const ICQUser*))); 
    348348 
    349349  myUsers.append(newUser); 
     
    351351} 
    352352 
    353 void ContactListModel::updateUserGroups(ContactUserData* user, ICQUser* licqUser) 
     353void ContactListModel::updateUserGroups(ContactUserData* user, const ICQUser* licqUser) 
    354354{ 
    355355  // Check which user groups the user should be member of 
  • trunk/qt4-gui/src/contactlist/contactlist.h

    r6323 r6463  
    210210   * @param licqUser The user to add 
    211211   */ 
    212   void addUser(ICQUser* licqUser); 
     212  void addUser(const ICQUser* licqUser); 
    213213 
    214214  /** 
     
    412412   * @param licqUser The daemon user to get group membership from 
    413413   */ 
    414   void updateUserGroups(ContactUserData* user, ICQUser* licqUser); 
     414  void updateUserGroups(ContactUserData* user, const ICQUser* licqUser); 
    415415 
    416416private: 
  • trunk/qt4-gui/src/contactlist/contactuserdata.cpp

    r6460 r6463  
    5858 
    5959 
    60 ContactUserData::ContactUserData(ICQUser* licqUser, QObject* parent) 
     60ContactUserData::ContactUserData(const ICQUser* licqUser, QObject* parent) 
    6161  : myStatus(ICQ_STATUS_OFFLINE), 
    6262    myEvents(0), 
     
    144144 
    145145 
    146   ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); 
     146  const ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); 
    147147  if (u != NULL) 
    148148  { 
     
    157157} 
    158158 
    159 void ContactUserData::updateAll(ICQUser* u) 
     159void ContactUserData::updateAll(const ICQUser* u) 
    160160{ 
    161161  myStatus = u->Status(); 
     
    396396} 
    397397 
    398 bool ContactUserData::updateText(ICQUser* licqUser) 
     398bool ContactUserData::updateText(const ICQUser* licqUser) 
    399399{ 
    400400  bool hasChanged = false; 
     
    425425void ContactUserData::configUpdated() 
    426426{ 
    427   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     427  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    428428  if (u == NULL) 
    429429    return; 
     
    499499  // Here we update any content that may be dynamic, for example timestamps 
    500500 
    501   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     501  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    502502  if (u == NULL) 
    503503    return; 
     
    669669QString ContactUserData::tooltip() const 
    670670{ 
    671   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     671  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    672672  if (u == NULL) 
    673673    return ""; 
  • trunk/qt4-gui/src/contactlist/contactuserdata.h

    r6150 r6463  
    5454   * @param parent Object to use as parent for those objects that needs it 
    5555   */ 
    56   ContactUserData(ICQUser* licqUser, QObject* parent); 
     56  ContactUserData(const ICQUser* licqUser, QObject* parent); 
    5757 
    5858  /** 
     
    7373   * @param licqUser Licq user to read information from 
    7474   */ 
    75   void updateAll(ICQUser* licqUser); 
     75  void updateAll(const ICQUser* licqUser); 
    7676 
    7777  /** 
     
    168168   * Signal emitted when the user group memberships (may) have changed 
    169169   */ 
    170   void updateUserGroups(ContactUserData* user, ICQUser* licqUser); 
     170  void updateUserGroups(ContactUserData* user, const ICQUser* licqUser); 
    171171 
    172172private: 
     
    192192   * @return True if any data was actually changed 
    193193   */ 
    194   bool updateText(ICQUser* licqUser); 
     194  bool updateText(const ICQUser* licqUser); 
    195195 
    196196  /**