changeset 675:eb9cad5fb771

* Fixed the Map editor crashes. The problem was a not cleaned RenderList in testRenderedViewPort(). This fixes also the same problem for the getMatchingInstances() functions. fixes[ticket:500]
author helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 09 Nov 2010 19:55:46 +0000
parents 20d1d695bf47
children f73be43f69c8
files engine/core/view/camera.cpp
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/engine/core/view/camera.cpp	Tue Nov 09 15:46:04 2010 +0000
+++ b/engine/core/view/camera.cpp	Tue Nov 09 19:55:46 2010 +0000
@@ -416,10 +416,10 @@
 
 		const std::list<Layer*>& layers = map->getLayers();
 		std::list<Layer*>::const_iterator layer_it = layers.begin();
+		m_layer_to_instances.clear();
 		const RenderList& layer_instances = m_layer_to_instances[*layer_it];
 		RenderList::const_iterator instance_it = layer_instances.begin();
 		for(; instance_it != layer_instances.end(); ++instance_it) {
-			Instance* i = (*instance_it)->instance;
 			const RenderItem& vc = **instance_it;
 			if(vc.dimensions.intersects(rec1) && !trec1) {
 				trec1 = true;
@@ -434,7 +434,6 @@
 		if(trec1 && trec2) {
 			RenderList::const_reverse_iterator instance_itr = layer_instances.rbegin();
 			for(; instance_itr != layer_instances.rend(); ++instance_itr) {
-				Instance* i = (*instance_itr)->instance;
 				const RenderItem& vc = **instance_itr;
 				if(vc.dimensions.intersects(rec3) && !trec3) {
 					trec3 = true;
@@ -456,6 +455,7 @@
 
 	void Camera::getMatchingInstances(ScreenPoint screen_coords, Layer& layer, std::list<Instance*>& instances) {
 		instances.clear();
+		m_layer_to_instances.clear();
 		const RenderList& layer_instances = m_layer_to_instances[&layer];
 		RenderList::const_iterator instance_it = layer_instances.end();
 		while (instance_it != layer_instances.begin()) {
@@ -488,6 +488,7 @@
 
 	void Camera::getMatchingInstances(Rect screen_rect, Layer& layer, std::list<Instance*>& instances) {
 		instances.clear();
+		m_layer_to_instances.clear();
 		const RenderList& layer_instances = m_layer_to_instances[&layer];
 		RenderList::const_iterator instance_it = layer_instances.end();
 		while (instance_it != layer_instances.begin()) {
@@ -528,6 +529,7 @@
 
 	void Camera::getMatchingInstances(Location& loc, std::list<Instance*>& instances, bool use_exactcoordinates) {
 		instances.clear();
+		m_layer_to_instances.clear();
 		const RenderList& layer_instances = m_layer_to_instances[loc.getLayer()];
 		RenderList::const_iterator instance_it = layer_instances.end();
 		while (instance_it != layer_instances.begin()) {