Changeset 5438

Show
Ignore:
Timestamp:
09/26/07 06:09:00 (14 months ago)
Author:
erijo
Message:

Check that the user returned from UserManager? isn't NULL before using
it. Will hopefully fix #1520.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt-gui/src/userbox.cpp

    r5328 r5438  
    17061706    QRect r(itemRect(item)); 
    17071707    ICQUser *u = gUserManager.FetchUser(item->m_szId, item->m_nPPID, LOCK_R); 
    1708     QTextCodec * codec = UserCodec::codecForICQUser(u); 
     1708 
    17091709    QString strFileName = ""; 
    17101710    if (u && u->GetPicturePresent() && gMainWindow->m_bPopPicture) 
    17111711    { 
    1712       const QString file = QString("%1/%2/%3.pic").arg(BASE_DIR).arg(USER_DIR).arg(u->IdString()); 
     1712      const QString file = 
     1713          QString("%1/%2/%3.pic").arg(BASE_DIR).arg(USER_DIR).arg(u->IdString()); 
    17131714      const QImage picture = QImage(file); 
    17141715      if (!picture.isNull()) 
     
    17191720    } 
    17201721 
    1721     QString s = strFileName + QString("<nobr>") + QString(ICQUser::StatusToStatusStr(item->m_nStatus, item->m_bStatusInvisible)) 
    1722       + QString("</nobr>"); 
    1723      
    1724     if (*u->GetAlias() && gMainWindow->m_bPopAlias) 
     1722    QString s = strFileName + QString("<nobr>") + 
     1723        QString(ICQUser::StatusToStatusStr(item->m_nStatus, 
     1724                                           item->m_bStatusInvisible)) + 
     1725        QString("</nobr>"); 
     1726 
     1727    QTextCodec* codec = UserCodec::defaultEncoding(); 
     1728    if (u != NULL) 
     1729      codec = UserCodec::codecForICQUser(u); 
     1730 
     1731    if (u && *u->GetAlias() && gMainWindow->m_bPopAlias) 
    17251732      s += tr("<br><nobr>") + QString::fromUtf8(u->GetAlias()) + tr("</nobr>"); 
    17261733 
    1727     if ((*u->GetFirstName() || *u->GetLastName()) && gMainWindow->m_bPopName) 
     1734    if (u && (*u->GetFirstName() || *u->GetLastName()) && gMainWindow->m_bPopName) 
    17281735    { 
    17291736      s += tr("<br><nobr>"); 
     
    17641771      s += tr("<br>Custom&nbsp;Auto&nbsp;Response"); 
    17651772 
    1766     if (u != NULL) 
    1767     { 
    1768       if (!u->StatusOffline() && u->ClientInfo() && *u->ClientInfo()) 
     1773    if (u && !u->StatusOffline() && u->ClientInfo() && *u->ClientInfo()) 
    17691774      s += tr("<br><nobr>") + codec->toUnicode(u->ClientInfo()) + tr("</nobr>"); 
    17701775       
    1771       if (u->AutoResponse() && *u->AutoResponse() && 
    1772           item->m_nStatus != ICQ_STATUS_OFFLINE && 
    1773           item->m_nStatus != ICQ_STATUS_ONLINE) 
    1774         s += tr("<br><u>Auto Response:</u>") + codec->toUnicode(u->AutoResponse()); 
    1775       gUserManager.DropUser(u); 
    1776     } 
    1777  
    1778     if (*u->GetEmailPrimary() && gMainWindow->m_bPopEmail) 
    1779       s += tr("<br><nobr>E: ") + codec->toUnicode(u->GetEmailPrimary()) + tr("</nobr>"); 
    1780  
    1781     if (item->m_bPhone && gMainWindow->m_bPopPhone) 
    1782       s += tr("<br><nobr>P: ") + codec->toUnicode(u->GetPhoneNumber()) + tr("</nobr>"); 
    1783  
    1784     if (item->m_bCellular && gMainWindow->m_bPopCellular) 
    1785       s += tr("<br><nobr>C: ") + codec->toUnicode(u->GetCellularNumber()) + tr("</nobr>"); 
    1786  
    1787     if ((u->GetFaxNumber()[0]!='\0') && gMainWindow->m_bPopEmail) 
    1788       s += tr("<br><nobr>F: ") + codec->toUnicode(u->GetFaxNumber()) + tr("</nobr>"); 
    1789  
    1790     if ((u->Ip() || u->IntIp()) && gMainWindow->m_bPopIP) { 
     1776    if (u && u->AutoResponse() && *u->AutoResponse() && 
     1777    item->m_nStatus != ICQ_STATUS_OFFLINE && 
     1778    item->m_nStatus != ICQ_STATUS_ONLINE) 
     1779      s += tr("<br><u>Auto Response:</u>") + codec->toUnicode(u->AutoResponse()); 
     1780 
     1781    if (u && *u->GetEmailPrimary() && gMainWindow->m_bPopEmail) 
     1782      s += tr("<br><nobr>E: ") + codec->toUnicode(u->GetEmailPrimary()) + 
     1783    tr("</nobr>"); 
     1784 
     1785    if (u && item->m_bPhone && gMainWindow->m_bPopPhone) 
     1786      s += tr("<br><nobr>P: ") + codec->toUnicode(u->GetPhoneNumber()) + 
     1787    tr("</nobr>"); 
     1788 
     1789    if (u && item->m_bCellular && gMainWindow->m_bPopCellular) 
     1790      s += tr("<br><nobr>C: ") + codec->toUnicode(u->GetCellularNumber()) + 
     1791    tr("</nobr>"); 
     1792 
     1793    if (u && (u->GetFaxNumber()[0]!='\0') && gMainWindow->m_bPopEmail) 
     1794      s += tr("<br><nobr>F: ") + codec->toUnicode(u->GetFaxNumber()) + 
     1795    tr("</nobr>"); 
     1796 
     1797    if (u && (u->Ip() || u->IntIp()) && gMainWindow->m_bPopIP) 
     1798    { 
    17911799      char buf_ip[32]; 
    17921800      char buf_int_ip[32]; 
     
    17991807    } 
    18001808 
    1801     if ((u->LastOnline()>0) && gMainWindow->m_bPopLastOnline) { 
     1809    if (u && (u->LastOnline()>0) && gMainWindow->m_bPopLastOnline) 
     1810    { 
    18021811      QDateTime t; 
    18031812      t.setTime_t(u->LastOnline()); 
     
    18061815    } 
    18071816 
    1808     if ((!u->StatusOffline()) && gMainWindow->m_bPopOnlineSince) { 
     1817    if (u && (!u->StatusOffline()) && gMainWindow->m_bPopOnlineSince) 
     1818    { 
    18091819      time_t nLoggedIn = time(0) - u->OnlineSince(); 
    18101820      unsigned long nWeek, nDay, nHour, nMinute; 
     
    18481858    if (gMainWindow->m_bPopIdleTime) 
    18491859    { 
    1850       if (u->IdleSince()) 
     1860      if (u && u->IdleSince()) 
    18511861      { 
    18521862        char *szTemp; 
     
    18581868    } 
    18591869 
    1860     if (gMainWindow->m_bPopLocalTime) 
     1870    if (u && gMainWindow->m_bPopLocalTime) 
    18611871    { 
    18621872      char *szTemp; 
     
    18671877    } 
    18681878 
    1869     if (gMainWindow->m_bPopID) 
     1879    if (u && gMainWindow->m_bPopID) 
    18701880    { 
    18711881      char *szTemp; 
     
    18761886    } 
    18771887 
     1888    gUserManager.DropUser(u); 
     1889 
    18781890    tip(r, s); 
    18791891  }