Browse code

Fixed crash on closing a map

This is a crash introduced with
1afabff912bd959e866f084e9c65d89a9cbcf8db. We can't always call
TerrainBrush::updateBrush since it expects the current layer to be a
tile layer, which is not the case when the map is being closed (and the
brush set back to a null map).

Reviewed-by: Manu Evans

Thorbjørn Lindeijer authored on 04/06/2012 21:31:12
Showing 1 changed files
... ...
@@ -213,9 +213,10 @@ void TerrainBrush::mapDocumentChanged(MapDocument *oldDocument,
213 213
     AbstractTileTool::mapDocumentChanged(oldDocument, newDocument);
214 214
 
215 215
     // Reset the brush, since it probably became invalid
216
-    brushItem()->setTileRegion(QRegion());
216
+    brushItem()->setTileLayer(0);
217 217
 
218
-    setTerrain(firstTerrain(newDocument));
218
+    // Don't use setTerrain since we do not want to update the brush right now
219
+    mTerrain = firstTerrain(newDocument);
219 220
 }
220 221
 
221 222
 void TerrainBrush::setTerrain(const Terrain *terrain)