[Marble-commits] KDE/kdeedu/marble/src/plugins/runner/monav
Dennis Nienhüser
earthwings at gentoo.org
Wed Nov 3 20:04:20 CET 2010
SVN commit 1192694 by nienhueser:
Write downloaded data to disk immediately as intended, don't cache it in memory.
M +20 -12 MonavConfigWidget.cpp
M +3 -1 MonavConfigWidget.h
--- trunk/KDE/kdeedu/marble/src/plugins/runner/monav/MonavConfigWidget.cpp #1192693:1192694
@@ -385,24 +385,29 @@
return settings;
}
-void MonavConfigWidget::retrieveData( QNetworkReply *reply )
+void MonavConfigWidget::retrieveMapList( QNetworkReply *reply )
{
- if ( reply->isReadable() ) {
- if ( !d->m_currentDownload.isEmpty() ) {
- d->m_currentFile.write( reply->readAll() );
- if ( reply->isFinished() ) {
- reply->deleteLater();
+ if ( reply->isReadable() && d->m_currentDownload.isEmpty() ) {
+ disconnect( d->m_networkAccessManager, SIGNAL( finished( QNetworkReply * ) ),
+ this, SLOT( retrieveMapList( QNetworkReply * ) ) );
+ d->parseNewStuff( reply->readAll() );
+ updateComboBoxes();
+ }
+}
+
+void MonavConfigWidget::retrieveData()
+{
+ if ( d->m_currentReply && d->m_currentReply->isReadable() && !d->m_currentDownload.isEmpty() ) {
+ d->m_currentFile.write( d->m_currentReply->readAll() );
+ if ( d->m_currentReply->isFinished() ) {
+ d->m_currentReply->deleteLater();
d->m_currentReply = 0;
d->m_currentFile.close();
d->installMap();
d->m_currentDownload = QString();
}
- } else {
- d->parseNewStuff( reply->readAll() );
- updateComboBoxes();
}
}
-}
void MonavConfigWidget::updateComboBoxes()
{
@@ -468,6 +473,10 @@
QString message = QObject::tr( "Downloading %1" ).arg( file.fileName() );
setBusy( true, message );
m_currentReply = m_networkAccessManager->get( QNetworkRequest( m_currentDownload ) );
+ QObject::connect( m_currentReply, SIGNAL( readyRead() ),
+ m_parent, SLOT( retrieveData() ) );
+ QObject::connect( m_currentReply, SIGNAL( readChannelFinished() ),
+ m_parent, SLOT( retrieveData() ) );
QObject::connect( m_currentReply, SIGNAL( downloadProgress( qint64, qint64 ) ),
m_parent, SLOT( updateProgressBar( qint64, qint64 ) ) );
} else {
@@ -552,8 +561,7 @@
d->updateInstalledMapsView();
d->m_networkAccessManager = new QNetworkAccessManager( this );
connect( d->m_networkAccessManager, SIGNAL( finished( QNetworkReply * ) ),
- this, SLOT( retrieveData( QNetworkReply * ) ) );
-
+ this, SLOT( retrieveMapList( QNetworkReply * ) ) );
QUrl url = QUrl( "http://edu.kde.org/marble/newstuff/maps-monav.xml" );
d->m_networkAccessManager->get( QNetworkRequest( url ) );
}
--- trunk/KDE/kdeedu/marble/src/plugins/runner/monav/MonavConfigWidget.h #1192693:1192694
@@ -41,8 +41,10 @@
virtual void showEvent ( QShowEvent * event );
private Q_SLOTS:
- void retrieveData( QNetworkReply *reply );
+ void retrieveMapList( QNetworkReply *reply );
+ void retrieveData();
+
void updateComboBoxes();
void updateStates();
More information about the Marble-commits
mailing list