After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 764433 - Setting world on a default-constructed bounding box freezes the view.
Setting world on a default-constructed bounding box freezes the view.
Status: RESOLVED FIXED
Product: libchamplain
Classification: Core
Component: view
unspecified
Other Linux
: Normal normal
: ---
Assigned To: libchamplain-maint
libchamplain-maint
Depends on:
Blocks:
 
 
Reported: 2016-03-31 19:39 UTC by Marius Stanciu
Modified: 2016-04-02 18:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
champlain-vew: Add valid bounding-box check for champlain_view_set_world (841 bytes, patch)
2016-03-31 19:44 UTC, Marius Stanciu
none Details | Review
champlain-view: Add valid bouding-box check for champlain_view_set_world (843 bytes, patch)
2016-04-02 16:33 UTC, Marius Stanciu
none Details | Review

Description Marius Stanciu 2016-03-31 19:39:56 UTC
Using:
   ChamplainBoundingBox *bbox = champlain_bounding_box_new();
   champlain_view_set_world(view, bbox);

then any other view interaction such as:
   champlain_view_zoom_out(view);

causes an infinite loop in champlain-viewport.c: hadjustment_value_notify_cb()
(the notify callback function modifies the property so it causes another call)

I've come up with a fix, but I'm not really sure about a few things:

1)
champlain_bounding_box_new() returns an invalid bounding box
(champlain_bounding_box_is_valid(bbox) is false).

Is there a reason why that constructor sets the bounding box extremities totally wrong like this:

  bbox->left = CHAMPLAIN_MAX_LONGITUDE;
  bbox->right = CHAMPLAIN_MIN_LONGITUDE;
  bbox->bottom = CHAMPLAIN_MAX_LATITUDE;
  bbox->top = CHAMPLAIN_MIN_LATITUDE;

Shouldn't it be:

  bbox->left = CHAMPLAIN_MIN_LONGITUDE;
  bbox->right = CHAMPLAIN_MAX_LONGITUDE;
  bbox->bottom = CHAMPLAIN_MIN_LATITUDE;
  bbox->top = CHAMPLAIN_MAX_LATITUDE;

?

2)
Also, setting the world with an invalid bbox shouldn't be allowed anyway( it totally messes up the view ), so I've attached a patch that adds a check in the champlain_view_set_world function.
Comment 1 Marius Stanciu 2016-03-31 19:44:47 UTC
Created attachment 325112 [details] [review]
champlain-vew: Add valid bounding-box check for champlain_view_set_world
Comment 2 Jiri Techet 2016-04-02 08:36:17 UTC
(In reply to Marius Stanciu from comment #0)
> Using:
>    ChamplainBoundingBox *bbox = champlain_bounding_box_new();
>    champlain_view_set_world(view, bbox);
> 
> then any other view interaction such as:
>    champlain_view_zoom_out(view);
> 
> causes an infinite loop in champlain-viewport.c:
> hadjustment_value_notify_cb()
> (the notify callback function modifies the property so it causes another
> call)
> 
> I've come up with a fix, but I'm not really sure about a few things:
> 
> 1)
> champlain_bounding_box_new() returns an invalid bounding box
> (champlain_bounding_box_is_valid(bbox) is false).
> 
> Is there a reason why that constructor sets the bounding box extremities
> totally wrong like this:
> 
>   bbox->left = CHAMPLAIN_MAX_LONGITUDE;
>   bbox->right = CHAMPLAIN_MIN_LONGITUDE;
>   bbox->bottom = CHAMPLAIN_MAX_LATITUDE;
>   bbox->top = CHAMPLAIN_MIN_LATITUDE;
> 
> Shouldn't it be:
> 
>   bbox->left = CHAMPLAIN_MIN_LONGITUDE;
>   bbox->right = CHAMPLAIN_MAX_LONGITUDE;
>   bbox->bottom = CHAMPLAIN_MIN_LATITUDE;
>   bbox->top = CHAMPLAIN_MAX_LATITUDE;
> 
> ?

This is intentional. Basically the idea is to have the initial values set to the opposite extremes so when extended with another bounding box using champlain_bounding_box_extend(), its value becomes the new bounding box. Or in other words, champlain_bounding_box_new() creates a bounding box corresponding go "empty set" and champlain_bounding_box_extend() behaves like union.

This is for instance used in get_bounding_box() in champlain-path-layer.c.

> 
> 2)
> Also, setting the world with an invalid bbox shouldn't be allowed anyway( it
> totally messes up the view ), so I've attached a patch that adds a check in
> the champlain_view_set_world function.

This is a problem though. Maybe I'd just not issue a warning when this happens and test the champlain_bounding_box_is_valid() using normal if like we already do in champlain_view_ensure_visible(). Could you update the patch this way?
Comment 3 Marius Stanciu 2016-04-02 16:33:55 UTC
Created attachment 325227 [details] [review]
champlain-view: Add valid bouding-box check for champlain_view_set_world
Comment 4 Jiri Techet 2016-04-02 18:51:56 UTC
Applied, thanks!