Changeset 13864


Ignore:
Timestamp:
Jan 25, 2013, 5:43:22 AM (8 years ago)
Author:
jordan
Message:

(qt) #5252 'File-renaming causes QObject::startTimer error': probable fix.

Location:
trunk/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/session.cc

    r13829 r13864  
    2828#include <QStyle>
    2929#include <QTextStream>
    30 #include <QTimer>
    3130
    3231#include <curl/curl.h>
     
    249248    mySession( 0 ),
    250249    myConfigDir( QString::fromUtf8( configDir ) ),
    251     myNAM( 0 ),
    252     myResponseTimer (this)
     250    myNAM( 0 )
    253251{
    254252    myStats.ratio = TR_RATIO_NA;
     
    262260    connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(updatePref(int)) );
    263261
    264     connect (&myResponseTimer, SIGNAL(timeout()), this, SLOT(onResponseTimer()));
    265     myResponseTimer.setSingleShot (true);
     262    connect (this, SIGNAL(responseReceived(const QByteArray&)),
     263             this, SLOT(onResponseReceived(const QByteArray&)));
    266264}
    267265
     
    657655
    658656void
    659 Session :: localSessionCallback( tr_session * session, struct evbuffer * json, void * vself )
    660 {
    661   Q_UNUSED (session);
     657Session :: localSessionCallback( tr_session * s, struct evbuffer * json, void * vself )
     658{
     659  Q_UNUSED (s);
    662660
    663661  Session * self = static_cast<Session*>(vself);
    664662
    665   self->myIdleJSON.append (QString ((const char*) evbuffer_pullup (json, -1)));
    666 
    667   if (!self->myResponseTimer.isActive())
    668     self->myResponseTimer.start(50);
     663  /* this callback is invoked in the libtransmission thread, so we don't want
     664     to process the response here... let's push it over to the Qt thread. */
     665  self->responseReceived (QByteArray ((const char *)evbuffer_pullup (json, -1),
     666                                      (int)evbuffer_get_length (json)));
    669667}
    670668
     
    743741
    744742void
    745 Session :: onResponseTimer ()
    746 {
    747   QStringList responses = myIdleJSON;
    748   myIdleJSON.clear();
    749 
    750   foreach (QString response, responses)
    751     {
    752       const QByteArray utf8 (response.toUtf8());
    753       parseResponse (utf8.constData(), utf8.length());
    754     }
     743Session :: onResponseReceived (const QByteArray& utf8)
     744{
     745  parseResponse (utf8.constData(), utf8.length());
    755746}
    756747
  • trunk/qt/session.h

    r13810 r13864  
    2121#include <QString>
    2222#include <QStringList>
    23 #include <QTimer>
    2423#include <QUrl>
    2524
     
    132131    private slots:
    133132        void onFinished( QNetworkReply * reply );
    134         void onResponseTimer( );
     133        void onResponseReceived (const QByteArray& json);
    135134
    136135    signals:
     136        void responseReceived (const QByteArray& json);
    137137        void executed( int64_t tag, const QString& result, struct tr_variant * arguments );
    138138        void sourceChanged( );
     
    160160        struct tr_session_stats myCumulativeStats;
    161161        QString mySessionVersion;
    162         QTimer myResponseTimer;
    163162};
    164163
Note: See TracChangeset for help on using the changeset viewer.