avoid possible segv when recreating tiles (e.g. when returning to MapActivity)

This commit is contained in:
Hannes Janetzek 2012-11-25 22:14:00 +01:00
parent 17a610e06e
commit 2ac904ecef

View File

@ -171,8 +171,6 @@ public class TileManager {
// clear all tiles references // clear all tiles references
Log.d(TAG, "CLEAR " + mInitial); Log.d(TAG, "CLEAR " + mInitial);
mUpdateCnt = 0;
if (clear) { if (clear) {
// pass VBOs and VertexItems back to pools // pass VBOs and VertexItems back to pools
for (MapTile t : mTiles) for (MapTile t : mTiles)
@ -187,6 +185,10 @@ public class TileManager {
mTiles.clear(); mTiles.clear();
mTilesLoaded.clear(); mTilesLoaded.clear();
//mUpdateCnt = 0;
for (TileSet td : mTileSets)
td.cnt = 0;
// set up TileData arrays that are passed to gl-thread // set up TileData arrays that are passed to gl-thread
int num = Math.max(mWidth, mHeight); int num = Math.max(mWidth, mHeight);
int size = Tile.TILE_SIZE >> 1; int size = Tile.TILE_SIZE >> 1;
@ -196,7 +198,7 @@ public class TileManager {
GLRenderer.drawlock.unlock(); GLRenderer.drawlock.unlock();
// .. make sure mMapPosition will be updated // make sure mMapPosition will be updated
mMapPosition.zoomLevel = -1; mMapPosition.zoomLevel = -1;
mInitial = false; mInitial = false;
} }
@ -239,6 +241,9 @@ public class TileManager {
} }
} }
/// EEEK, need to keep track of TileSets to clear on reset...
private static ArrayList<TileSet> mTileSets = new ArrayList<TileSet>(2);
public static TileSet getActiveTiles(TileSet td) { public static TileSet getActiveTiles(TileSet td) {
if (mCurrentTiles == null) if (mCurrentTiles == null)
return td; return td;
@ -259,11 +264,13 @@ public class TileManager {
if (td == null) { if (td == null) {
td = new TileSet(newTiles.length); td = new TileSet(newTiles.length);
} else if (td.serial > mUpdateCnt) { mTileSets.add(td);
Log.d(TAG, "ignore previous tile data " + td.cnt);
// tile data was cleared, ignore tiles
td.cnt = 0;
} }
// else if (td.serial > mUpdateCnt) {
// Log.d(TAG, "ignore previous tile data " + td.cnt);
// // tile data was cleared, ignore tiles
// td.cnt = 0;
// }
nextTiles = td.tiles; nextTiles = td.tiles;
// unlock previously active tiles // unlock previously active tiles