Merge lp:~gunchleoc/widelands/bug-1818494-ingame-zoom-freezes into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 9024
Proposed branch: lp:~gunchleoc/widelands/bug-1818494-ingame-zoom-freezes
Merge into: lp:widelands
Diff against target: 61 lines (+20/-0)
2 files modified
src/wui/mapview.cc (+16/-0)
src/wui/mapview.h (+4/-0)
To merge this branch: bzr merge lp:~gunchleoc/widelands/bug-1818494-ingame-zoom-freezes
Reviewer Review Type Date Requested Status
Benedikt Straub Approve
Review via email: mp+364304@code.launchpad.net

Commit message

Skip calculating changes to the map view's viewport when nothing would change. This prevents the map view from being busy when the user leans on the CTRL+/- keys.

Description of the change

I think this should go into Build 20, because it can make the player think that Widelands has crashed, while it's just the mapview being busy.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4610. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/508054518.
Appveyor build 4397. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_gunchleoc_widelands_bug_1818494_ingame_zoom_freezes-4397.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Just bumping this review. I'd like this branch in Build 20 to avoid getting bug reports when Widelands seems to freeze.

Revision history for this message
Benedikt Straub (nordfriese) wrote :

Code LGTM, works as expected.
Thanks for fixing this nasty bug :)

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for the review :)

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wui/mapview.cc'
2--- src/wui/mapview.cc 2019-02-23 11:00:49 +0000
3+++ src/wui/mapview.cc 2019-03-20 12:59:24 +0000
4@@ -387,6 +387,10 @@
5 const Transition transition = animate_map_panning_ ? passed_transition : Transition::Jump;
6 switch (transition) {
7 case Transition::Jump: {
8+ if (view_ == target_view) {
9+ // We're already there
10+ return;
11+ }
12 view_ = target_view;
13 MapviewPixelFunctions::normalize_pix(map_, &view_.viewpoint);
14 changeview();
15@@ -394,6 +398,10 @@
16 }
17
18 case Transition::Smooth: {
19+ if (!view_plans_.empty() && view_plans_.back().back().view == target_view) {
20+ // We're already there
21+ return;
22+ }
23 const TimestampedView current = animation_target_view();
24 const auto plan =
25 plan_map_transition(current.t, map_, current.view, target_view, get_w(), get_h());
26@@ -509,6 +517,10 @@
27 const TimestampedView current = animation_target_view();
28 switch (transition) {
29 case Transition::Jump: {
30+ if (view_.zoom == new_zoom) {
31+ // We're already there
32+ return;
33+ }
34 // Zoom around the current mouse position. See
35 // http://stackoverflow.com/questions/2916081/zoom-in-on-a-point-using-scale-and-translate
36 // for a good explanation of this math.
37@@ -518,6 +530,10 @@
38 }
39
40 case Transition::Smooth: {
41+ if (!view_plans_.empty() && view_plans_.back().back().view.zoom == new_zoom) {
42+ // We're already there
43+ return;
44+ }
45 const int w = get_w();
46 const int h = get_h();
47 const auto plan = plan_zoom_transition(
48
49=== modified file 'src/wui/mapview.h'
50--- src/wui/mapview.h 2019-02-23 11:00:49 +0000
51+++ src/wui/mapview.h 2019-03-20 12:59:24 +0000
52@@ -75,6 +75,10 @@
53 View() : View(Vector2f::zero(), 1.0f) {
54 }
55
56+ bool operator==(const View& other) const {
57+ return (zoom == other.zoom) && (viewpoint == other.viewpoint);
58+ }
59+
60 // Mappixel of top-left pixel of this MapView.
61 Vector2f viewpoint;
62

Subscribers

People subscribed via source and target branches

to status/vote changes: