← Back to team overview

widelands-dev team mailing list archive

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

 

Thanks for the review!

@bunnybot merge

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();
> +			}
> +		}

Good point - there is: http://www.cplusplus.com/reference/deque/deque/erase/

This is non-trivial though, because it can't trivially move the contents. It's also not exception-safe, so I'll leave things as is for now. I don't think that we can gain much performance here anyway.

>  	}
>  	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;

It is called every time the panel thinks, actually. It skips the vector resize when the size has not changed, to that bis is triggered by any change in the zoom factor, or when toggling fullscreen mode.

>  	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 subscribed to branch lp:~widelands-dev/widelands/bug-1818494-reset-zoom-crash.


References