← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/bug-1818494-reset-zoom-crash into lp:widelands

 

Wow, we should get the Map(s) this user created :-)

To reproduce the first problem we should edit the biggest maxium possible 
map with as many objects a possible and zomm out and in like mad. 
Never restart to get the overflow in that undo stack?.

An in a normal game this could happen, too?

Can we perhaps limit the maximum Zoom-factor to avoid this?

Some questions / comments inline.



Diff comments:

> === modified file 'src/editor/tools/history.cc'
> --- src/editor/tools/history.cc	2019-02-23 11:00:49 +0000
> +++ src/editor/tools/history.cc	2019-03-10 07:49:40 +0000
> @@ -115,6 +118,11 @@
>  		undo_stack_.push_front(ac);
>  		undo_button_.set_enabled(true);
>  		redo_button_.set_enabled(false);
> +		if (undo_stack_.size() > kMaximumUndoActions) {
> +			for (size_t i = 0; i < kTooManyUndoActionsDeleteBatch; ++i) {
> +				undo_stack_.pop_back();
> +			}
> +		}

A stack has no bulk operation fo this?

>  	}
>  	return tool.handle_click(ind, world, center, parent, ac.args, &map);
>  }
> 
> === modified file 'src/graphic/gl/fields_to_draw.cc'
> --- src/graphic/gl/fields_to_draw.cc	2019-02-23 11:00:49 +0000
> +++ src/graphic/gl/fields_to_draw.cc	2019-03-10 07:49:40 +0000
> @@ -106,7 +106,17 @@
>  
>  	w_ = max_fx_ - min_fx_ + 1;

This is FieldsToDraw::reset(), which is called when ctrl-0 or the Reset-zoom Button is pressed.

If this correct we should spend some comments on this function and its parameters.

>  	h_ = max_fy_ - min_fy_ + 1;
> -	const size_t dimension = w_ * h_;
> +	assert(w_ > 0);
> +	assert(h_ > 0);
> +
> +	// Ensure that there is enough memory for the resize operation
> +	size_t dimension = w_ * h_;
> +	const size_t max_dimension = fields_.max_size();
> +	if (dimension > max_dimension) {
> +		log("WARNING: Not enough memory allocated to redraw the whole map!\nWe recommend that you restart Widelands\n");
> +		dimension = max_dimension;
> +	}
> +	// Now resize the vector
>  	if (fields_.size() != dimension) {
>  		fields_.resize(dimension);
>  	}


-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1818494-reset-zoom-crash/+merge/364208
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1818494-reset-zoom-crash into lp:widelands.


References