[Kde-pim] [patch] handling of static data in akonadi and mailtransport

Jaroslaw Staniek js at iidea.pl
Mon May 19 21:42:42 BST 2008


Ingo Klöcker said the following, On 2008-05-19 21:12:
> On Monday 19 May 2008, Jarosław Staniek wrote:
>> -SmtpJob: added reverse hash so we don't need to perform linear
>> lookup in slavePool
> 
> That's not really worth the effort and the additional memory 
> allocations. In fact, a linear lookup on such a small number of 
> elements is often more efficient.
>
> 
>>   Index: mailtransport/socket.cpp
>> ===================================================================
>> --- mailtransport/socket.cpp    (wersja 809610)
>> +++ mailtransport/socket.cpp    (kopia robocza)
>> @@ -102,7 +102,7 @@
>>      return;
>>    }
>>  
>> -  static QString msg;
>> +  QString msg;
>>    msg += QLatin1String( socket->readAll() );
>>  
>>    if ( !msg.endsWith( QLatin1Char( '\n' ) ) ) {
> 
> This change is clearly wrong because the full code of this method reads:
> =====
> void SocketPrivate::slotSocketRead()
> {
>   kDebug();
> 
>   if ( !socket ) {
>     return;
>   }
> 
>   static QString msg;
>   msg += QLatin1String( socket->readAll() );
> 
>   if ( !msg.endsWith( QLatin1Char( '\n' ) ) ) {
>     return;
>   }
> 
> #ifdef comm_debug
>   kDebug() << socket->isEncrypted() << msg.trimmed();
> #endif
> 
>   emit q->data( msg );
>   msg.clear();
> }
> =====
> 
> So text is appended to the static QString msg until msg ends with '\n'. 
> Your patch will make the socket lose all text that does not end 
> with '\n'. Of course, there are much better ways than to use a static 
> QString for this, e.g. a member variable.

Thnaks and I will fix the issue ASAP.

-- 
regards / pozdrawiam, Jaroslaw Staniek
  Sponsored by OpenOffice Polska (http://www.openoffice.com.pl/en) to work on
  Kexi & KOffice (http://www.kexi.pl/en, http://www.koffice.org/kexi)
  KDE Libraries for MS Windows (http://windows.kde.org)
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list