[Marble-commits] KDE/kdeedu/marble/src/lib

Jens-Michael Hoffmann jensmh at gmx.de
Sun Jan 31 10:28:29 CET 2010


SVN commit 1082697 by jmhoffmann:

Let TileLoader use HttpDownloadManager's downloadComplete( filename, id ) signal again.

This partly reverts the change for using the downloaded data directly w/o
loading it from the filesystem, because there is a problem with how the
cloud tiles are handled.

TileLoader::setLayer lets us specify for which map theme we want to load
tiles. The widget displays one map theme at a time, and when the users
switches to a different map theme, TileLoader::setLayer is called with the
new map theme as argument. The TileLoader internally manages a hash for fast
access to the tiles currently on display.

In MarbleModel::paintTile (with given tile), MergedLayerDecorator::paintTile
is called, the tile given is for example a tile of the bluemarble theme.
Then, in MergedLayerDecorator there is code to load the corresponding cloud
tile:
	TextureTile tile( TileId(...)); // here a empty TextureTile object is constructed

Then the tile's downloadTile signal is connected to MergedLayerDecorator's
downloadTile signal and then TextureTile::loadDataset is called.
In TextureTile::loadDataset the downloadTile signal is emitted (because the
tile was not yet locally available), which is connected to
HttpDownloadManager's addJob slot.
The tile is then downloaded and HttpDownloadManager emits the downloadComplete
signal, to which the TileLoader is connected. TileLoader then gets the data
and the TileId (which does not contain information about map themes, only
tile level, x and y), so the TileLoader updates the wrong tile, namely the
tile of the bluemarble theme.

 M  +19 -2     TileLoader.cpp  
 M  +2 -0      TileLoader.h  


--- trunk/KDE/kdeedu/marble/src/lib/TileLoader.cpp #1082696:1082697
@@ -100,8 +100,8 @@
 
     d->m_downloadManager = downloadManager;
     if ( d->m_downloadManager != 0 ) {
-        connect( d->m_downloadManager, SIGNAL( downloadComplete( QByteArray, QString )),
-                 SLOT( updateTile( QByteArray, QString )));
+        connect( d->m_downloadManager, SIGNAL( downloadComplete( QString, QString )),
+                 SLOT( updateTile( QString, QString )));
     }
 }
 
@@ -365,6 +365,23 @@
     }
 }
 
+void TileLoader::updateTile( const QString &fileName, const QString &idStr )
+{
+    if ( !d->m_layer )
+        return;
+
+    const TileId id = TileId::fromString( idStr );
+    if ( d->m_tilesOnDisplay.contains( id ) ) {
+        GeoSceneTexture * texture = static_cast<GeoSceneTexture *>( d->m_layer->groundDataset() );
+        d->m_tilesOnDisplay[id]->loadDataset( texture, &d->m_tileCache );
+        m_parent->paintTile( d->m_tilesOnDisplay[id], texture );
+        emit tileUpdateAvailable();
+    } else {
+        // Remove "false" tile from cache so it doesn't get loaded anymore
+        d->m_tileCache.remove( id );
+    }
+}
+
 void TileLoader::update()
 {
     mDebug() << "TileLoader::update()";
--- trunk/KDE/kdeedu/marble/src/lib/TileLoader.h #1082696:1082697
@@ -167,6 +167,8 @@
 
         void updateTile( const QByteArray &data, const QString &id );
 
+        void updateTile( const QString &fileName, const QString &id );
+
         /**
          * Effectively triggers a reload of all tiles that are currently in use
          * and clears the tile cache in physical memory.


More information about the Marble-commits mailing list