Changeset 13864
- Timestamp:
- Jan 25, 2013, 5:43:22 AM (8 years ago)
- Location:
- trunk/qt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/session.cc
r13829 r13864 28 28 #include <QStyle> 29 29 #include <QTextStream> 30 #include <QTimer>31 30 32 31 #include <curl/curl.h> … … 249 248 mySession( 0 ), 250 249 myConfigDir( QString::fromUtf8( configDir ) ), 251 myNAM( 0 ), 252 myResponseTimer (this) 250 myNAM( 0 ) 253 251 { 254 252 myStats.ratio = TR_RATIO_NA; … … 262 260 connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(updatePref(int)) ); 263 261 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&))); 266 264 } 267 265 … … 657 655 658 656 void 659 Session :: localSessionCallback( tr_session * s ession, struct evbuffer * json, void * vself )660 { 661 Q_UNUSED (s ession);657 Session :: localSessionCallback( tr_session * s, struct evbuffer * json, void * vself ) 658 { 659 Q_UNUSED (s); 662 660 663 661 Session * self = static_cast<Session*>(vself); 664 662 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))); 669 667 } 670 668 … … 743 741 744 742 void 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 } 743 Session :: onResponseReceived (const QByteArray& utf8) 744 { 745 parseResponse (utf8.constData(), utf8.length()); 755 746 } 756 747 -
trunk/qt/session.h
r13810 r13864 21 21 #include <QString> 22 22 #include <QStringList> 23 #include <QTimer>24 23 #include <QUrl> 25 24 … … 132 131 private slots: 133 132 void onFinished( QNetworkReply * reply ); 134 void onResponse Timer();133 void onResponseReceived (const QByteArray& json); 135 134 136 135 signals: 136 void responseReceived (const QByteArray& json); 137 137 void executed( int64_t tag, const QString& result, struct tr_variant * arguments ); 138 138 void sourceChanged( ); … … 160 160 struct tr_session_stats myCumulativeStats; 161 161 QString mySessionVersion; 162 QTimer myResponseTimer;163 162 }; 164 163
Note: See TracChangeset
for help on using the changeset viewer.